Version Description
- Improved user experience with AAM UI
- Removed Welcome message
- Fixed bug with media access
- Added filter for AAM shordcodes so other plugins can hook to AAM
- Optimized AAM javascript
- Removed subscription box to reduce "UI noise" as more features are coming
Download this release
Release Info
Developer | vasyl_m |
Plugin | Advanced Access Manager |
Version | 4.9.5 |
Comparing to | |
See all releases |
Code changes from version 4.9.4 to 4.9.5
- Application/Backend/Manager.php +0 -1
- Application/Backend/View.php +0 -26
- Application/Backend/phtml/index.phtml +3 -16
- Application/Core/Media.php +7 -11
- Application/Core/Server.php +1 -27
- Application/Shortcode/Factory.php +1 -1
- aam.php +1 -1
- media/js/aam-interface.js +0 -2712
- media/js/aam.js +2684 -11
- readme.txt +9 -1
Application/Backend/Manager.php
CHANGED
@@ -425,7 +425,6 @@ class AAM_Backend_Manager {
|
|
425 |
'ajaxurl' => admin_url('admin-ajax.php'),
|
426 |
'url' => array(
|
427 |
'site' => admin_url('index.php'),
|
428 |
-
'jsbase' => AAM_MEDIA . '/js',
|
429 |
'editUser' => admin_url('user-edit.php'),
|
430 |
'addUser' => admin_url('user-new.php')
|
431 |
),
|
425 |
'ajaxurl' => admin_url('admin-ajax.php'),
|
426 |
'url' => array(
|
427 |
'site' => admin_url('index.php'),
|
|
|
428 |
'editUser' => admin_url('user-edit.php'),
|
429 |
'addUser' => admin_url('user-new.php')
|
430 |
),
|
Application/Backend/View.php
CHANGED
@@ -221,32 +221,6 @@ class AAM_Backend_View {
|
|
221 |
return $this->getSubject()->resetObject(AAM_Core_Request::post('object'));
|
222 |
}
|
223 |
|
224 |
-
/**
|
225 |
-
*
|
226 |
-
* @return type
|
227 |
-
*/
|
228 |
-
public function subscribe() {
|
229 |
-
$email = filter_var(
|
230 |
-
AAM_Core_Request::post('email'), FILTER_VALIDATE_EMAIL
|
231 |
-
);
|
232 |
-
|
233 |
-
if ($email) {
|
234 |
-
$response = AAM_Core_Server::subscribe($email);
|
235 |
-
} else {
|
236 |
-
$response = array(
|
237 |
-
'status' => 'failure', 'reason' => __('Invalid Email', AAM_KEY)
|
238 |
-
);
|
239 |
-
}
|
240 |
-
|
241 |
-
if (is_wp_error($response)) {
|
242 |
-
$response = array(
|
243 |
-
'status' => 'failure', 'reason' => $response->get_error_message()
|
244 |
-
);
|
245 |
-
}
|
246 |
-
|
247 |
-
return json_encode($response);
|
248 |
-
}
|
249 |
-
|
250 |
/**
|
251 |
*
|
252 |
* @return type
|
221 |
return $this->getSubject()->resetObject(AAM_Core_Request::post('object'));
|
222 |
}
|
223 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
224 |
/**
|
225 |
*
|
226 |
* @return type
|
Application/Backend/phtml/index.phtml
CHANGED
@@ -15,7 +15,9 @@
|
|
15 |
<span class="aam-help-menu" data-target="#access-manager-inside"><i class="icon-help-circled"></i></span>
|
16 |
</h3>
|
17 |
<div class="inside" id="access-manager-inside">
|
18 |
-
<div class="aam-postbox-inside" id="aam-content"
|
|
|
|
|
19 |
<div class="aam-help-context" >
|
20 |
<div class="text-justify aam-large-padding">
|
21 |
<p class="text-larger"><?php echo __('Appreciate your interest in Advanced Access Manager (AAM). With strong knowledge and experience in WordPress, AAM becomes a very powerful tool to manage access to your frontend and backend.', AAM_KEY); ?></p>
|
@@ -269,21 +271,6 @@
|
|
269 |
<p class="aam-promo"><strong>NEED HELP FASTER?</strong><br/>Get in touch with Google Hangouts.<br/><b>It is free.</b></p>
|
270 |
<a href="mailto:support@aamplugin.com" class="btn btn-success" target="_blank"><i class="icon-chat-empty"></i> support@aamplugin.com</a>
|
271 |
</div>
|
272 |
-
|
273 |
-
<hr/>
|
274 |
-
|
275 |
-
<label for="extension-key"><?php echo __('Subscribe to updates', AAM_KEY); ?></label><a href="#" data-toggle="tooltip" title="<?php echo __('Get once a month the email with the latest AAM features and promo-codes', AAM_KEY) ?>"><i class="icon-help-circled"></i></a>
|
276 |
-
<div class="row">
|
277 |
-
<div class="col-xs-8">
|
278 |
-
<div class="form-group">
|
279 |
-
<input type="text" class="form-control" id="subscribe-email" placeholder="<?php echo __('Your Email Address', AAM_KEY); ?>" />
|
280 |
-
</div>
|
281 |
-
</div>
|
282 |
-
<div class="col-xs-4">
|
283 |
-
<button class="btn btn-primary btn-block" id="subscribe"><i class="icon-rss"></i> <?php echo __('Submit', AAM_KEY); ?></button>
|
284 |
-
</div>
|
285 |
-
</div>
|
286 |
-
|
287 |
</div>
|
288 |
</div>
|
289 |
</div>
|
15 |
<span class="aam-help-menu" data-target="#access-manager-inside"><i class="icon-help-circled"></i></span>
|
16 |
</h3>
|
17 |
<div class="inside" id="access-manager-inside">
|
18 |
+
<div class="aam-postbox-inside" id="aam-content">
|
19 |
+
<p class="alert alert-info text-larger text-center" id="aam-initial-load"><?php echo AAM_Backend_View_Helper::preparePhrase('[Loading AAM UI]. Please wait few seconds. If content will not load within next 30 seconds, clear your browser cache and reload the page. If still nothing, it is most likely some sort of JavaScript or CSS conflict with one your active plugins or theme. [Contact as immediately if you are having troubles with loading AAM].', 'strong', 'strong'); ?></p>
|
20 |
+
</div>
|
21 |
<div class="aam-help-context" >
|
22 |
<div class="text-justify aam-large-padding">
|
23 |
<p class="text-larger"><?php echo __('Appreciate your interest in Advanced Access Manager (AAM). With strong knowledge and experience in WordPress, AAM becomes a very powerful tool to manage access to your frontend and backend.', AAM_KEY); ?></p>
|
271 |
<p class="aam-promo"><strong>NEED HELP FASTER?</strong><br/>Get in touch with Google Hangouts.<br/><b>It is free.</b></p>
|
272 |
<a href="mailto:support@aamplugin.com" class="btn btn-success" target="_blank"><i class="icon-chat-empty"></i> support@aamplugin.com</a>
|
273 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
274 |
</div>
|
275 |
</div>
|
276 |
</div>
|
Application/Core/Media.php
CHANGED
@@ -45,14 +45,6 @@ class AAM_Core_Media {
|
|
45 |
*/
|
46 |
protected function __construct() {
|
47 |
if (AAM_Core_Request::get('aam-media')) {
|
48 |
-
if (AAM_Core_Request::get('debug')) {
|
49 |
-
file_put_contents(
|
50 |
-
dirname(__FILE__) . '/debug.log',
|
51 |
-
print_r(AAM_Core_Request::server(), 1) . "\n",
|
52 |
-
FILE_APPEND
|
53 |
-
);
|
54 |
-
}
|
55 |
-
|
56 |
$this->initialize();
|
57 |
|
58 |
if (AAM_Core_Config::get('media-access-control', false)) {
|
@@ -142,16 +134,20 @@ class AAM_Core_Media {
|
|
142 |
}
|
143 |
|
144 |
//normalize path and strip all unexpected trails. Thanks to Antonius Hegyes
|
145 |
-
$path
|
|
|
|
|
|
|
|
|
146 |
|
147 |
if (empty($mime)) {
|
148 |
if (function_exists('mime_content_type')) {
|
149 |
-
$mime = mime_content_type($
|
150 |
}
|
151 |
}
|
152 |
|
153 |
@header('Content-Type: ' . (empty($mime) ? $type : $mime));
|
154 |
-
echo file_get_contents($
|
155 |
exit;
|
156 |
}
|
157 |
|
45 |
*/
|
46 |
protected function __construct() {
|
47 |
if (AAM_Core_Request::get('aam-media')) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
$this->initialize();
|
49 |
|
50 |
if (AAM_Core_Config::get('media-access-control', false)) {
|
134 |
}
|
135 |
|
136 |
//normalize path and strip all unexpected trails. Thanks to Antonius Hegyes
|
137 |
+
$path = preg_replace('/\?.*$/', '', $path);
|
138 |
+
$rpath = preg_replace('/\?.*$/', '', $this->request_uri);
|
139 |
+
|
140 |
+
//finally replace the filename with requested filename
|
141 |
+
$request = str_replace(basename($path), basename($rpath), $path);
|
142 |
|
143 |
if (empty($mime)) {
|
144 |
if (function_exists('mime_content_type')) {
|
145 |
+
$mime = mime_content_type($request);
|
146 |
}
|
147 |
}
|
148 |
|
149 |
@header('Content-Type: ' . (empty($mime) ? $type : $mime));
|
150 |
+
echo file_get_contents($request);
|
151 |
exit;
|
152 |
}
|
153 |
|
Application/Core/Server.php
CHANGED
@@ -62,8 +62,7 @@ final class AAM_Core_Server {
|
|
62 |
$params = array(
|
63 |
'domain' => parse_url(site_url(), PHP_URL_HOST),
|
64 |
'version' => AAM_Core_API::version(),
|
65 |
-
'uid' => AAM_Core_API::getOption('aam-uid', null, 'site')
|
66 |
-
'email' => AAM_Core_API::getOption('admin_email')
|
67 |
);
|
68 |
|
69 |
$response = self::send('/check', $params);
|
@@ -113,31 +112,6 @@ final class AAM_Core_Server {
|
|
113 |
return $result;
|
114 |
}
|
115 |
|
116 |
-
/**
|
117 |
-
* Subscribe to updates
|
118 |
-
*
|
119 |
-
* @param string $email
|
120 |
-
*
|
121 |
-
* @return array
|
122 |
-
*
|
123 |
-
* @access public
|
124 |
-
*/
|
125 |
-
public static function subscribe($email) {
|
126 |
-
$response = self::send('/subscribe', array('email' => $email));
|
127 |
-
|
128 |
-
if (!is_wp_error($response)) {
|
129 |
-
if ($response->error === true) {
|
130 |
-
$result = new WP_Error($response->code, $response->message);
|
131 |
-
} else {
|
132 |
-
$result = $response;
|
133 |
-
}
|
134 |
-
} else {
|
135 |
-
$result = $response;
|
136 |
-
}
|
137 |
-
|
138 |
-
return $result;
|
139 |
-
}
|
140 |
-
|
141 |
/**
|
142 |
* Send request
|
143 |
*
|
62 |
$params = array(
|
63 |
'domain' => parse_url(site_url(), PHP_URL_HOST),
|
64 |
'version' => AAM_Core_API::version(),
|
65 |
+
'uid' => AAM_Core_API::getOption('aam-uid', null, 'site')
|
|
|
66 |
);
|
67 |
|
68 |
$response = self::send('/check', $params);
|
112 |
return $result;
|
113 |
}
|
114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
/**
|
116 |
* Send request
|
117 |
*
|
Application/Shortcode/Factory.php
CHANGED
@@ -36,7 +36,7 @@ class AAM_Shortcode_Factory {
|
|
36 |
$this->strategy = new $classname($args, $content);
|
37 |
} else {
|
38 |
$this->strategy = apply_filters(
|
39 |
-
'aam-shortcode-
|
40 |
);
|
41 |
}
|
42 |
}
|
36 |
$this->strategy = new $classname($args, $content);
|
37 |
} else {
|
38 |
$this->strategy = apply_filters(
|
39 |
+
'aam-shortcode-filter', null, $context, $args, $content
|
40 |
);
|
41 |
}
|
42 |
}
|
aam.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
Plugin Name: Advanced Access Manager
|
5 |
Description: All you need to manage access to your WordPress website
|
6 |
-
Version: 4.9.
|
7 |
Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
Author URI: https://vasyltech.com
|
9 |
|
3 |
/**
|
4 |
Plugin Name: Advanced Access Manager
|
5 |
Description: All you need to manage access to your WordPress website
|
6 |
+
Version: 4.9.5
|
7 |
Author: Vasyl Martyniuk <vasyl@vasyltech.com>
|
8 |
Author URI: https://vasyltech.com
|
9 |
|
media/js/aam-interface.js
DELETED
@@ -1,2712 +0,0 @@
|
|
1 |
-
/**
|
2 |
-
* ======================================================================
|
3 |
-
* LICENSE: This file is subject to the terms and conditions defined in *
|
4 |
-
* file 'license.txt', which is part of this source code package. *
|
5 |
-
* ======================================================================
|
6 |
-
*/
|
7 |
-
|
8 |
-
/**
|
9 |
-
* Role List Interface
|
10 |
-
*
|
11 |
-
* @param {jQuery} $
|
12 |
-
*
|
13 |
-
* @returns {void}
|
14 |
-
*/
|
15 |
-
(function ($) {
|
16 |
-
|
17 |
-
/**
|
18 |
-
*
|
19 |
-
* @param {type} id
|
20 |
-
* @returns {Boolean}
|
21 |
-
*/
|
22 |
-
function isCurrent(id) {
|
23 |
-
var subject = aam.getSubject();
|
24 |
-
|
25 |
-
return (subject.type === 'role' && subject.id === id);
|
26 |
-
}
|
27 |
-
|
28 |
-
/**
|
29 |
-
*
|
30 |
-
* @returns {undefined}
|
31 |
-
*/
|
32 |
-
function fetchRoleList(exclude) {
|
33 |
-
$.ajax(aamLocal.ajaxurl, {
|
34 |
-
type: 'POST',
|
35 |
-
dataType: 'json',
|
36 |
-
data: {
|
37 |
-
action: 'aam',
|
38 |
-
sub_action: 'Role.getList',
|
39 |
-
_ajax_nonce: aamLocal.nonce,
|
40 |
-
exclude: exclude
|
41 |
-
},
|
42 |
-
beforeSend: function () {
|
43 |
-
$('.inherit-role-list').html(
|
44 |
-
'<option value="">' + aam.__('Loading...') + '</option>'
|
45 |
-
);
|
46 |
-
},
|
47 |
-
success: function (response) {
|
48 |
-
$('.inherit-role-list').html(
|
49 |
-
'<option value="">' + aam.__('No Role') + '</option>'
|
50 |
-
);
|
51 |
-
for (var i in response) {
|
52 |
-
$('.inherit-role-list').append(
|
53 |
-
'<option value="' + i + '">' + response[i].name + '</option>'
|
54 |
-
);
|
55 |
-
}
|
56 |
-
if ($.aamEditRole) {
|
57 |
-
$('#inherit-role').val($.aamEditRole[0]);
|
58 |
-
}
|
59 |
-
aam.triggerHook('post-get-role-list', {
|
60 |
-
list : response
|
61 |
-
});
|
62 |
-
//TODO - Rerwite JavaScript to support $.aam
|
63 |
-
$.aamEditRole = null;
|
64 |
-
}
|
65 |
-
});
|
66 |
-
}
|
67 |
-
|
68 |
-
//initialize the role list table
|
69 |
-
$('#role-list').DataTable({
|
70 |
-
autoWidth: false,
|
71 |
-
ordering: false,
|
72 |
-
dom: 'ftrip',
|
73 |
-
pagingType: 'simple',
|
74 |
-
processing: true,
|
75 |
-
serverSide: false,
|
76 |
-
ajax: {
|
77 |
-
url: aamLocal.ajaxurl,
|
78 |
-
type: 'POST',
|
79 |
-
dataType: 'json',
|
80 |
-
data: {
|
81 |
-
action: 'aam',
|
82 |
-
sub_action: 'Role.getTable',
|
83 |
-
_ajax_nonce: aamLocal.nonce
|
84 |
-
}
|
85 |
-
},
|
86 |
-
columnDefs: [
|
87 |
-
{visible: false, targets: [0, 1, 4, 5]}
|
88 |
-
],
|
89 |
-
language: {
|
90 |
-
search: '_INPUT_',
|
91 |
-
searchPlaceholder: aam.__('Search Role'),
|
92 |
-
info: aam.__('_TOTAL_ role(s)'),
|
93 |
-
infoFiltered: ''
|
94 |
-
},
|
95 |
-
initComplete: function () {
|
96 |
-
if (!aam.isUI() && parseInt(aamLocal.caps.create_roles)) {
|
97 |
-
var create = $('<a/>', {
|
98 |
-
'href': '#',
|
99 |
-
'class': 'btn btn-primary'
|
100 |
-
}).html('<i class="icon-plus"></i> ' + aam.__('Create'))
|
101 |
-
.bind('click', function () {
|
102 |
-
$('#add-role-modal').modal('show');
|
103 |
-
});
|
104 |
-
|
105 |
-
$('.dataTables_filter', '#role-list_wrapper').append(create);
|
106 |
-
}
|
107 |
-
},
|
108 |
-
createdRow: function (row, data) {
|
109 |
-
if (isCurrent(data[0])) {
|
110 |
-
$('td:eq(0)', row).html('<strong class="aam-highlight">' + data[2] + '</strong>');
|
111 |
-
} else {
|
112 |
-
$('td:eq(0)', row).html('<span>' + data[2] + '</span>');
|
113 |
-
}
|
114 |
-
|
115 |
-
$(row).attr('data-id', data[0]);
|
116 |
-
|
117 |
-
//add subtitle
|
118 |
-
var expire = (data[5] ? '; <i class="icon-clock"></i>' : '');
|
119 |
-
$('td:eq(0)', row).append(
|
120 |
-
$('<i/>', {'class': 'aam-row-subtitle'}).html(
|
121 |
-
aam.__('Users') + ': <b>' + parseInt(data[1]) + '</b>; ID: <b>' + data[0] + '</b>' + expire
|
122 |
-
)
|
123 |
-
);
|
124 |
-
|
125 |
-
var actions = data[3].split(',');
|
126 |
-
|
127 |
-
var container = $('<div/>', {'class': 'aam-row-actions'});
|
128 |
-
$.each(actions, function (i, action) {
|
129 |
-
switch (action) {
|
130 |
-
case 'manage':
|
131 |
-
$(container).append($('<i/>', {
|
132 |
-
'class': 'aam-row-action icon-cog ' + (isCurrent(data[0]) ? 'text-muted': 'text-info')
|
133 |
-
}).bind('click', function () {
|
134 |
-
if (!$(this).prop('disabled')) {
|
135 |
-
$(this).prop('disabled', true);
|
136 |
-
var title = $('td:eq(0) span', row).html();
|
137 |
-
aam.setSubject('role', data[0], title, data[4]);
|
138 |
-
$('td:eq(0) span', row).replaceWith(
|
139 |
-
'<strong class="aam-highlight">' + title + '</strong>'
|
140 |
-
);
|
141 |
-
$('i.icon-cog', container).attr(
|
142 |
-
'class', 'aam-row-action icon-cog text-muted'
|
143 |
-
);
|
144 |
-
if (!aam.isUI()) {
|
145 |
-
$('i.icon-cog', container).attr(
|
146 |
-
'class', 'aam-row-action icon-spin4 animate-spin'
|
147 |
-
);
|
148 |
-
aam.fetchContent();
|
149 |
-
$('i.icon-spin4', container).attr(
|
150 |
-
'class', 'aam-row-action icon-cog text-muted'
|
151 |
-
);
|
152 |
-
} else {
|
153 |
-
$.aam.loadAccessForm($('#load-post-object-type').val(), $('#load-post-object').val(), $(this));
|
154 |
-
}
|
155 |
-
}
|
156 |
-
}).attr({
|
157 |
-
'data-toggle': "tooltip",
|
158 |
-
'title': aam.__('Manage Role')
|
159 |
-
}).prop('disabled', (isCurrent(data[0]) ? true: false)));
|
160 |
-
break;
|
161 |
-
|
162 |
-
case 'edit':
|
163 |
-
if (!aam.isUI()) {
|
164 |
-
$(container).append($('<i/>', {
|
165 |
-
'class': 'aam-row-action icon-pencil text-warning'
|
166 |
-
}).bind('click', function () {
|
167 |
-
$('#edit-role-btn').data('role', data[0]);
|
168 |
-
$('#edit-role-name').val(data[2]);
|
169 |
-
$('#edit-role-expiration').val(data[5]);
|
170 |
-
$('#edit-role-modal').modal('show');
|
171 |
-
fetchRoleList(data[0]);
|
172 |
-
//TODO - Rerwite JavaScript to support $.aam
|
173 |
-
$.aamEditRole = data;
|
174 |
-
}).attr({
|
175 |
-
'data-toggle': "tooltip",
|
176 |
-
'title': aam.__('Edit Role')
|
177 |
-
}));
|
178 |
-
}
|
179 |
-
break;
|
180 |
-
|
181 |
-
case 'clone':
|
182 |
-
if (!aam.isUI()) {
|
183 |
-
$(container).append($('<i/>', {
|
184 |
-
'class': 'aam-row-action icon-clone text-success'
|
185 |
-
}).bind('click', function () {
|
186 |
-
//TODO - Rerwite JavaScript to support $.aam
|
187 |
-
$.aamEditRole = data;
|
188 |
-
$('#clone-role').prop('checked', true);
|
189 |
-
$('#add-role-modal').modal('show');
|
190 |
-
}).attr({
|
191 |
-
'data-toggle': "tooltip",
|
192 |
-
'title': aam.__('Clone Role')
|
193 |
-
}));
|
194 |
-
}
|
195 |
-
break;
|
196 |
-
|
197 |
-
case 'delete':
|
198 |
-
if (!aam.isUI()) {
|
199 |
-
$(container).append($('<i/>', {
|
200 |
-
'class': 'aam-row-action icon-trash-empty text-danger'
|
201 |
-
}).bind('click', {role: data}, function (event) {
|
202 |
-
$('#delete-role-btn').data('role', data[0]);
|
203 |
-
var message = $('#delete-role-modal .aam-confirm-message').data('message');
|
204 |
-
$('#delete-role-modal .aam-confirm-message').html(
|
205 |
-
message.replace(
|
206 |
-
'%s', '<strong>' + event.data.role[2] + '</strong>'
|
207 |
-
)
|
208 |
-
);
|
209 |
-
|
210 |
-
$('#delete-role-modal').modal('show');
|
211 |
-
}).attr({
|
212 |
-
'data-toggle': "tooltip",
|
213 |
-
'title': aam.__('Delete Role')
|
214 |
-
}));
|
215 |
-
}
|
216 |
-
break;
|
217 |
-
|
218 |
-
default:
|
219 |
-
if (!aam.isUI()) {
|
220 |
-
aam.triggerHook('role-action', {
|
221 |
-
container: container,
|
222 |
-
action : action,
|
223 |
-
data : data
|
224 |
-
});
|
225 |
-
}
|
226 |
-
break;
|
227 |
-
}
|
228 |
-
});
|
229 |
-
$('td:eq(1)', row).html(container);
|
230 |
-
|
231 |
-
aam.triggerHook('decorate-role-row', {
|
232 |
-
row : row,
|
233 |
-
data: data
|
234 |
-
});
|
235 |
-
}
|
236 |
-
});
|
237 |
-
|
238 |
-
$('#role-list').on( 'draw.dt', function () {
|
239 |
-
$('tr', '#role-list tbody').each(function() {
|
240 |
-
if (!isCurrent($(this).data('id'))) {
|
241 |
-
$('td:eq(0) strong', this).replaceWith(
|
242 |
-
'<span>' + $('td:eq(0) strong', this).text() + '</span>'
|
243 |
-
);
|
244 |
-
$('.text-muted', this).attr('disabled', false);
|
245 |
-
$('.text-muted', this).toggleClass('text-muted text-info');
|
246 |
-
}
|
247 |
-
});
|
248 |
-
} );
|
249 |
-
|
250 |
-
$('#add-role-modal').on('shown.bs.modal', function (e) {
|
251 |
-
fetchRoleList();
|
252 |
-
//clear add role form first
|
253 |
-
$('input[name="name"]', '#add-role-modal').val('').focus();
|
254 |
-
});
|
255 |
-
|
256 |
-
$('#edit-role-modal').on('shown.bs.modal', function (e) {
|
257 |
-
$('input[name="name"]', '#edit-role-modal').focus();
|
258 |
-
});
|
259 |
-
|
260 |
-
//add role button
|
261 |
-
$('#add-role-btn').bind('click', function () {
|
262 |
-
var _this = this;
|
263 |
-
|
264 |
-
$('input[name="name"]', '#add-role-modal').parent().removeClass('has-error');
|
265 |
-
|
266 |
-
var data = {
|
267 |
-
action: 'aam',
|
268 |
-
sub_action: 'Role.add',
|
269 |
-
_ajax_nonce: aamLocal.nonce
|
270 |
-
};
|
271 |
-
|
272 |
-
$('input,select', '#add-role-modal .modal-body').each(function() {
|
273 |
-
if ($(this).attr('type') === 'checkbox') {
|
274 |
-
data[$(this).attr('name')] = $(this).prop('checked') ? 1 : 0;
|
275 |
-
} else {
|
276 |
-
data[$(this).attr('name')] = $.trim($(this).val());
|
277 |
-
}
|
278 |
-
});
|
279 |
-
|
280 |
-
if (data.name) {
|
281 |
-
$.ajax(aamLocal.ajaxurl, {
|
282 |
-
type: 'POST',
|
283 |
-
dataType: 'json',
|
284 |
-
data: data,
|
285 |
-
beforeSend: function () {
|
286 |
-
$(_this).text(aam.__('Saving...')).attr('disabled', true);
|
287 |
-
},
|
288 |
-
success: function (response) {
|
289 |
-
if (response.status === 'success') {
|
290 |
-
$('#role-list').DataTable().ajax.reload();
|
291 |
-
aam.setSubject(
|
292 |
-
'role',
|
293 |
-
response.role.id,
|
294 |
-
response.role.name,
|
295 |
-
response.role.level
|
296 |
-
);
|
297 |
-
aam.fetchContent();
|
298 |
-
$('#add-role-modal').modal('hide');
|
299 |
-
} else {
|
300 |
-
aam.notification(
|
301 |
-
'danger', aam.__('Failed to add new role')
|
302 |
-
);
|
303 |
-
}
|
304 |
-
},
|
305 |
-
error: function () {
|
306 |
-
aam.notification('danger', aam.__('Application error'));
|
307 |
-
},
|
308 |
-
complete: function () {
|
309 |
-
$(_this).text(aam.__('Add Role')).attr('disabled', false);
|
310 |
-
}
|
311 |
-
});
|
312 |
-
} else {
|
313 |
-
$('input,select', '#add-role-modal .modal-body').focus().parent().addClass('has-error');
|
314 |
-
}
|
315 |
-
});
|
316 |
-
|
317 |
-
//edit role button
|
318 |
-
$('#edit-role-btn').bind('click', function (event) {
|
319 |
-
var _this = this;
|
320 |
-
|
321 |
-
$('#edit-role-name').parent().removeClass('has-error');
|
322 |
-
|
323 |
-
var data = {
|
324 |
-
action: 'aam',
|
325 |
-
sub_action: 'Role.edit',
|
326 |
-
_ajax_nonce: aamLocal.nonce,
|
327 |
-
subject: 'role',
|
328 |
-
subjectId: $(_this).data('role')
|
329 |
-
};
|
330 |
-
|
331 |
-
$('input,select', '#edit-role-modal .modal-body').each(function() {
|
332 |
-
data[$(this).attr('name')] = $.trim($(this).val());
|
333 |
-
});
|
334 |
-
|
335 |
-
if (data.name) {
|
336 |
-
$.ajax(aamLocal.ajaxurl, {
|
337 |
-
type: 'POST',
|
338 |
-
dataType: 'json',
|
339 |
-
data: data,
|
340 |
-
beforeSend: function () {
|
341 |
-
$(_this).text(aam.__('Saving...')).attr('disabled', true);
|
342 |
-
},
|
343 |
-
success: function (response) {
|
344 |
-
if (response.status === 'success') {
|
345 |
-
$('#role-list').DataTable().ajax.reload();
|
346 |
-
} else {
|
347 |
-
aam.notification(
|
348 |
-
'danger', aam.__('Failed to update role')
|
349 |
-
);
|
350 |
-
}
|
351 |
-
},
|
352 |
-
error: function () {
|
353 |
-
aam.notification('danger', aam.__('Application error'));
|
354 |
-
},
|
355 |
-
complete: function () {
|
356 |
-
$('#edit-role-modal').modal('hide');
|
357 |
-
$(_this).text(aam.__('Update')).attr('disabled', false);
|
358 |
-
}
|
359 |
-
});
|
360 |
-
} else {
|
361 |
-
$('#edit-role-name').focus().parent().addClass('has-error');
|
362 |
-
}
|
363 |
-
});
|
364 |
-
|
365 |
-
//edit role button
|
366 |
-
$('#delete-role-btn').bind('click', function (event) {
|
367 |
-
var _this = this;
|
368 |
-
|
369 |
-
$.ajax(aamLocal.ajaxurl, {
|
370 |
-
type: 'POST',
|
371 |
-
dataType: 'json',
|
372 |
-
data: {
|
373 |
-
action: 'aam',
|
374 |
-
sub_action: 'Role.delete',
|
375 |
-
_ajax_nonce: aamLocal.nonce,
|
376 |
-
subject: 'role',
|
377 |
-
subjectId: $(_this).data('role')
|
378 |
-
},
|
379 |
-
beforeSend: function () {
|
380 |
-
$(_this).text(aam.__('Deleting...')).attr('disabled', true);
|
381 |
-
},
|
382 |
-
success: function (response) {
|
383 |
-
if (response.status === 'success') {
|
384 |
-
$('#role-list').DataTable().ajax.reload();
|
385 |
-
} else {
|
386 |
-
aam.notification('danger', aam.__('Failed to delete role'));
|
387 |
-
}
|
388 |
-
},
|
389 |
-
error: function () {
|
390 |
-
aam.notification('danger', aam.__('Application error'));
|
391 |
-
},
|
392 |
-
complete: function () {
|
393 |
-
$('#delete-role-modal').modal('hide');
|
394 |
-
$(_this).text(aam.__('Delete Role')).attr('disabled', false);
|
395 |
-
}
|
396 |
-
});
|
397 |
-
});
|
398 |
-
|
399 |
-
//add setSubject hook
|
400 |
-
aam.addHook('setSubject', function () {
|
401 |
-
//clear highlight
|
402 |
-
$('tbody tr', '#role-list').each(function () {
|
403 |
-
if ($('strong', $(this)).length) {
|
404 |
-
var highlight = $('strong', $(this));
|
405 |
-
$('.icon-cog', $(this)).toggleClass('text-muted text-info');
|
406 |
-
$('.icon-cog', $(this)).prop('disabled', false);
|
407 |
-
highlight.replaceWith($('<span/>').text(highlight.text()));
|
408 |
-
}
|
409 |
-
});
|
410 |
-
//show post & pages access control groups that belong to backend
|
411 |
-
$('.aam-backend-post-access').show();
|
412 |
-
});
|
413 |
-
|
414 |
-
//in case interface needed to be reloaded
|
415 |
-
aam.addHook('refresh', function () {
|
416 |
-
$('#role-list').DataTable().ajax.url(aamLocal.ajaxurl).load();
|
417 |
-
});
|
418 |
-
|
419 |
-
})(jQuery);
|
420 |
-
|
421 |
-
|
422 |
-
/**
|
423 |
-
* User List Interface
|
424 |
-
*
|
425 |
-
* @param {jQuery} $
|
426 |
-
*
|
427 |
-
* @returns {void}
|
428 |
-
*/
|
429 |
-
(function ($) {
|
430 |
-
|
431 |
-
/**
|
432 |
-
*
|
433 |
-
* @param {type} id
|
434 |
-
* @returns {Boolean}
|
435 |
-
*/
|
436 |
-
function isCurrent(id) {
|
437 |
-
var subject = aam.getSubject();
|
438 |
-
|
439 |
-
return (subject.type === 'user' && parseInt(subject.id) === id);
|
440 |
-
}
|
441 |
-
|
442 |
-
/**
|
443 |
-
*
|
444 |
-
* @param {type} id
|
445 |
-
* @param {type} btn
|
446 |
-
* @returns {undefined}
|
447 |
-
*/
|
448 |
-
function blockUser(id, btn) {
|
449 |
-
var state = ($(btn).hasClass('icon-lock') ? 0 : 1);
|
450 |
-
|
451 |
-
$.ajax(aamLocal.ajaxurl, {
|
452 |
-
type: 'POST',
|
453 |
-
dataType: 'json',
|
454 |
-
data: {
|
455 |
-
action: 'aam',
|
456 |
-
sub_action: 'User.block',
|
457 |
-
_ajax_nonce: aamLocal.nonce,
|
458 |
-
subject: 'user',
|
459 |
-
subjectId: id
|
460 |
-
},
|
461 |
-
beforeSend: function () {
|
462 |
-
$(btn).attr('class', 'aam-row-action icon-spin4 animate-spin');
|
463 |
-
},
|
464 |
-
success: function (response) {
|
465 |
-
if (response.status === 'success') {
|
466 |
-
if (state === 1) {
|
467 |
-
$(btn).attr({
|
468 |
-
'class': 'aam-row-action icon-lock text-danger',
|
469 |
-
'title': aam.__('Unlock User'),
|
470 |
-
'data-original-title': aam.__('Unlock User')
|
471 |
-
});
|
472 |
-
} else {
|
473 |
-
$(btn).attr({
|
474 |
-
'class': 'aam-row-action icon-lock-open-alt text-warning',
|
475 |
-
'title': aam.__('Lock User'),
|
476 |
-
'data-original-title': aam.__('Lock User')
|
477 |
-
});
|
478 |
-
}
|
479 |
-
} else {
|
480 |
-
aam.notification('danger', aam.__('Failed to block user'));
|
481 |
-
}
|
482 |
-
},
|
483 |
-
error: function () {
|
484 |
-
aam.notification('danger', aam.__('Application error'));
|
485 |
-
}
|
486 |
-
});
|
487 |
-
}
|
488 |
-
|
489 |
-
/**
|
490 |
-
*
|
491 |
-
* @param {type} id
|
492 |
-
* @param {type} btn
|
493 |
-
* @returns {undefined}
|
494 |
-
*/
|
495 |
-
function switchToUser(id, btn) {
|
496 |
-
$.ajax(aamLocal.ajaxurl, {
|
497 |
-
type: 'POST',
|
498 |
-
dataType: 'json',
|
499 |
-
data: {
|
500 |
-
action: 'aam',
|
501 |
-
sub_action: 'switchToUser',
|
502 |
-
_ajax_nonce: aamLocal.nonce,
|
503 |
-
user: id
|
504 |
-
},
|
505 |
-
beforeSend: function () {
|
506 |
-
$(btn).attr('class', 'aam-row-action icon-spin4 animate-spin');
|
507 |
-
},
|
508 |
-
success: function (response) {
|
509 |
-
if (response.status === 'success') {
|
510 |
-
location.href = response.redirect;
|
511 |
-
} else {
|
512 |
-
aam.notification('danger', response.reason);
|
513 |
-
}
|
514 |
-
},
|
515 |
-
error: function () {
|
516 |
-
aam.notification('danger', aam.__('Application error'));
|
517 |
-
},
|
518 |
-
complete: function () {
|
519 |
-
$(btn).attr('class', 'aam-row-action icon-exchange text-success');
|
520 |
-
}
|
521 |
-
});
|
522 |
-
}
|
523 |
-
|
524 |
-
//initialize the user list table
|
525 |
-
$('#user-list').DataTable({
|
526 |
-
autoWidth: false,
|
527 |
-
ordering: false,
|
528 |
-
dom: 'ftrip',
|
529 |
-
pagingType: 'simple',
|
530 |
-
serverSide: true,
|
531 |
-
processing: true,
|
532 |
-
ajax: {
|
533 |
-
url: aamLocal.ajaxurl,
|
534 |
-
type: 'POST',
|
535 |
-
dataType: 'json',
|
536 |
-
data: {
|
537 |
-
action: 'aam',
|
538 |
-
sub_action: 'User.getTable',
|
539 |
-
_ajax_nonce: aamLocal.nonce
|
540 |
-
}
|
541 |
-
},
|
542 |
-
columnDefs: [
|
543 |
-
{visible: false, targets: [0, 1, 4]}
|
544 |
-
],
|
545 |
-
language: {
|
546 |
-
search: '_INPUT_',
|
547 |
-
searchPlaceholder: aam.__('Search User'),
|
548 |
-
info: aam.__('_TOTAL_ user(s)'),
|
549 |
-
infoFiltered: ''
|
550 |
-
},
|
551 |
-
initComplete: function () {
|
552 |
-
if (!aam.isUI() && parseInt(aamLocal.caps.create_users)) {
|
553 |
-
var create = $('<a/>', {
|
554 |
-
'href': '#',
|
555 |
-
'class': 'btn btn-primary'
|
556 |
-
}).html('<i class="icon-plus"></i> ' + aam.__('Create')).bind('click', function () {
|
557 |
-
window.open(aamLocal.url.addUser, '_blank');
|
558 |
-
});
|
559 |
-
|
560 |
-
$('.dataTables_filter', '#user-list_wrapper').append(create);
|
561 |
-
}
|
562 |
-
},
|
563 |
-
createdRow: function (row, data) {
|
564 |
-
if (isCurrent(data[0])) {
|
565 |
-
$('td:eq(0)', row).html('<strong class="aam-highlight">' + data[2] + '</strong>');
|
566 |
-
} else {
|
567 |
-
$('td:eq(0)', row).html('<span>' + data[2] + '</span>');
|
568 |
-
}
|
569 |
-
|
570 |
-
//add subtitle
|
571 |
-
$('td:eq(0)', row).append(
|
572 |
-
$('<i/>', {'class': 'aam-row-subtitle'}).html(
|
573 |
-
aam.__('Role') + ': ' + data[1] + '; ID: <b>' + data[0] + '</b>'
|
574 |
-
)
|
575 |
-
);
|
576 |
-
|
577 |
-
var actions = data[3].split(',');
|
578 |
-
var container = $('<div/>', {'class': 'aam-row-actions'});
|
579 |
-
|
580 |
-
if ($.trim(data[3])) {
|
581 |
-
$.each(actions, function (i, action) {
|
582 |
-
switch (action) {
|
583 |
-
case 'manage':
|
584 |
-
$(container).append($('<i/>', {
|
585 |
-
'class': 'aam-row-action icon-cog ' + (isCurrent(data[0]) ? 'text-muted': 'text-info')
|
586 |
-
}).bind('click', function () {
|
587 |
-
if (!$(this).prop('disabled')) {
|
588 |
-
$(this).prop('disabled', true);
|
589 |
-
aam.setSubject('user', data[0], data[2], data[4]);
|
590 |
-
$('td:eq(0) span', row).replaceWith(
|
591 |
-
'<strong class="aam-highlight">' + data[2] + '</strong>'
|
592 |
-
);
|
593 |
-
$('i.icon-cog', container).attr('class', 'aam-row-action icon-cog text-muted');
|
594 |
-
|
595 |
-
if (!aam.isUI()) {
|
596 |
-
$('i.icon-cog', container).attr('class', 'aam-row-action icon-spin4 animate-spin');
|
597 |
-
aam.fetchContent();
|
598 |
-
$('i.icon-spin4', container).attr('class', 'aam-row-action icon-cog text-muted');
|
599 |
-
} else {
|
600 |
-
$.aam.loadAccessForm($('#load-post-object-type').val(), $('#load-post-object').val(), $(this));
|
601 |
-
}
|
602 |
-
}
|
603 |
-
}).attr({
|
604 |
-
'data-toggle': "tooltip",
|
605 |
-
'title': aam.__('Manage User')
|
606 |
-
})).prop('disabled', (isCurrent(data[0]) ? true: false));
|
607 |
-
break;
|
608 |
-
|
609 |
-
case 'edit':
|
610 |
-
if (!aam.isUI()) {
|
611 |
-
$(container).append($('<i/>', {
|
612 |
-
'class': 'aam-row-action icon-pencil text-info'
|
613 |
-
}).bind('click', function () {
|
614 |
-
window.open(
|
615 |
-
aamLocal.url.editUser + '?user_id=' + data[0], '_blank'
|
616 |
-
);
|
617 |
-
}).attr({
|
618 |
-
'data-toggle': "tooltip",
|
619 |
-
'title': aam.__('Edit User')
|
620 |
-
}));
|
621 |
-
}
|
622 |
-
break;
|
623 |
-
|
624 |
-
case 'lock':
|
625 |
-
if (!aam.isUI()) {
|
626 |
-
$(container).append($('<i/>', {
|
627 |
-
'class': 'aam-row-action icon-lock-open-alt text-warning'
|
628 |
-
}).bind('click', function () {
|
629 |
-
blockUser(data[0], $(this));
|
630 |
-
}).attr({
|
631 |
-
'data-toggle': "tooltip",
|
632 |
-
'title': aam.__('Lock User')
|
633 |
-
}));
|
634 |
-
}
|
635 |
-
break;
|
636 |
-
|
637 |
-
case 'unlock':
|
638 |
-
if (!aam.isUI()) {
|
639 |
-
$(container).append($('<i/>', {
|
640 |
-
'class': 'aam-row-action icon-lock text-danger'
|
641 |
-
}).bind('click', function () {
|
642 |
-
blockUser(data[0], $(this));
|
643 |
-
}).attr({
|
644 |
-
'data-toggle': "tooltip",
|
645 |
-
'title': aam.__('Unlock User')
|
646 |
-
}));
|
647 |
-
}
|
648 |
-
break;
|
649 |
-
|
650 |
-
case 'switch':
|
651 |
-
if (!aam.isUI()) {
|
652 |
-
$(container).append($('<i/>', {
|
653 |
-
'class': 'aam-row-action icon-exchange text-success'
|
654 |
-
}).bind('click', function () {
|
655 |
-
switchToUser(data[0], $(this));
|
656 |
-
}).attr({
|
657 |
-
'data-toggle': "tooltip",
|
658 |
-
'title': aam.__('Switch To User')
|
659 |
-
}));
|
660 |
-
}
|
661 |
-
break;
|
662 |
-
|
663 |
-
default:
|
664 |
-
break;
|
665 |
-
}
|
666 |
-
});
|
667 |
-
} else {
|
668 |
-
$(container).append($('<i/>', {
|
669 |
-
'class': 'aam-row-action text-muted'
|
670 |
-
}).text('---'));
|
671 |
-
}
|
672 |
-
$('td:eq(1)', row).html(container);
|
673 |
-
}
|
674 |
-
});
|
675 |
-
|
676 |
-
//add setSubject hook
|
677 |
-
aam.addHook('setSubject', function () {
|
678 |
-
//clear highlight
|
679 |
-
$('tbody tr', '#user-list').each(function () {
|
680 |
-
if ($('strong', $(this)).length) {
|
681 |
-
var highlight = $('strong', $(this));
|
682 |
-
$('.icon-cog', $(this)).toggleClass('text-muted text-info');
|
683 |
-
$('.icon-cog', $(this)).prop('disabled', false);
|
684 |
-
highlight.replaceWith('<span>' + highlight.text() + '</span>');
|
685 |
-
}
|
686 |
-
});
|
687 |
-
//show post & pages access control groups that belong to backend
|
688 |
-
$('.aam-backend-post-access').show();
|
689 |
-
});
|
690 |
-
|
691 |
-
//in case interface needed to be reloaded
|
692 |
-
aam.addHook('refresh', function () {
|
693 |
-
$('#user-list').DataTable().ajax.url(aamLocal.ajaxurl).load();
|
694 |
-
});
|
695 |
-
|
696 |
-
})(jQuery);
|
697 |
-
|
698 |
-
|
699 |
-
/**
|
700 |
-
* Visitor Interface
|
701 |
-
*
|
702 |
-
* @param {jQuery} $
|
703 |
-
*
|
704 |
-
* @returns {void}
|
705 |
-
*/
|
706 |
-
(function ($) {
|
707 |
-
|
708 |
-
$('document').ready(function() {
|
709 |
-
$('#manage-visitor').bind('click', function () {
|
710 |
-
var _this = this;
|
711 |
-
|
712 |
-
aam.setSubject('visitor', null, aam.__('Anonymous'), 0);
|
713 |
-
$('i.icon-cog', $(this)).attr('class', 'icon-spin4 animate-spin');
|
714 |
-
|
715 |
-
if (!aam.isUI()) {
|
716 |
-
aam.fetchContent();
|
717 |
-
$('i.icon-spin4', $(this)).attr('class', 'icon-cog');
|
718 |
-
} else {
|
719 |
-
$.aam.loadAccessForm($('#load-post-object-type').val(), $('#load-post-object').val(), null, function () {
|
720 |
-
$('i.icon-spin4', $(_this)).attr('class', 'icon-cog');
|
721 |
-
});
|
722 |
-
}
|
723 |
-
//hide post & pages access control groups that belong to backend
|
724 |
-
$('.aam-backend-post-access').hide();
|
725 |
-
});
|
726 |
-
});
|
727 |
-
|
728 |
-
})(jQuery);
|
729 |
-
|
730 |
-
/**
|
731 |
-
* Default Interface
|
732 |
-
*
|
733 |
-
* @param {jQuery} $
|
734 |
-
*
|
735 |
-
* @returns {void}
|
736 |
-
*/
|
737 |
-
(function ($) {
|
738 |
-
|
739 |
-
$('document').ready(function() {
|
740 |
-
$('#manage-default').bind('click', function () {
|
741 |
-
var _this = this;
|
742 |
-
|
743 |
-
aam.setSubject('default', null, aam.__('All Users, Roles and Visitor'), 0);
|
744 |
-
$('i.icon-cog', $(this)).attr('class', 'icon-spin4 animate-spin');
|
745 |
-
if (!aam.isUI()) {
|
746 |
-
aam.fetchContent();
|
747 |
-
$('i.icon-spin4', $(this)).attr('class', 'icon-cog');
|
748 |
-
} else {
|
749 |
-
$.aam.loadAccessForm($('#load-post-object-type').val(), $('#load-post-object').val(), null, function () {
|
750 |
-
$('i.icon-spin4', $(_this)).attr('class', 'icon-cog');
|
751 |
-
});
|
752 |
-
}
|
753 |
-
});
|
754 |
-
});
|
755 |
-
|
756 |
-
})(jQuery);
|
757 |
-
|
758 |
-
|
759 |
-
/**
|
760 |
-
* Admin Menu Interface
|
761 |
-
*
|
762 |
-
* @param {jQuery} $
|
763 |
-
*
|
764 |
-
* @returns {void}
|
765 |
-
*/
|
766 |
-
(function ($) {
|
767 |
-
|
768 |
-
/**
|
769 |
-
*
|
770 |
-
* @param {type} param
|
771 |
-
* @param {type} value
|
772 |
-
* @returns {undefined}
|
773 |
-
*/
|
774 |
-
function save(items, status, successCallback) {
|
775 |
-
$.ajax(aamLocal.ajaxurl, {
|
776 |
-
type: 'POST',
|
777 |
-
dataType: 'json',
|
778 |
-
data: {
|
779 |
-
action: 'aam',
|
780 |
-
sub_action: 'Menu.save',
|
781 |
-
subject: aam.getSubject().type,
|
782 |
-
subjectId: aam.getSubject().id,
|
783 |
-
_ajax_nonce: aamLocal.nonce,
|
784 |
-
items: items,
|
785 |
-
status: status
|
786 |
-
},
|
787 |
-
success: function(response) {
|
788 |
-
successCallback(response);
|
789 |
-
},
|
790 |
-
error: function () {
|
791 |
-
aam.notification('danger', aam.__('Application Error'));
|
792 |
-
}
|
793 |
-
});
|
794 |
-
}
|
795 |
-
|
796 |
-
/**
|
797 |
-
*
|
798 |
-
* @returns {undefined}
|
799 |
-
*/
|
800 |
-
function initialize() {
|
801 |
-
if ($('#admin_menu-content').length) {
|
802 |
-
$('.aam-restrict-menu').each(function () {
|
803 |
-
$(this).bind('click', function () {
|
804 |
-
var _this = $(this);
|
805 |
-
var status = ($('i', $(this)).hasClass('icon-eye-off') ? 1 : 0);
|
806 |
-
var target = _this.data('target');
|
807 |
-
|
808 |
-
$('i', _this).attr('class', 'icon-spin4 animate-spin');
|
809 |
-
|
810 |
-
var items = new Array(_this.data('menu-id'));
|
811 |
-
|
812 |
-
$('input', target).each(function () {
|
813 |
-
$(this).attr('checked', status ? true : false);
|
814 |
-
items.push($(this).data('menu-id'));
|
815 |
-
});
|
816 |
-
|
817 |
-
save(items, status, function(result) {
|
818 |
-
if (result.status === 'success') {
|
819 |
-
$('#aam-menu-overwrite').show();
|
820 |
-
|
821 |
-
if (status) { //locked the menu
|
822 |
-
$('.aam-bordered', target).append(
|
823 |
-
$('<div/>', {'class': 'aam-lock'})
|
824 |
-
);
|
825 |
-
_this.removeClass('btn-danger').addClass('btn-primary');
|
826 |
-
_this.html('<i class="icon-eye"></i>' + aam.__('Show Menu'));
|
827 |
-
//add menu restricted indicator
|
828 |
-
var ind = $('<i/>', {
|
829 |
-
'class': 'aam-panel-title-icon icon-eye-off text-danger'
|
830 |
-
});
|
831 |
-
$('.panel-title', target + '-heading').append(ind);
|
832 |
-
} else {
|
833 |
-
$('.aam-lock', target).remove();
|
834 |
-
_this.removeClass('btn-primary').addClass('btn-danger');
|
835 |
-
_this.html(
|
836 |
-
'<i class="icon-eye-off"></i>' + aam.__('Restrict Menu')
|
837 |
-
);
|
838 |
-
$('.panel-title .icon-eye-off', target + '-heading').remove();
|
839 |
-
}
|
840 |
-
} else {
|
841 |
-
_this.attr('checked', !status);
|
842 |
-
}
|
843 |
-
});
|
844 |
-
});
|
845 |
-
});
|
846 |
-
|
847 |
-
$('input[type="checkbox"]', '#admin-menu').each(function () {
|
848 |
-
$(this).bind('click', function () {
|
849 |
-
aam.save(
|
850 |
-
$(this).data('menu-id'),
|
851 |
-
$(this).attr('checked') ? 1 : 0,
|
852 |
-
'menu',
|
853 |
-
null,
|
854 |
-
function(result) {
|
855 |
-
if (result.status === 'success') {
|
856 |
-
$('#aam-menu-overwrite').show();
|
857 |
-
}
|
858 |
-
}
|
859 |
-
);
|
860 |
-
});
|
861 |
-
});
|
862 |
-
|
863 |
-
//reset button
|
864 |
-
$('#menu-reset').bind('click', function () {
|
865 |
-
aam.reset('menu');
|
866 |
-
});
|
867 |
-
}
|
868 |
-
}
|
869 |
-
|
870 |
-
aam.addHook('init', initialize);
|
871 |
-
|
872 |
-
})(jQuery);
|
873 |
-
|
874 |
-
|
875 |
-
/**
|
876 |
-
* Metaboxes & Widgets Interface
|
877 |
-
*
|
878 |
-
* @param {jQuery} $
|
879 |
-
*
|
880 |
-
* @returns {void}
|
881 |
-
*/
|
882 |
-
(function ($) {
|
883 |
-
|
884 |
-
/**
|
885 |
-
*
|
886 |
-
* @returns {undefined}
|
887 |
-
*/
|
888 |
-
function getContent() {
|
889 |
-
$.ajax(aamLocal.ajaxurl, {
|
890 |
-
type: 'POST',
|
891 |
-
dataType: 'html',
|
892 |
-
data: {
|
893 |
-
action: 'aam',
|
894 |
-
sub_action: 'Metabox.getContent',
|
895 |
-
_ajax_nonce: aamLocal.nonce,
|
896 |
-
subject: aam.getSubject().type,
|
897 |
-
subjectId: aam.getSubject().id
|
898 |
-
},
|
899 |
-
success: function (response) {
|
900 |
-
$('#metabox-content').replaceWith(response);
|
901 |
-
$('#metabox-content').addClass('active');
|
902 |
-
initialize();
|
903 |
-
},
|
904 |
-
error: function () {
|
905 |
-
aam.notification('danger', aam.__('Application error'));
|
906 |
-
}
|
907 |
-
});
|
908 |
-
}
|
909 |
-
|
910 |
-
/**
|
911 |
-
*
|
912 |
-
* @returns {undefined}
|
913 |
-
*/
|
914 |
-
function initialize() {
|
915 |
-
if ($('#metabox-content').length) {
|
916 |
-
//init refresh list button
|
917 |
-
$('#refresh-metabox-list').bind('click', function () {
|
918 |
-
$.ajax(aamLocal.ajaxurl, {
|
919 |
-
type: 'POST',
|
920 |
-
dataType: 'json',
|
921 |
-
data: {
|
922 |
-
action: 'aam',
|
923 |
-
sub_action: 'Metabox.refreshList',
|
924 |
-
_ajax_nonce: aamLocal.nonce
|
925 |
-
},
|
926 |
-
beforeSend: function () {
|
927 |
-
$('i', '#refresh-metabox-list').attr(
|
928 |
-
'class', 'icon-spin4 animate-spin'
|
929 |
-
);
|
930 |
-
},
|
931 |
-
success: function (response) {
|
932 |
-
if (response.status === 'success') {
|
933 |
-
getContent();
|
934 |
-
} else {
|
935 |
-
aam.notification(
|
936 |
-
'danger', aam.__('Failed to retrieve mataboxes')
|
937 |
-
);
|
938 |
-
}
|
939 |
-
},
|
940 |
-
error: function () {
|
941 |
-
aam.notification('danger', aam.__('Application error'));
|
942 |
-
},
|
943 |
-
complete: function () {
|
944 |
-
$('i', '#refresh-metabox-list').attr(
|
945 |
-
'class', 'icon-arrows-cw'
|
946 |
-
);
|
947 |
-
}
|
948 |
-
});
|
949 |
-
});
|
950 |
-
|
951 |
-
$('#init-url-btn').bind('click', function () {
|
952 |
-
$.ajax(aamLocal.ajaxurl, {
|
953 |
-
type: 'POST',
|
954 |
-
dataType: 'json',
|
955 |
-
data: {
|
956 |
-
action: 'aam',
|
957 |
-
sub_action: 'Metabox.initURL',
|
958 |
-
_ajax_nonce: aamLocal.nonce,
|
959 |
-
url: $('#init-url').val()
|
960 |
-
},
|
961 |
-
beforeSend: function () {
|
962 |
-
$('#init-url-btn').text(aam.__('Processing'));
|
963 |
-
},
|
964 |
-
success: function (response) {
|
965 |
-
if (response.status === 'success') {
|
966 |
-
$('#init-url-modal').modal('hide');
|
967 |
-
getContent();
|
968 |
-
} else {
|
969 |
-
aam.notification(
|
970 |
-
'danger', aam.__('Failed to initialize URL')
|
971 |
-
);
|
972 |
-
}
|
973 |
-
},
|
974 |
-
error: function () {
|
975 |
-
aam.notification('danger', aam.__('Application error'));
|
976 |
-
},
|
977 |
-
complete: function () {
|
978 |
-
$('#init-url-btn').text(aam.__('Initialize'));
|
979 |
-
$('#init-url-modal').modal('hide');
|
980 |
-
}
|
981 |
-
});
|
982 |
-
});
|
983 |
-
|
984 |
-
//reset button
|
985 |
-
$('#metabox-reset').bind('click', function () {
|
986 |
-
aam.reset('metabox');
|
987 |
-
});
|
988 |
-
|
989 |
-
$('input[type="checkbox"]', '#metabox-list').each(function () {
|
990 |
-
$(this).bind('click', function () {
|
991 |
-
aam.save(
|
992 |
-
$(this).data('metabox'),
|
993 |
-
$(this).attr('checked') ? 1 : 0,
|
994 |
-
'metabox',
|
995 |
-
null,
|
996 |
-
function(result) {
|
997 |
-
if (result.status === 'success') {
|
998 |
-
$('#aam-metabox-overwrite').show();
|
999 |
-
}
|
1000 |
-
}
|
1001 |
-
);
|
1002 |
-
});
|
1003 |
-
});
|
1004 |
-
}
|
1005 |
-
}
|
1006 |
-
|
1007 |
-
aam.addHook('init', initialize);
|
1008 |
-
|
1009 |
-
})(jQuery);
|
1010 |
-
|
1011 |
-
|
1012 |
-
/**
|
1013 |
-
* Capabilities Interface
|
1014 |
-
*
|
1015 |
-
* @param {jQuery} $
|
1016 |
-
*
|
1017 |
-
* @returns {void}
|
1018 |
-
*/
|
1019 |
-
(function ($) {
|
1020 |
-
|
1021 |
-
/**
|
1022 |
-
*
|
1023 |
-
* @param {type} capability
|
1024 |
-
* @param {type} btn
|
1025 |
-
* @returns {undefined}
|
1026 |
-
*/
|
1027 |
-
function save(capability, btn) {
|
1028 |
-
var granted = $(btn).hasClass('icon-check-empty') ? 1 : 0;
|
1029 |
-
|
1030 |
-
//show indicator
|
1031 |
-
$(btn).attr('class', 'aam-row-action icon-spin4 animate-spin');
|
1032 |
-
|
1033 |
-
aam.save(capability, granted, 'capability', null, function(result) {
|
1034 |
-
if (result.status === 'success') {
|
1035 |
-
if (granted) {
|
1036 |
-
$(btn).attr('class', 'aam-row-action text-success icon-check');
|
1037 |
-
} else {
|
1038 |
-
$(btn).attr('class', 'aam-row-action text-muted icon-check-empty');
|
1039 |
-
}
|
1040 |
-
} else {
|
1041 |
-
if (granted) {
|
1042 |
-
aam.notification(
|
1043 |
-
'danger', aam.__('WordPress core does not allow to grant this capability')
|
1044 |
-
);
|
1045 |
-
$(btn).attr('class', 'aam-row-action text-muted icon-check-empty');
|
1046 |
-
} else {
|
1047 |
-
$(btn).attr('class', 'aam-row-action text-success icon-check');
|
1048 |
-
}
|
1049 |
-
}
|
1050 |
-
});
|
1051 |
-
}
|
1052 |
-
/**
|
1053 |
-
*
|
1054 |
-
* @returns {undefined}
|
1055 |
-
*/
|
1056 |
-
function initialize() {
|
1057 |
-
if ($('#capability-content').length) {
|
1058 |
-
//initialize the role list table
|
1059 |
-
$('#capability-list').DataTable({
|
1060 |
-
autoWidth: false,
|
1061 |
-
ordering: false,
|
1062 |
-
pagingType: 'simple',
|
1063 |
-
serverSide: false,
|
1064 |
-
ajax: {
|
1065 |
-
url: aamLocal.ajaxurl,
|
1066 |
-
type: 'POST',
|
1067 |
-
data: {
|
1068 |
-
action: 'aam',
|
1069 |
-
sub_action: 'Capability.getTable',
|
1070 |
-
_ajax_nonce: aamLocal.nonce,
|
1071 |
-
subject: aam.getSubject().type,
|
1072 |
-
subjectId: aam.getSubject().id
|
1073 |
-
}
|
1074 |
-
},
|
1075 |
-
columnDefs: [
|
1076 |
-
{visible: false, targets: [0]}
|
1077 |
-
],
|
1078 |
-
language: {
|
1079 |
-
search: '_INPUT_',
|
1080 |
-
searchPlaceholder: aam.__('Search Capability'),
|
1081 |
-
info: aam.__('_TOTAL_ capability(s)'),
|
1082 |
-
infoFiltered: '',
|
1083 |
-
infoEmpty: aam.__('Nothing to show'),
|
1084 |
-
lengthMenu: '_MENU_'
|
1085 |
-
},
|
1086 |
-
createdRow: function (row, data) {
|
1087 |
-
var actions = data[3].split(',');
|
1088 |
-
|
1089 |
-
var container = $('<div/>', {'class': 'aam-row-actions'});
|
1090 |
-
$.each(actions, function (i, action) {
|
1091 |
-
switch (action) {
|
1092 |
-
case 'unchecked':
|
1093 |
-
$(container).append($('<i/>', {
|
1094 |
-
'class': 'aam-row-action text-muted icon-check-empty'
|
1095 |
-
}).bind('click', function () {
|
1096 |
-
save(data[0], this);
|
1097 |
-
}));
|
1098 |
-
break;
|
1099 |
-
|
1100 |
-
case 'checked':
|
1101 |
-
$(container).append($('<i/>', {
|
1102 |
-
'class': 'aam-row-action text-success icon-check'
|
1103 |
-
}).bind('click', function () {
|
1104 |
-
save(data[0], this);
|
1105 |
-
}));
|
1106 |
-
break;
|
1107 |
-
|
1108 |
-
case 'edit':
|
1109 |
-
$(container).append($('<i/>', {
|
1110 |
-
'class': 'aam-row-action icon-pencil text-warning'
|
1111 |
-
}).bind('click', function () {
|
1112 |
-
$('#capability-id').val(data[0]);
|
1113 |
-
$('#update-capability-btn').attr('data-cap', data[0]);
|
1114 |
-
$('#edit-capability-modal').modal('show');
|
1115 |
-
}));
|
1116 |
-
break;
|
1117 |
-
|
1118 |
-
case 'delete':
|
1119 |
-
$(container).append($('<i/>', {
|
1120 |
-
'class': 'aam-row-action icon-trash-empty text-danger'
|
1121 |
-
}).bind('click', function () {
|
1122 |
-
var message = $('.aam-confirm-message', '#delete-capability-modal');
|
1123 |
-
$(message).html(message.data('message').replace(
|
1124 |
-
'%s', '<b>' + data[0] + '</b>')
|
1125 |
-
);
|
1126 |
-
$('#capability-id').val(data[0]);
|
1127 |
-
$('#delete-capability-btn').attr('data-cap', data[0]);
|
1128 |
-
$('#delete-capability-modal').modal('show');
|
1129 |
-
}));
|
1130 |
-
break;
|
1131 |
-
|
1132 |
-
default:
|
1133 |
-
aam.triggerHook('decorate-capability-row', {
|
1134 |
-
action: action,
|
1135 |
-
container: container,
|
1136 |
-
data: data
|
1137 |
-
});
|
1138 |
-
break;
|
1139 |
-
}
|
1140 |
-
});
|
1141 |
-
$('td:eq(2)', row).html(container);
|
1142 |
-
}
|
1143 |
-
});
|
1144 |
-
|
1145 |
-
$('a', '#capability-groups').each(function () {
|
1146 |
-
$(this).bind('click', function () {
|
1147 |
-
var table = $('#capability-list').DataTable();
|
1148 |
-
if ($(this).data('clear') !== true) {
|
1149 |
-
table.column(1).search($(this).text()).draw();
|
1150 |
-
} else {
|
1151 |
-
table.column(1).search('').draw();
|
1152 |
-
}
|
1153 |
-
});
|
1154 |
-
});
|
1155 |
-
|
1156 |
-
$('#add-capability-modal').on('shown.bs.modal', function (e) {
|
1157 |
-
$('#new-capability-name').val('');
|
1158 |
-
});
|
1159 |
-
|
1160 |
-
$('#add-capability').bind('click', function () {
|
1161 |
-
$('#add-capability-modal').modal('show');
|
1162 |
-
});
|
1163 |
-
|
1164 |
-
$('#add-capability-btn').bind('click', function () {
|
1165 |
-
var _this = this;
|
1166 |
-
|
1167 |
-
var capability = $.trim($('#new-capability-name').val());
|
1168 |
-
$('#new-capability-name').parent().removeClass('has-error');
|
1169 |
-
|
1170 |
-
if (capability) {
|
1171 |
-
$.ajax(aamLocal.ajaxurl, {
|
1172 |
-
type: 'POST',
|
1173 |
-
dataType: 'json',
|
1174 |
-
data: {
|
1175 |
-
action: 'aam',
|
1176 |
-
sub_action: 'Capability.add',
|
1177 |
-
_ajax_nonce: aamLocal.nonce,
|
1178 |
-
capability: capability,
|
1179 |
-
subject: aam.getSubject().type,
|
1180 |
-
subjectId: aam.getSubject().id
|
1181 |
-
},
|
1182 |
-
beforeSend: function () {
|
1183 |
-
$(_this).text(aam.__('Saving...')).attr('disabled', true);
|
1184 |
-
},
|
1185 |
-
success: function (response) {
|
1186 |
-
if (response.status === 'success') {
|
1187 |
-
$('#add-capability-modal').modal('hide');
|
1188 |
-
$('#capability-list').DataTable().ajax.reload();
|
1189 |
-
} else {
|
1190 |
-
aam.notification(
|
1191 |
-
'danger', aam.__('Failed to add new capability')
|
1192 |
-
);
|
1193 |
-
}
|
1194 |
-
},
|
1195 |
-
error: function () {
|
1196 |
-
aam.notification('danger', aam.__('Application error'));
|
1197 |
-
},
|
1198 |
-
complete: function () {
|
1199 |
-
$(_this).text(aam.__('Add Capability')).attr('disabled', false);
|
1200 |
-
}
|
1201 |
-
});
|
1202 |
-
} else {
|
1203 |
-
$('#new-capability-name').parent().addClass('has-error');
|
1204 |
-
}
|
1205 |
-
});
|
1206 |
-
|
1207 |
-
$('#add-capability-modal').on('shown.bs.modal', function (e) {
|
1208 |
-
$('#new-capability-name').focus();
|
1209 |
-
});
|
1210 |
-
|
1211 |
-
$('#update-capability-btn').bind('click', function () {
|
1212 |
-
var btn = this;
|
1213 |
-
var cap = $.trim($('#capability-id').val());
|
1214 |
-
|
1215 |
-
if (cap) {
|
1216 |
-
$.ajax(aamLocal.ajaxurl, {
|
1217 |
-
type: 'POST',
|
1218 |
-
dataType: 'json',
|
1219 |
-
data: {
|
1220 |
-
action: 'aam',
|
1221 |
-
sub_action: 'Capability.update',
|
1222 |
-
_ajax_nonce: aamLocal.nonce,
|
1223 |
-
capability: $(this).attr('data-cap'),
|
1224 |
-
updated: cap
|
1225 |
-
},
|
1226 |
-
beforeSend: function () {
|
1227 |
-
$(btn).text(aam.__('Saving...')).attr('disabled', true);
|
1228 |
-
},
|
1229 |
-
success: function (response) {
|
1230 |
-
if (response.status === 'success') {
|
1231 |
-
$('#edit-capability-modal').modal('hide');
|
1232 |
-
$('#capability-list').DataTable().ajax.reload();
|
1233 |
-
} else {
|
1234 |
-
aam.notification(
|
1235 |
-
'danger', aam.__('Failed to update capability')
|
1236 |
-
);
|
1237 |
-
}
|
1238 |
-
},
|
1239 |
-
error: function () {
|
1240 |
-
aam.notification('danger', aam.__('Application error'));
|
1241 |
-
},
|
1242 |
-
complete: function () {
|
1243 |
-
$(btn).text(aam.__('Update Capability')).attr(
|
1244 |
-
'disabled', false
|
1245 |
-
);
|
1246 |
-
}
|
1247 |
-
});
|
1248 |
-
}
|
1249 |
-
});
|
1250 |
-
|
1251 |
-
$('#delete-capability-btn').bind('click', function () {
|
1252 |
-
var btn = this;
|
1253 |
-
|
1254 |
-
$.ajax(aamLocal.ajaxurl, {
|
1255 |
-
type: 'POST',
|
1256 |
-
dataType: 'json',
|
1257 |
-
data: {
|
1258 |
-
action: 'aam',
|
1259 |
-
sub_action: 'Capability.delete',
|
1260 |
-
_ajax_nonce: aamLocal.nonce,
|
1261 |
-
subject: aam.getSubject().type,
|
1262 |
-
subjectId: aam.getSubject().id,
|
1263 |
-
capability: $(this).attr('data-cap')
|
1264 |
-
},
|
1265 |
-
beforeSend: function () {
|
1266 |
-
$(btn).text(aam.__('Deleting...')).attr('disabled', true);
|
1267 |
-
},
|
1268 |
-
success: function (response) {
|
1269 |
-
if (response.status === 'success') {
|
1270 |
-
$('#delete-capability-modal').modal('hide');
|
1271 |
-
$('#capability-list').DataTable().ajax.reload();
|
1272 |
-
} else {
|
1273 |
-
aam.notification(
|
1274 |
-
'danger', aam.__('Failed to delete capability')
|
1275 |
-
);
|
1276 |
-
}
|
1277 |
-
},
|
1278 |
-
error: function () {
|
1279 |
-
aam.notification('danger', aam.__('Application error'));
|
1280 |
-
},
|
1281 |
-
complete: function () {
|
1282 |
-
$(btn).text(aam.__('Delete Capability')).attr(
|
1283 |
-
'disabled', false
|
1284 |
-
);
|
1285 |
-
}
|
1286 |
-
});
|
1287 |
-
});
|
1288 |
-
|
1289 |
-
//reset button
|
1290 |
-
$('#capability-reset').bind('click', function () {
|
1291 |
-
aam.reset('capability');
|
1292 |
-
});
|
1293 |
-
}
|
1294 |
-
}
|
1295 |
-
|
1296 |
-
aam.addHook('init', initialize);
|
1297 |
-
|
1298 |
-
})(jQuery);
|
1299 |
-
|
1300 |
-
|
1301 |
-
/**
|
1302 |
-
* Posts & Pages Interface
|
1303 |
-
*
|
1304 |
-
* @param {jQuery} $
|
1305 |
-
*
|
1306 |
-
* @returns {void}
|
1307 |
-
*/
|
1308 |
-
(function ($) {
|
1309 |
-
|
1310 |
-
/**
|
1311 |
-
* Table extra filter
|
1312 |
-
*
|
1313 |
-
* @type Object
|
1314 |
-
*/
|
1315 |
-
var filter = {
|
1316 |
-
type: null
|
1317 |
-
};
|
1318 |
-
|
1319 |
-
/**
|
1320 |
-
*
|
1321 |
-
* @param {*} param
|
1322 |
-
* @param {*} value
|
1323 |
-
* @param {*} object
|
1324 |
-
* @param {*} object_id
|
1325 |
-
* @param {*} successCallback
|
1326 |
-
*/
|
1327 |
-
function save(param, value, object, object_id, successCallback) {
|
1328 |
-
$.ajax(aamLocal.ajaxurl, {
|
1329 |
-
type: 'POST',
|
1330 |
-
dataType: 'json',
|
1331 |
-
data: {
|
1332 |
-
action: 'aam',
|
1333 |
-
sub_action: 'Post.save',
|
1334 |
-
_ajax_nonce: aamLocal.nonce,
|
1335 |
-
subject: aam.getSubject().type,
|
1336 |
-
subjectId: aam.getSubject().id,
|
1337 |
-
param: param,
|
1338 |
-
value: value,
|
1339 |
-
object: object,
|
1340 |
-
objectId: object_id
|
1341 |
-
},
|
1342 |
-
success: function (response) {
|
1343 |
-
if (response.status === 'failure') {
|
1344 |
-
aam.notification('danger', response.error);
|
1345 |
-
} else {
|
1346 |
-
$('#post-overwritten').removeClass('hidden');
|
1347 |
-
//add some specific attributes to reset button
|
1348 |
-
$('#post-reset').attr({
|
1349 |
-
'data-type': object,
|
1350 |
-
'data-id': object_id
|
1351 |
-
});
|
1352 |
-
}
|
1353 |
-
successCallback(response);
|
1354 |
-
},
|
1355 |
-
error: function () {
|
1356 |
-
aam.notification('danger', aam.__('Application error'));
|
1357 |
-
}
|
1358 |
-
});
|
1359 |
-
}
|
1360 |
-
|
1361 |
-
/**
|
1362 |
-
*
|
1363 |
-
* @param {type} type
|
1364 |
-
* @param {type} id
|
1365 |
-
* @param {type} title
|
1366 |
-
* @returns {undefined}
|
1367 |
-
*/
|
1368 |
-
function addBreadcrumbLevel(type, id, title) {
|
1369 |
-
var level = $((type === 'type' ? '<a/>' : '<span/>')).attr({
|
1370 |
-
'href': '#',
|
1371 |
-
'data-level': type,
|
1372 |
-
'data-id': id
|
1373 |
-
}).html('<i class="icon-angle-double-right"></i>' + title);
|
1374 |
-
$('.aam-post-breadcrumb').append(level);
|
1375 |
-
}
|
1376 |
-
|
1377 |
-
/**
|
1378 |
-
*
|
1379 |
-
* @param {type} object
|
1380 |
-
* @param {type} id
|
1381 |
-
* @param {type} btn
|
1382 |
-
* @param {type} callback
|
1383 |
-
* @returns {undefined}
|
1384 |
-
*/
|
1385 |
-
$.aam.loadAccessForm = function(object, id, btn, callback) {
|
1386 |
-
//reset the form first
|
1387 |
-
var container = $('.aam-access-form[data-type="' + object + '"]');
|
1388 |
-
$('#post-overwritten').addClass('hidden');
|
1389 |
-
|
1390 |
-
//show overlay if present
|
1391 |
-
$('.aam-overlay', container).show();
|
1392 |
-
|
1393 |
-
//reset data preview elements
|
1394 |
-
$('[data-preview]', container).text('');
|
1395 |
-
|
1396 |
-
$('.aam-row-action', container).each(function () {
|
1397 |
-
$(this).attr({
|
1398 |
-
'class': 'aam-row-action text-muted icon-check-empty',
|
1399 |
-
'data-type': object,
|
1400 |
-
'data-id': id
|
1401 |
-
});
|
1402 |
-
|
1403 |
-
//initialize each access property
|
1404 |
-
$(this).unbind('click').bind('click', function () {
|
1405 |
-
var _this = $(this);
|
1406 |
-
var checked = !_this.hasClass('icon-check');
|
1407 |
-
|
1408 |
-
_this.attr('class', 'aam-row-action icon-spin4 animate-spin');
|
1409 |
-
var response = save(
|
1410 |
-
_this.data('property'),
|
1411 |
-
(checked ? 1 : 0),
|
1412 |
-
object,
|
1413 |
-
id,
|
1414 |
-
function(response) {
|
1415 |
-
if (response.status === 'success') {
|
1416 |
-
if (checked) {
|
1417 |
-
_this.attr(
|
1418 |
-
'class', 'aam-row-action text-danger icon-check'
|
1419 |
-
);
|
1420 |
-
} else {
|
1421 |
-
_this.attr(
|
1422 |
-
'class', 'aam-row-action text-muted icon-check-empty'
|
1423 |
-
);
|
1424 |
-
}
|
1425 |
-
}
|
1426 |
-
}
|
1427 |
-
);
|
1428 |
-
});
|
1429 |
-
|
1430 |
-
});
|
1431 |
-
|
1432 |
-
$.ajax(aamLocal.ajaxurl, {
|
1433 |
-
type: 'POST',
|
1434 |
-
dataType: 'json',
|
1435 |
-
data: {
|
1436 |
-
action: 'aam',
|
1437 |
-
sub_action: 'Post.getAccess',
|
1438 |
-
_ajax_nonce: aamLocal.nonce,
|
1439 |
-
type: object,
|
1440 |
-
id: id,
|
1441 |
-
subject: aam.getSubject().type,
|
1442 |
-
subjectId: aam.getSubject().id
|
1443 |
-
},
|
1444 |
-
beforeSend: function () {
|
1445 |
-
$(btn).attr('data-class', $(btn).attr('class'));
|
1446 |
-
$(btn).attr('class', 'aam-row-action icon-spin4 animate-spin');
|
1447 |
-
},
|
1448 |
-
success: function (response) {
|
1449 |
-
//iterate through each property
|
1450 |
-
for (var property in response.access) {
|
1451 |
-
var checked = (parseInt(response.access[property]) ? 'text-danger icon-check' : 'text-muted icon-check-empty');
|
1452 |
-
var checkbox = $('[data-property="' + property + '"]', container);
|
1453 |
-
|
1454 |
-
if (checkbox.length) {
|
1455 |
-
checkbox.attr({
|
1456 |
-
'class': 'aam-row-action ' + checked
|
1457 |
-
});
|
1458 |
-
} else {
|
1459 |
-
$('[data-preview="' + property + '"]', container).prop('data-original-value', response.access[property]);
|
1460 |
-
$('[data-preview="' + property + '"]', container).html(
|
1461 |
-
preparePreview(response.access[property])
|
1462 |
-
);
|
1463 |
-
}
|
1464 |
-
}
|
1465 |
-
|
1466 |
-
//check metadata and show message if necessary
|
1467 |
-
if (response.meta.overwritten === true) {
|
1468 |
-
$('#post-overwritten').removeClass('hidden');
|
1469 |
-
//add some specific attributes to reset button
|
1470 |
-
$('#post-reset').attr({
|
1471 |
-
'data-type': object,
|
1472 |
-
'data-id': id
|
1473 |
-
});
|
1474 |
-
}
|
1475 |
-
|
1476 |
-
$('.extended-post-access-btn').attr({
|
1477 |
-
'data-type': object,
|
1478 |
-
'data-id': id
|
1479 |
-
});
|
1480 |
-
|
1481 |
-
$('#post-list_wrapper').addClass('aam-hidden');
|
1482 |
-
container.addClass('active');
|
1483 |
-
|
1484 |
-
if (typeof callback === 'function') {
|
1485 |
-
callback.call();
|
1486 |
-
}
|
1487 |
-
|
1488 |
-
//update dynamic labels
|
1489 |
-
if ($('#load-post-object-title').length) {
|
1490 |
-
var marker = $('#load-post-object-title').val();
|
1491 |
-
} else {
|
1492 |
-
marker = $('.aam-post-breadcrumb span').text();
|
1493 |
-
}
|
1494 |
-
$('[data-dynamic-post-label]').each(function() {
|
1495 |
-
$(this).html(
|
1496 |
-
$(this).attr('data-dynamic-post-label').replace(/%s/g, '<b>' + marker + '</b>')
|
1497 |
-
);
|
1498 |
-
});
|
1499 |
-
},
|
1500 |
-
error: function () {
|
1501 |
-
aam.notification('danger', aam.__('Application error'));
|
1502 |
-
},
|
1503 |
-
complete: function () {
|
1504 |
-
$(btn).attr('class', $(btn).attr('data-class')).removeAttr('data-class');
|
1505 |
-
//show overlay if present
|
1506 |
-
$('.aam-overlay', container).hide();
|
1507 |
-
}
|
1508 |
-
});
|
1509 |
-
};
|
1510 |
-
|
1511 |
-
/**
|
1512 |
-
*
|
1513 |
-
* @param {type} text
|
1514 |
-
* @returns {String}
|
1515 |
-
*/
|
1516 |
-
function preparePreview(preview) {
|
1517 |
-
if (typeof preview === 'string') {
|
1518 |
-
preview = preview.replace(/<\/?[^>]+(>|$)/g, "");
|
1519 |
-
|
1520 |
-
if (preview.length > 25) {
|
1521 |
-
preview = preview.substring(0, 22) + '...';
|
1522 |
-
}
|
1523 |
-
}
|
1524 |
-
|
1525 |
-
return preview;
|
1526 |
-
}
|
1527 |
-
|
1528 |
-
/**
|
1529 |
-
*
|
1530 |
-
* @returns {undefined}
|
1531 |
-
*/
|
1532 |
-
function initialize() {
|
1533 |
-
if ($('#post-content').length) {
|
1534 |
-
//reset filter to default list of post types
|
1535 |
-
filter.type = null;
|
1536 |
-
|
1537 |
-
//initialize the role list table
|
1538 |
-
$('#post-list').DataTable({
|
1539 |
-
autoWidth: false,
|
1540 |
-
ordering: false,
|
1541 |
-
pagingType: 'simple',
|
1542 |
-
processing: true,
|
1543 |
-
serverSide: true,
|
1544 |
-
ajax: {
|
1545 |
-
url: aamLocal.ajaxurl,
|
1546 |
-
type: 'POST',
|
1547 |
-
data: function (data) {
|
1548 |
-
data.action = 'aam';
|
1549 |
-
data.sub_action = 'Post.getTable';
|
1550 |
-
data._ajax_nonce = aamLocal.nonce;
|
1551 |
-
data.subject = aam.getSubject().type;
|
1552 |
-
data.subjectId = aam.getSubject().id;
|
1553 |
-
data.type = filter.type;
|
1554 |
-
}
|
1555 |
-
},
|
1556 |
-
columnDefs: [
|
1557 |
-
{visible: false, targets: [0, 1]}
|
1558 |
-
],
|
1559 |
-
language: {
|
1560 |
-
search: '_INPUT_',
|
1561 |
-
searchPlaceholder: aam.__('Search'),
|
1562 |
-
info: aam.__('_TOTAL_ object(s)'),
|
1563 |
-
infoFiltered: '',
|
1564 |
-
lengthMenu: '_MENU_'
|
1565 |
-
},
|
1566 |
-
initComplete: function () {
|
1567 |
-
$('#post-list_filter .form-control').bind('change', function() {
|
1568 |
-
if ($(this).val()) {
|
1569 |
-
$(this).addClass('highlight');
|
1570 |
-
} else {
|
1571 |
-
$(this).removeClass('highlight');
|
1572 |
-
}
|
1573 |
-
});
|
1574 |
-
},
|
1575 |
-
rowCallback: function (row, data) {
|
1576 |
-
//object type icon
|
1577 |
-
switch (data[2]) {
|
1578 |
-
case 'type':
|
1579 |
-
$('td:eq(0)', row).html('<i class="icon-box"></i>');
|
1580 |
-
break;
|
1581 |
-
|
1582 |
-
case 'term':
|
1583 |
-
$('td:eq(0)', row).html('<i class="icon-folder"></i>');
|
1584 |
-
break;
|
1585 |
-
|
1586 |
-
default:
|
1587 |
-
$('td:eq(0)', row).html('<i class="icon-doc-text-inv"></i>');
|
1588 |
-
break;
|
1589 |
-
}
|
1590 |
-
|
1591 |
-
//update the title to a link
|
1592 |
-
if (data[2] === 'type') {
|
1593 |
-
var link = $('<a/>', {
|
1594 |
-
href: '#'
|
1595 |
-
}).bind('click', function () {
|
1596 |
-
//visual feedback - show loading icon
|
1597 |
-
$('td:eq(0)', row).html(
|
1598 |
-
'<i class="icon-spin4 animate-spin"></i>'
|
1599 |
-
);
|
1600 |
-
//set filter
|
1601 |
-
filter[data[2]] = data[0];
|
1602 |
-
|
1603 |
-
//finally reload the data
|
1604 |
-
$('#post-list').DataTable().ajax.reload();
|
1605 |
-
|
1606 |
-
//update the breadcrumb
|
1607 |
-
addBreadcrumbLevel('type', data[0], data[3]);
|
1608 |
-
|
1609 |
-
}).html(data[3]);
|
1610 |
-
$('td:eq(1)', row).html(link);
|
1611 |
-
} else { //reset the post/term title
|
1612 |
-
$('td:eq(1)', row).html(data[3]);
|
1613 |
-
}
|
1614 |
-
|
1615 |
-
//update the actions
|
1616 |
-
var actions = data[4].split(',');
|
1617 |
-
|
1618 |
-
var container = $('<div/>', {'class': 'aam-row-actions'});
|
1619 |
-
$.each(actions, function (i, action) {
|
1620 |
-
switch (action) {
|
1621 |
-
case 'drilldown':
|
1622 |
-
$(container).append($('<i/>', {
|
1623 |
-
'class': 'aam-row-action text-success icon-level-down'
|
1624 |
-
}).bind('click', function () {
|
1625 |
-
if (!$(this).prop('disabled')) {
|
1626 |
-
$(this).prop('disabled', true);
|
1627 |
-
//set filter
|
1628 |
-
filter[data[2]] = data[0];
|
1629 |
-
//finally reload the data
|
1630 |
-
$('#post-list').DataTable().ajax.reload();
|
1631 |
-
//update the breadcrumb
|
1632 |
-
addBreadcrumbLevel('type', data[0], data[3]);
|
1633 |
-
}
|
1634 |
-
}).attr({
|
1635 |
-
'data-toggle': "tooltip",
|
1636 |
-
'title': aam.__('Drill-Down')
|
1637 |
-
}));
|
1638 |
-
$('.tooltip').remove();
|
1639 |
-
break;
|
1640 |
-
|
1641 |
-
case 'manage':
|
1642 |
-
$(container).append($('<i/>', {
|
1643 |
-
'class': 'aam-row-action text-info icon-cog'
|
1644 |
-
}).bind('click', function () {
|
1645 |
-
$.aam.loadAccessForm(data[2], data[0], $(this), function () {
|
1646 |
-
addBreadcrumbLevel('edit', data[2], data[3]);
|
1647 |
-
});
|
1648 |
-
}).attr({
|
1649 |
-
'data-toggle': "tooltip",
|
1650 |
-
'title': aam.__('Manage Access')
|
1651 |
-
}));
|
1652 |
-
$('.tooltip').remove();
|
1653 |
-
break;
|
1654 |
-
|
1655 |
-
case 'edit' :
|
1656 |
-
$(container).append($('<i/>', {
|
1657 |
-
'class': 'aam-row-action text-warning icon-pencil'
|
1658 |
-
}).bind('click', function () {
|
1659 |
-
window.open(data[1], '_blank');
|
1660 |
-
}).attr({
|
1661 |
-
'data-toggle': "tooltip",
|
1662 |
-
'title': aam.__('Edit')
|
1663 |
-
}));
|
1664 |
-
break;
|
1665 |
-
|
1666 |
-
default:
|
1667 |
-
aam.triggerHook('post-action', {
|
1668 |
-
container: container,
|
1669 |
-
action : action,
|
1670 |
-
data : data
|
1671 |
-
});
|
1672 |
-
break;
|
1673 |
-
}
|
1674 |
-
});
|
1675 |
-
$('td:eq(2)', row).html(container);
|
1676 |
-
}
|
1677 |
-
});
|
1678 |
-
|
1679 |
-
//initialize the breadcrumb
|
1680 |
-
$('.aam-post-breadcrumb').delegate('a', 'click', function () {
|
1681 |
-
filter.type = $(this).data('id');
|
1682 |
-
$('#post-list').DataTable().ajax.reload();
|
1683 |
-
$(this).nextAll().remove();
|
1684 |
-
$('.aam-slide-form').removeClass('active');
|
1685 |
-
$('#post-list_wrapper').removeClass('aam-hidden');
|
1686 |
-
$('#post-overwritten').addClass('hidden');
|
1687 |
-
});
|
1688 |
-
|
1689 |
-
//reset button
|
1690 |
-
$('#post-reset').bind('click', function () {
|
1691 |
-
var type = $(this).attr('data-type');
|
1692 |
-
var id = $(this).attr('data-id');
|
1693 |
-
|
1694 |
-
$.ajax(aamLocal.ajaxurl, {
|
1695 |
-
type: 'POST',
|
1696 |
-
dataType: 'json',
|
1697 |
-
data: {
|
1698 |
-
action: 'aam',
|
1699 |
-
sub_action: 'Post.reset',
|
1700 |
-
_ajax_nonce: aamLocal.nonce,
|
1701 |
-
type: type,
|
1702 |
-
id: id,
|
1703 |
-
subject: aam.getSubject().type,
|
1704 |
-
subjectId: aam.getSubject().id
|
1705 |
-
},
|
1706 |
-
beforeSend: function () {
|
1707 |
-
},
|
1708 |
-
success: function (response) {
|
1709 |
-
if (response.status === 'success') {
|
1710 |
-
$('#post-overwritten').addClass('hidden');
|
1711 |
-
$.aam.loadAccessForm(type, id);
|
1712 |
-
}
|
1713 |
-
}
|
1714 |
-
});
|
1715 |
-
});
|
1716 |
-
|
1717 |
-
//go back button
|
1718 |
-
$('.aam-slide-form').delegate('.post-back', 'click', function () {
|
1719 |
-
var type = $(this).parent().data('type');
|
1720 |
-
|
1721 |
-
$('.aam-slide-form[data-type="' + type + '"]').removeClass('active');
|
1722 |
-
$('#post-list_wrapper').removeClass('aam-hidden');
|
1723 |
-
$('.aam-post-breadcrumb span:last').remove();
|
1724 |
-
$('#post-overwritten').addClass('hidden');
|
1725 |
-
});
|
1726 |
-
|
1727 |
-
//load referenced post
|
1728 |
-
if ($('#load-post-object').val()) {
|
1729 |
-
$.aam.loadAccessForm(
|
1730 |
-
$('#load-post-object-type').val(),
|
1731 |
-
$('#load-post-object').val()
|
1732 |
-
);
|
1733 |
-
}
|
1734 |
-
|
1735 |
-
$('.change-password').each(function() {
|
1736 |
-
$(this).bind('click', function() {
|
1737 |
-
var password = $('#' + $(this).attr('data-preview-id')).text();
|
1738 |
-
|
1739 |
-
if (password !== '') {
|
1740 |
-
$('#password-value').val(password);
|
1741 |
-
} else {
|
1742 |
-
$('#password-value').val('');
|
1743 |
-
}
|
1744 |
-
|
1745 |
-
$('#change-password-btn').attr({
|
1746 |
-
'data-ref': $(this).attr('data-ref'),
|
1747 |
-
'data-preview-id': $(this).attr('data-preview-id')
|
1748 |
-
});
|
1749 |
-
|
1750 |
-
$('#password-modal').modal('show');
|
1751 |
-
});
|
1752 |
-
});
|
1753 |
-
|
1754 |
-
$('#change-password-btn').bind('click', function() {
|
1755 |
-
var _this = $(this);
|
1756 |
-
_this.text(aam.__('Saving...'));
|
1757 |
-
|
1758 |
-
var password = $('#password-value').val();
|
1759 |
-
save(
|
1760 |
-
_this.attr('data-ref'),
|
1761 |
-
password,
|
1762 |
-
_this.attr('data-type'),
|
1763 |
-
_this.attr('data-id'),
|
1764 |
-
function(response) {
|
1765 |
-
if (response.status === 'success') {
|
1766 |
-
var preview = $('#' + _this.attr('data-preview-id'));
|
1767 |
-
var action = $('.aam-row-action', preview.parent().parent().parent());
|
1768 |
-
|
1769 |
-
preview.html(password ? password : '');
|
1770 |
-
|
1771 |
-
if ($(action).hasClass('icon-check-empty')) {
|
1772 |
-
action.trigger('click');
|
1773 |
-
}
|
1774 |
-
}
|
1775 |
-
$('#password-modal').modal('hide');
|
1776 |
-
|
1777 |
-
_this.text(aam.__('Set'));
|
1778 |
-
}
|
1779 |
-
);
|
1780 |
-
});
|
1781 |
-
|
1782 |
-
$('.change-location').each(function() {
|
1783 |
-
$(this).bind('click', function() {
|
1784 |
-
var location = $('#' + $(this).attr('data-preview-id')).text();
|
1785 |
-
|
1786 |
-
if (location !== '') {
|
1787 |
-
$('#location-value').val(location);
|
1788 |
-
} else {
|
1789 |
-
$('#location-value').val('');
|
1790 |
-
}
|
1791 |
-
|
1792 |
-
$('#change-location-btn').attr({
|
1793 |
-
'data-ref': $(this).attr('data-ref'),
|
1794 |
-
'data-preview-id': $(this).attr('data-preview-id')
|
1795 |
-
});
|
1796 |
-
|
1797 |
-
$('#location-modal').modal('show');
|
1798 |
-
});
|
1799 |
-
});
|
1800 |
-
|
1801 |
-
$('#change-location-btn').bind('click', function() {
|
1802 |
-
var _this = $(this);
|
1803 |
-
_this.text(aam.__('Saving...'));
|
1804 |
-
|
1805 |
-
var redirect = $('#location-value').val();
|
1806 |
-
save(
|
1807 |
-
_this.attr('data-ref'),
|
1808 |
-
redirect,
|
1809 |
-
_this.attr('data-type'),
|
1810 |
-
_this.attr('data-id'),
|
1811 |
-
function(response) {
|
1812 |
-
if (response.status === 'success') {
|
1813 |
-
var preview = $('#' + _this.attr('data-preview-id'));
|
1814 |
-
var action = $('.aam-row-action', preview.parent().parent().parent());
|
1815 |
-
|
1816 |
-
preview.html(redirect ? redirect : '');
|
1817 |
-
|
1818 |
-
if ($(action).hasClass('icon-check-empty')) {
|
1819 |
-
action.trigger('click');
|
1820 |
-
}
|
1821 |
-
}
|
1822 |
-
$('#location-modal').modal('hide');
|
1823 |
-
_this.text(aam.__('Set'));
|
1824 |
-
}
|
1825 |
-
);
|
1826 |
-
});
|
1827 |
-
|
1828 |
-
$('.change-expiration').each(function() {
|
1829 |
-
$(this).bind('click', function() {
|
1830 |
-
var expiration = $('#' + $(this).attr('data-preview-id')).text();
|
1831 |
-
|
1832 |
-
if (expiration !== '') {
|
1833 |
-
$('#expiration-value').val(expiration);
|
1834 |
-
} else {
|
1835 |
-
$('#expiration-value').val('');
|
1836 |
-
}
|
1837 |
-
|
1838 |
-
$('#change-expiration-btn').attr({
|
1839 |
-
'data-ref': $(this).attr('data-ref'),
|
1840 |
-
'data-preview-id': $(this).attr('data-preview-id')
|
1841 |
-
});
|
1842 |
-
|
1843 |
-
$('#expiration-modal').modal('show');
|
1844 |
-
});
|
1845 |
-
});
|
1846 |
-
|
1847 |
-
$('#change-expiration-btn').bind('click', function() {
|
1848 |
-
var _this = $(this);
|
1849 |
-
_this.text(aam.__('Saving...'));
|
1850 |
-
|
1851 |
-
var expires = $('#expiration-value').val();
|
1852 |
-
save(
|
1853 |
-
_this.attr('data-ref'),
|
1854 |
-
expires,
|
1855 |
-
_this.attr('data-type'),
|
1856 |
-
_this.attr('data-id'),
|
1857 |
-
function(response) {
|
1858 |
-
if (response.status === 'success') {
|
1859 |
-
var preview = $('#' + _this.attr('data-preview-id'));
|
1860 |
-
var action = $('.aam-row-action', preview.parent().parent().parent());
|
1861 |
-
preview.html(response.value);
|
1862 |
-
|
1863 |
-
if ($(action).hasClass('icon-check-empty')) {
|
1864 |
-
action.trigger('click');
|
1865 |
-
}
|
1866 |
-
}
|
1867 |
-
$('#expiration-modal').modal('hide');
|
1868 |
-
_this.text(aam.__('Set'));
|
1869 |
-
}
|
1870 |
-
);
|
1871 |
-
});
|
1872 |
-
|
1873 |
-
$('.change-teaser').each(function() {
|
1874 |
-
$(this).bind('click', function() {
|
1875 |
-
var teaser = $('#' + $(this).attr('data-preview-id')).prop('data-original-value');
|
1876 |
-
$('#teaser-value').val(teaser);
|
1877 |
-
|
1878 |
-
$('#change-teaser-btn').attr({
|
1879 |
-
'data-ref': $(this).attr('data-ref'),
|
1880 |
-
'data-preview-id': $(this).attr('data-preview-id')
|
1881 |
-
});
|
1882 |
-
|
1883 |
-
$('#teaser-modal').modal('show');
|
1884 |
-
});
|
1885 |
-
});
|
1886 |
-
|
1887 |
-
$('#change-teaser-btn').bind('click', function() {
|
1888 |
-
var _this = $(this);
|
1889 |
-
_this.text(aam.__('Saving...'));
|
1890 |
-
|
1891 |
-
var teaser = $('#teaser-value').val();
|
1892 |
-
save(
|
1893 |
-
_this.attr('data-ref'),
|
1894 |
-
teaser,
|
1895 |
-
_this.attr('data-type'),
|
1896 |
-
_this.attr('data-id'),
|
1897 |
-
function(response) {
|
1898 |
-
if (response.status === 'success') {
|
1899 |
-
var preview = $('#' + _this.attr('data-preview-id'));
|
1900 |
-
var action = $('.aam-row-action', preview.parent().parent().parent());
|
1901 |
-
|
1902 |
-
preview.prop('data-original-value', teaser);
|
1903 |
-
preview.html(preparePreview(teaser));
|
1904 |
-
|
1905 |
-
if ($(action).hasClass('icon-check-empty')) {
|
1906 |
-
action.trigger('click');
|
1907 |
-
}
|
1908 |
-
}
|
1909 |
-
$('#teaser-modal').modal('hide');
|
1910 |
-
_this.text(aam.__('Save'));
|
1911 |
-
}
|
1912 |
-
);
|
1913 |
-
});
|
1914 |
-
}
|
1915 |
-
}
|
1916 |
-
|
1917 |
-
aam.addHook('init', initialize);
|
1918 |
-
|
1919 |
-
})(jQuery);
|
1920 |
-
|
1921 |
-
/**
|
1922 |
-
* Redirect Interface
|
1923 |
-
*
|
1924 |
-
* @param {jQuery} $
|
1925 |
-
*
|
1926 |
-
* @returns {void}
|
1927 |
-
*/
|
1928 |
-
(function ($) {
|
1929 |
-
|
1930 |
-
/**
|
1931 |
-
*
|
1932 |
-
* @returns {undefined}
|
1933 |
-
*/
|
1934 |
-
function initialize() {
|
1935 |
-
var container = '#redirect-content';
|
1936 |
-
|
1937 |
-
if ($(container).length) {
|
1938 |
-
$('input[type="radio"]', container).each(function () {
|
1939 |
-
$(this).bind('click', function () {
|
1940 |
-
//hide group
|
1941 |
-
$('.' + $(this).data('group')).hide();
|
1942 |
-
|
1943 |
-
//show the specific one
|
1944 |
-
$($(this).data('action')).show();
|
1945 |
-
|
1946 |
-
//save redirect type
|
1947 |
-
aam.save(
|
1948 |
-
$(this).attr('name'),
|
1949 |
-
$(this).val(),
|
1950 |
-
'redirect',
|
1951 |
-
null,
|
1952 |
-
function(result) {
|
1953 |
-
if (result.status === 'success') {
|
1954 |
-
$('#aam-redirect-overwrite').show();
|
1955 |
-
}
|
1956 |
-
}
|
1957 |
-
);
|
1958 |
-
});
|
1959 |
-
});
|
1960 |
-
|
1961 |
-
$('input[type="text"],select,textarea', container).each(function () {
|
1962 |
-
$(this).bind('change', function () {
|
1963 |
-
//save redirect type
|
1964 |
-
aam.save(
|
1965 |
-
$(this).attr('name'),
|
1966 |
-
$(this).val(),
|
1967 |
-
'redirect',
|
1968 |
-
null,
|
1969 |
-
function(result) {
|
1970 |
-
if (result.status === 'success') {
|
1971 |
-
$('#aam-redirect-overwrite').show();
|
1972 |
-
}
|
1973 |
-
}
|
1974 |
-
);
|
1975 |
-
});
|
1976 |
-
});
|
1977 |
-
|
1978 |
-
$('#redirect-reset').bind('click', function () {
|
1979 |
-
aam.reset('redirect');
|
1980 |
-
});
|
1981 |
-
}
|
1982 |
-
}
|
1983 |
-
|
1984 |
-
aam.addHook('init', initialize);
|
1985 |
-
|
1986 |
-
})(jQuery);
|
1987 |
-
|
1988 |
-
/**
|
1989 |
-
* Login Redirect Interface
|
1990 |
-
*
|
1991 |
-
* @param {jQuery} $
|
1992 |
-
*
|
1993 |
-
* @returns {void}
|
1994 |
-
*/
|
1995 |
-
(function ($) {
|
1996 |
-
|
1997 |
-
/**
|
1998 |
-
*
|
1999 |
-
* @returns {undefined}
|
2000 |
-
*/
|
2001 |
-
function initialize() {
|
2002 |
-
var container = '#login_redirect-content';
|
2003 |
-
|
2004 |
-
if ($(container).length) {
|
2005 |
-
$('input[type="radio"]', container).each(function () {
|
2006 |
-
$(this).bind('click', function () {
|
2007 |
-
//hide all fields
|
2008 |
-
$('.login-redirect-action').hide();
|
2009 |
-
|
2010 |
-
//show the specific one
|
2011 |
-
$($(this).data('action')).show();
|
2012 |
-
|
2013 |
-
//save redirect type
|
2014 |
-
aam.save(
|
2015 |
-
$(this).attr('name'),
|
2016 |
-
$(this).val(),
|
2017 |
-
'loginRedirect',
|
2018 |
-
null,
|
2019 |
-
function(result) {
|
2020 |
-
if (result.status === 'success') {
|
2021 |
-
$('#aam-login-redirect-overwrite').show();
|
2022 |
-
}
|
2023 |
-
}
|
2024 |
-
);
|
2025 |
-
});
|
2026 |
-
});
|
2027 |
-
|
2028 |
-
$('input[type="text"],select,textarea', container).each(function () {
|
2029 |
-
$(this).bind('change', function () {
|
2030 |
-
if ($(this).is('input[type="checkbox"]')) {
|
2031 |
-
var val = $(this).prop('checked') ? $(this).val() : 0;
|
2032 |
-
} else {
|
2033 |
-
val = $.trim($(this).val());
|
2034 |
-
}
|
2035 |
-
|
2036 |
-
//save redirect type
|
2037 |
-
aam.save(
|
2038 |
-
$(this).attr('name'),
|
2039 |
-
val,
|
2040 |
-
'loginRedirect',
|
2041 |
-
null,
|
2042 |
-
function(result) {
|
2043 |
-
if (result.status === 'success') {
|
2044 |
-
$('#aam-login-redirect-overwrite').show();
|
2045 |
-
}
|
2046 |
-
}
|
2047 |
-
);
|
2048 |
-
});
|
2049 |
-
});
|
2050 |
-
|
2051 |
-
$('#login-redirect-reset').bind('click', function () {
|
2052 |
-
aam.reset('loginRedirect');
|
2053 |
-
});
|
2054 |
-
}
|
2055 |
-
}
|
2056 |
-
|
2057 |
-
aam.addHook('init', initialize);
|
2058 |
-
|
2059 |
-
})(jQuery);
|
2060 |
-
|
2061 |
-
/**
|
2062 |
-
* Logout Redirect Interface
|
2063 |
-
*
|
2064 |
-
* @param {jQuery} $
|
2065 |
-
*
|
2066 |
-
* @returns {void}
|
2067 |
-
*/
|
2068 |
-
(function ($) {
|
2069 |
-
|
2070 |
-
/**
|
2071 |
-
*
|
2072 |
-
* @returns {undefined}
|
2073 |
-
*/
|
2074 |
-
function initialize() {
|
2075 |
-
var container = '#logout_redirect-content';
|
2076 |
-
|
2077 |
-
if ($(container).length) {
|
2078 |
-
$('input[type="radio"]', container).each(function () {
|
2079 |
-
$(this).bind('click', function () {
|
2080 |
-
//hide all fields
|
2081 |
-
$('.logout-redirect-action').hide();
|
2082 |
-
|
2083 |
-
//show the specific one
|
2084 |
-
$($(this).data('action')).show();
|
2085 |
-
|
2086 |
-
//save redirect type
|
2087 |
-
aam.save(
|
2088 |
-
$(this).attr('name'),
|
2089 |
-
$(this).val(),
|
2090 |
-
'logoutRedirect',
|
2091 |
-
null,
|
2092 |
-
function(result) {
|
2093 |
-
if (result.status === 'success') {
|
2094 |
-
$('#aam-logout-redirect-overwrite').show();
|
2095 |
-
}
|
2096 |
-
}
|
2097 |
-
);
|
2098 |
-
});
|
2099 |
-
});
|
2100 |
-
|
2101 |
-
$('input[type="text"],select,textarea', container).each(function () {
|
2102 |
-
$(this).bind('change', function () {
|
2103 |
-
//save redirect type
|
2104 |
-
aam.save(
|
2105 |
-
$(this).attr('name'),
|
2106 |
-
$(this).val(),
|
2107 |
-
'logoutRedirect',
|
2108 |
-
null,
|
2109 |
-
function(result) {
|
2110 |
-
if (result.status === 'success') {
|
2111 |
-
$('#aam-logout-redirect-overwrite').show();
|
2112 |
-
}
|
2113 |
-
}
|
2114 |
-
);
|
2115 |
-
});
|
2116 |
-
});
|
2117 |
-
|
2118 |
-
$('#logout-redirect-reset').bind('click', function () {
|
2119 |
-
aam.reset('logoutRedirect');
|
2120 |
-
});
|
2121 |
-
}
|
2122 |
-
}
|
2123 |
-
|
2124 |
-
aam.addHook('init', initialize);
|
2125 |
-
|
2126 |
-
})(jQuery);
|
2127 |
-
|
2128 |
-
/**
|
2129 |
-
* Teaser Interface
|
2130 |
-
*
|
2131 |
-
* @param {jQuery} $
|
2132 |
-
*
|
2133 |
-
* @returns {void}
|
2134 |
-
*/
|
2135 |
-
(function ($) {
|
2136 |
-
|
2137 |
-
/**
|
2138 |
-
*
|
2139 |
-
* @returns {undefined}
|
2140 |
-
*/
|
2141 |
-
function initialize() {
|
2142 |
-
var container = '#teaser-content';
|
2143 |
-
|
2144 |
-
if ($(container).length) {
|
2145 |
-
$('input, textarea', container).each(function () {
|
2146 |
-
$(this).bind('change', function () {
|
2147 |
-
if ($(this).is('input[type="checkbox"]')) {
|
2148 |
-
var val = $(this).prop('checked') ? $(this).val() : 0;
|
2149 |
-
} else {
|
2150 |
-
val = $.trim($(this).val());
|
2151 |
-
}
|
2152 |
-
//save redirect type
|
2153 |
-
aam.save(
|
2154 |
-
$(this).attr('name'),
|
2155 |
-
val,
|
2156 |
-
'teaser',
|
2157 |
-
null,
|
2158 |
-
function(result) {
|
2159 |
-
if (result.status === 'success') {
|
2160 |
-
$('#aam-teaser-overwrite').show();
|
2161 |
-
}
|
2162 |
-
}
|
2163 |
-
);
|
2164 |
-
});
|
2165 |
-
});
|
2166 |
-
|
2167 |
-
$('#teaser-reset').bind('click', function () {
|
2168 |
-
aam.reset('teaser');
|
2169 |
-
});
|
2170 |
-
}
|
2171 |
-
}
|
2172 |
-
|
2173 |
-
aam.addHook('init', initialize);
|
2174 |
-
|
2175 |
-
})(jQuery);
|
2176 |
-
|
2177 |
-
/**
|
2178 |
-
* 404 Redirect Interface
|
2179 |
-
*
|
2180 |
-
* @param {jQuery} $
|
2181 |
-
*
|
2182 |
-
* @returns {void}
|
2183 |
-
*/
|
2184 |
-
(function ($) {
|
2185 |
-
|
2186 |
-
/**
|
2187 |
-
*
|
2188 |
-
* @param {type} param
|
2189 |
-
* @param {type} value
|
2190 |
-
* @returns {undefined}
|
2191 |
-
*/
|
2192 |
-
function save(param, value) {
|
2193 |
-
$.ajax(aamLocal.ajaxurl, {
|
2194 |
-
type: 'POST',
|
2195 |
-
dataType: 'json',
|
2196 |
-
data: {
|
2197 |
-
action: 'aam',
|
2198 |
-
sub_action: '404Redirect.save',
|
2199 |
-
_ajax_nonce: aamLocal.nonce,
|
2200 |
-
subject: aam.getSubject().type,
|
2201 |
-
subjectId: aam.getSubject().id,
|
2202 |
-
param: param,
|
2203 |
-
value: value
|
2204 |
-
},
|
2205 |
-
error: function () {
|
2206 |
-
aam.notification('danger', aam.__('Application error'));
|
2207 |
-
}
|
2208 |
-
});
|
2209 |
-
}
|
2210 |
-
|
2211 |
-
/**
|
2212 |
-
*
|
2213 |
-
* @returns {undefined}
|
2214 |
-
*/
|
2215 |
-
function initialize() {
|
2216 |
-
var container = '#404redirect-content';
|
2217 |
-
|
2218 |
-
if ($(container).length) {
|
2219 |
-
$('input[type="radio"]', container).each(function () {
|
2220 |
-
$(this).bind('click', function () {
|
2221 |
-
//hide group
|
2222 |
-
$('.aam-404redirect-action').hide();
|
2223 |
-
|
2224 |
-
//show the specific one
|
2225 |
-
$($(this).data('action')).show();
|
2226 |
-
|
2227 |
-
//save redirect type
|
2228 |
-
save($(this).attr('name'), $(this).val());
|
2229 |
-
});
|
2230 |
-
});
|
2231 |
-
|
2232 |
-
$('input[type="text"],select,textarea', container).each(function () {
|
2233 |
-
$(this).bind('change', function () {
|
2234 |
-
//save redirect type
|
2235 |
-
save($(this).attr('name'), $(this).val());
|
2236 |
-
});
|
2237 |
-
});
|
2238 |
-
}
|
2239 |
-
}
|
2240 |
-
|
2241 |
-
aam.addHook('init', initialize);
|
2242 |
-
|
2243 |
-
})(jQuery);
|
2244 |
-
|
2245 |
-
/**
|
2246 |
-
* Extensions Interface
|
2247 |
-
*
|
2248 |
-
* @param {jQuery} $
|
2249 |
-
*
|
2250 |
-
* @returns {void}
|
2251 |
-
*/
|
2252 |
-
(function ($) {
|
2253 |
-
|
2254 |
-
var dump = null;
|
2255 |
-
|
2256 |
-
/**
|
2257 |
-
*
|
2258 |
-
* @param {*} data
|
2259 |
-
* @param {*} completeCallback
|
2260 |
-
*/
|
2261 |
-
function downloadExtension(data, completeCallback) {
|
2262 |
-
$.ajax(aamLocal.ajaxurl, {
|
2263 |
-
type: 'POST',
|
2264 |
-
dataType: 'json',
|
2265 |
-
data: data,
|
2266 |
-
success: function (response) {
|
2267 |
-
if (response.status === 'success') {
|
2268 |
-
setTimeout(function () {
|
2269 |
-
location.reload();
|
2270 |
-
}, 500);
|
2271 |
-
} else {
|
2272 |
-
aam.notification('danger', aam.__(response.error));
|
2273 |
-
if (typeof response.content !== 'undefined') {
|
2274 |
-
dump = response;
|
2275 |
-
$('#installation-error').html(response.error);
|
2276 |
-
$('#extension-notification-modal').modal('show');
|
2277 |
-
}
|
2278 |
-
}
|
2279 |
-
},
|
2280 |
-
error: function () {
|
2281 |
-
aam.notification('danger', aam.__('Application error'));
|
2282 |
-
},
|
2283 |
-
complete: function() {
|
2284 |
-
completeCallback();
|
2285 |
-
}
|
2286 |
-
});
|
2287 |
-
}
|
2288 |
-
|
2289 |
-
/**
|
2290 |
-
*
|
2291 |
-
* @returns {undefined}
|
2292 |
-
*/
|
2293 |
-
function initialize() {
|
2294 |
-
if ($('#extension-content').length) {
|
2295 |
-
//check for updates
|
2296 |
-
$('#aam-update-check').bind('click', function() {
|
2297 |
-
$.ajax(aamLocal.ajaxurl, {
|
2298 |
-
type: 'POST',
|
2299 |
-
dataType: 'json',
|
2300 |
-
data: {
|
2301 |
-
action: 'aam',
|
2302 |
-
sub_action: 'Extension.check',
|
2303 |
-
_ajax_nonce: aamLocal.nonce,
|
2304 |
-
},
|
2305 |
-
beforeSend: function () {
|
2306 |
-
$('#aam-update-check i').attr('class', 'icon-spin4 animate-spin');
|
2307 |
-
},
|
2308 |
-
complete: function () {
|
2309 |
-
location.reload();
|
2310 |
-
}
|
2311 |
-
});
|
2312 |
-
});
|
2313 |
-
|
2314 |
-
//init refresh list button
|
2315 |
-
$('#install-extension').bind('click', function () {
|
2316 |
-
$('#extension-key').parent().removeClass('error');
|
2317 |
-
|
2318 |
-
var _this = $(this);
|
2319 |
-
var license = $.trim($('#extension-key').val());
|
2320 |
-
|
2321 |
-
if (!license) {
|
2322 |
-
$('#extension-key').parent().addClass('error');
|
2323 |
-
$('#extension-key').focus();
|
2324 |
-
return;
|
2325 |
-
}
|
2326 |
-
|
2327 |
-
$('i', _this).attr('class', 'icon-spin4 animate-spin');
|
2328 |
-
downloadExtension({
|
2329 |
-
action: 'aam',
|
2330 |
-
sub_action: 'Extension.install',
|
2331 |
-
_ajax_nonce: aamLocal.nonce,
|
2332 |
-
license: $('#extension-key').val(),
|
2333 |
-
function() {
|
2334 |
-
$('i', _this).attr('class', 'icon-download-cloud');
|
2335 |
-
}
|
2336 |
-
});
|
2337 |
-
});
|
2338 |
-
|
2339 |
-
//update extension
|
2340 |
-
$('.aam-update-extension').each(function () {
|
2341 |
-
$(this).bind('click', function () {
|
2342 |
-
var _this = $(this);
|
2343 |
-
|
2344 |
-
$('i', _this).attr('class', 'icon-spin4 animate-spin');
|
2345 |
-
downloadExtension({
|
2346 |
-
action: 'aam',
|
2347 |
-
sub_action: 'Extension.update',
|
2348 |
-
_ajax_nonce: aamLocal.nonce,
|
2349 |
-
extension: _this.data('product'),
|
2350 |
-
function() {
|
2351 |
-
$('i', _this).attr('class', 'icon-arrows-cw');
|
2352 |
-
}
|
2353 |
-
});
|
2354 |
-
});
|
2355 |
-
});
|
2356 |
-
|
2357 |
-
//download extension
|
2358 |
-
$('.aam-download-extension').each(function () {
|
2359 |
-
$(this).bind('click', function () {
|
2360 |
-
var _this = $(this);
|
2361 |
-
|
2362 |
-
$('i', _this).attr('class', 'icon-spin4 animate-spin');
|
2363 |
-
downloadExtension({
|
2364 |
-
action: 'aam',
|
2365 |
-
sub_action: 'Extension.install',
|
2366 |
-
_ajax_nonce: aamLocal.nonce,
|
2367 |
-
license: _this.data('license'),
|
2368 |
-
function() {
|
2369 |
-
$('i', _this).attr('class', 'icon-download-cloud');
|
2370 |
-
}
|
2371 |
-
});
|
2372 |
-
});
|
2373 |
-
});
|
2374 |
-
|
2375 |
-
//bind the download handler
|
2376 |
-
$('#download-extension').bind('click', function () {
|
2377 |
-
download(
|
2378 |
-
'data:application/zip;base64,' + dump.content,
|
2379 |
-
dump.title + '.zip',
|
2380 |
-
'application/zip'
|
2381 |
-
);
|
2382 |
-
$('#extension-notification-modal').modal('hide');
|
2383 |
-
});
|
2384 |
-
|
2385 |
-
if(/(Version)\/(\d+)\.(\d+)(?:\.(\d+))?.*Safari\//.test(navigator.userAgent)) {
|
2386 |
-
$('#safari-download-notification').removeClass('hidden');
|
2387 |
-
}
|
2388 |
-
}
|
2389 |
-
}
|
2390 |
-
|
2391 |
-
aam.addHook('init', initialize);
|
2392 |
-
|
2393 |
-
})(jQuery);
|
2394 |
-
|
2395 |
-
|
2396 |
-
/**
|
2397 |
-
* Utilities Interface
|
2398 |
-
*
|
2399 |
-
* @param {type} $
|
2400 |
-
*
|
2401 |
-
* @returns {undefined}
|
2402 |
-
*/
|
2403 |
-
(function ($) {
|
2404 |
-
|
2405 |
-
/**
|
2406 |
-
*
|
2407 |
-
* @param {type} param
|
2408 |
-
* @param {type} value
|
2409 |
-
* @returns {undefined}
|
2410 |
-
*/
|
2411 |
-
function save(param, value) {
|
2412 |
-
$.ajax(aamLocal.ajaxurl, {
|
2413 |
-
type: 'POST',
|
2414 |
-
dataType: 'json',
|
2415 |
-
data: {
|
2416 |
-
action: 'aam',
|
2417 |
-
sub_action: 'Utility.save',
|
2418 |
-
_ajax_nonce: aamLocal.nonce,
|
2419 |
-
param: param,
|
2420 |
-
value: value
|
2421 |
-
},
|
2422 |
-
error: function () {
|
2423 |
-
aam.notification('danger', aam.__('Application Error'));
|
2424 |
-
}
|
2425 |
-
});
|
2426 |
-
}
|
2427 |
-
|
2428 |
-
/**
|
2429 |
-
*
|
2430 |
-
* @returns {undefined}
|
2431 |
-
*/
|
2432 |
-
function initialize() {
|
2433 |
-
if ($('#utilities-content').length) {
|
2434 |
-
$('[data-toggle="toggle"]').bootstrapToggle();
|
2435 |
-
|
2436 |
-
$('input[type="checkbox"]', '#utilities-content').bind('change', function () {
|
2437 |
-
save($(this).attr('name'), ($(this).prop('checked') ? 1 : 0));
|
2438 |
-
});
|
2439 |
-
|
2440 |
-
$('input[type="text"]', '#utilities-content').bind('change', function() {
|
2441 |
-
save($(this).attr('name'), $(this).val());
|
2442 |
-
});
|
2443 |
-
|
2444 |
-
$('#clear-settings').bind('click', function () {
|
2445 |
-
$.ajax(aamLocal.ajaxurl, {
|
2446 |
-
type: 'POST',
|
2447 |
-
dataType: 'json',
|
2448 |
-
data: {
|
2449 |
-
action: 'aam',
|
2450 |
-
sub_action: 'Utility.clear',
|
2451 |
-
_ajax_nonce: aamLocal.nonce
|
2452 |
-
},
|
2453 |
-
beforeSend: function() {
|
2454 |
-
$('#clear-settings').prop('disabled', true);
|
2455 |
-
},
|
2456 |
-
success: function (response) {
|
2457 |
-
if (response.status === 'success') {
|
2458 |
-
location.reload();
|
2459 |
-
}
|
2460 |
-
},
|
2461 |
-
error: function () {
|
2462 |
-
aam.notification('danger', aam.__('Application Error'));
|
2463 |
-
},
|
2464 |
-
complete: function() {
|
2465 |
-
$('#clear-settings').prop('disabled', false);
|
2466 |
-
}
|
2467 |
-
});
|
2468 |
-
});
|
2469 |
-
|
2470 |
-
$('#clear-cache').bind('click', function () {
|
2471 |
-
$.ajax(aamLocal.ajaxurl, {
|
2472 |
-
type: 'POST',
|
2473 |
-
dataType: 'json',
|
2474 |
-
data: {
|
2475 |
-
action: 'aam',
|
2476 |
-
sub_action: 'Utility.clearCache',
|
2477 |
-
_ajax_nonce: aamLocal.nonce
|
2478 |
-
},
|
2479 |
-
beforeSend: function() {
|
2480 |
-
$('#clear-cache').prop('disabled', true);
|
2481 |
-
},
|
2482 |
-
success: function (response) {
|
2483 |
-
if (response.status === 'success') {
|
2484 |
-
location.reload();
|
2485 |
-
}
|
2486 |
-
},
|
2487 |
-
error: function () {
|
2488 |
-
aam.notification('danger', aam.__('Application Error'));
|
2489 |
-
},
|
2490 |
-
complete: function() {
|
2491 |
-
$('#clear-cache').prop('disabled', false);
|
2492 |
-
}
|
2493 |
-
});
|
2494 |
-
});
|
2495 |
-
|
2496 |
-
$('#export-aam').bind('click', function () {
|
2497 |
-
$.ajax(aamLocal.ajaxurl, {
|
2498 |
-
type: 'POST',
|
2499 |
-
dataType: 'json',
|
2500 |
-
data: {
|
2501 |
-
action: 'aam',
|
2502 |
-
sub_action: 'Utility.export',
|
2503 |
-
_ajax_nonce: aamLocal.nonce
|
2504 |
-
},
|
2505 |
-
beforeSend: function () {
|
2506 |
-
$('#export-aam').attr('data-lable', $('#export-aam').text());
|
2507 |
-
$('#export-aam').html('<i class="icon-spin4 animate-spin"></i>');
|
2508 |
-
},
|
2509 |
-
success: function(response) {
|
2510 |
-
if (response.status === 'success') {
|
2511 |
-
download(
|
2512 |
-
'data:text/plain;base64,' + response.content,
|
2513 |
-
'aam-export.json',
|
2514 |
-
'text/plain'
|
2515 |
-
);
|
2516 |
-
}
|
2517 |
-
},
|
2518 |
-
error: function () {
|
2519 |
-
aam.notification('danger', aam.__('Application Error'));
|
2520 |
-
},
|
2521 |
-
complete: function () {
|
2522 |
-
$('#export-aam').html($('#export-aam').attr('data-lable'));
|
2523 |
-
}
|
2524 |
-
});
|
2525 |
-
});
|
2526 |
-
|
2527 |
-
$('#import-aam').bind('click', function () {
|
2528 |
-
if (typeof FileReader !== 'undefined') {
|
2529 |
-
$('#aam-import-file').trigger('click');
|
2530 |
-
} else {
|
2531 |
-
aam.notification('danger', 'Your browser does not support FileReader functionality');
|
2532 |
-
}
|
2533 |
-
});
|
2534 |
-
|
2535 |
-
$('#aam-import-file').bind('change', function () {
|
2536 |
-
var file = $(this)[0].files[0];
|
2537 |
-
var json = null;
|
2538 |
-
|
2539 |
-
var reader = new FileReader();
|
2540 |
-
reader.onload = function(e) {
|
2541 |
-
json = reader.result;
|
2542 |
-
|
2543 |
-
try {
|
2544 |
-
//validate the content
|
2545 |
-
var loaded = JSON.parse(json);
|
2546 |
-
if (loaded.plugin && loaded.plugin == 'advanced-access-manager') {
|
2547 |
-
$.ajax(aamLocal.ajaxurl, {
|
2548 |
-
type: 'POST',
|
2549 |
-
dataType: 'json',
|
2550 |
-
data: {
|
2551 |
-
action: 'aam',
|
2552 |
-
sub_action: 'Utility.import',
|
2553 |
-
_ajax_nonce: aamLocal.nonce,
|
2554 |
-
json: json
|
2555 |
-
},
|
2556 |
-
beforeSend: function () {
|
2557 |
-
$('#import-aam').attr('data-lable', $('#import-aam').text());
|
2558 |
-
$('#import-aam').html('<i class="icon-spin4 animate-spin"></i>');
|
2559 |
-
},
|
2560 |
-
success: function(response) {
|
2561 |
-
if (response.status === 'success') {
|
2562 |
-
aam.notification('success', 'Data Imported Successfully');
|
2563 |
-
// location.reload();
|
2564 |
-
} else {
|
2565 |
-
aam.notification('danger', aam.__('Invalid data format'));
|
2566 |
-
}
|
2567 |
-
},
|
2568 |
-
error: function () {
|
2569 |
-
aam.notification('danger', aam.__('Application Error'));
|
2570 |
-
},
|
2571 |
-
complete: function () {
|
2572 |
-
$('#import-aam').html($('#import-aam').attr('data-lable'));
|
2573 |
-
}
|
2574 |
-
});
|
2575 |
-
} else {
|
2576 |
-
throw 'Invalid format';
|
2577 |
-
}
|
2578 |
-
} catch (e) {
|
2579 |
-
aam.notification('danger', 'Invalid file format');
|
2580 |
-
}
|
2581 |
-
};
|
2582 |
-
reader.readAsText(file);
|
2583 |
-
|
2584 |
-
});
|
2585 |
-
}
|
2586 |
-
}
|
2587 |
-
|
2588 |
-
aam.addHook('init', initialize);
|
2589 |
-
|
2590 |
-
})(jQuery);
|
2591 |
-
|
2592 |
-
/**
|
2593 |
-
* Main Panel Interface
|
2594 |
-
*
|
2595 |
-
* @param {jQuery} $
|
2596 |
-
*
|
2597 |
-
* @returns {void}
|
2598 |
-
*/
|
2599 |
-
(function ($) {
|
2600 |
-
|
2601 |
-
/**
|
2602 |
-
*
|
2603 |
-
* @returns {undefined}
|
2604 |
-
*/
|
2605 |
-
function initializeMenu() {
|
2606 |
-
//initialize the menu switch
|
2607 |
-
$('li', '#feature-list').each(function () {
|
2608 |
-
$(this).bind('click', function () {
|
2609 |
-
$('.aam-feature').removeClass('active');
|
2610 |
-
//highlight active feature
|
2611 |
-
$('li', '#feature-list').removeClass('active');
|
2612 |
-
$(this).addClass('active');
|
2613 |
-
//show feature content
|
2614 |
-
$('#' + $(this).data('feature') + '-content').addClass('active');
|
2615 |
-
location.hash = $(this).data('feature');
|
2616 |
-
//trigger hook
|
2617 |
-
aam.triggerHook('menu-feature-click', $(this).data('feature'));
|
2618 |
-
});
|
2619 |
-
});
|
2620 |
-
}
|
2621 |
-
|
2622 |
-
/**
|
2623 |
-
*
|
2624 |
-
* @returns {undefined}
|
2625 |
-
*/
|
2626 |
-
aam.fetchContent = function () {
|
2627 |
-
//referred object ID like post, page or any custom post type
|
2628 |
-
var object = window.location.search.match(/&oid\=([^&]*)/);
|
2629 |
-
var type = window.location.search.match(/&otype\=([^&]*)/);
|
2630 |
-
|
2631 |
-
$.ajax(aamLocal.url.site, {
|
2632 |
-
type: 'POST',
|
2633 |
-
dataType: 'html',
|
2634 |
-
data: {
|
2635 |
-
action: 'aamc',
|
2636 |
-
_ajax_nonce: aamLocal.nonce,
|
2637 |
-
subject: this.getSubject().type,
|
2638 |
-
subjectId: this.getSubject().id,
|
2639 |
-
oid: object ? object[1] : null,
|
2640 |
-
otype: type ? type[1] : null
|
2641 |
-
},
|
2642 |
-
beforeSend: function () {
|
2643 |
-
var loader = $('<div/>', {'class': 'aam-loading'}).html(
|
2644 |
-
'<i class="icon-spin4 animate-spin"></i>'
|
2645 |
-
);
|
2646 |
-
$('#aam-content').html(loader);
|
2647 |
-
},
|
2648 |
-
success: function (response) {
|
2649 |
-
$('#aam-content').html(response);
|
2650 |
-
//init menu
|
2651 |
-
initializeMenu();
|
2652 |
-
//trigger initialization hook
|
2653 |
-
aam.triggerHook('init');
|
2654 |
-
//activate one of the menu items
|
2655 |
-
var item = $('li:eq(0)', '#feature-list');
|
2656 |
-
|
2657 |
-
if (location.hash !== '') {
|
2658 |
-
var hash = location.hash.substr(1);
|
2659 |
-
if ($('li[data-feature="' + hash + '"]', '#feature-list').length) {
|
2660 |
-
item = $('li[data-feature="' + hash + '"]', '#feature-list');
|
2661 |
-
}
|
2662 |
-
}
|
2663 |
-
|
2664 |
-
item.trigger('click');
|
2665 |
-
}
|
2666 |
-
});
|
2667 |
-
};
|
2668 |
-
|
2669 |
-
aam.fetchContent(); //fetch default AAM content
|
2670 |
-
|
2671 |
-
})(jQuery);
|
2672 |
-
|
2673 |
-
/**
|
2674 | <