User Role Editor - Version 4.60

Version Description

Download this release

Release Info

Developer shinephp
Plugin Icon 128x128 User Role Editor
Version 4.60
Comparing to
See all releases

Code changes from version 4.59.1 to 4.60

changelog.txt CHANGED
@@ -1,5 +1,17 @@
1
  CHANGES LOG (full version).
2
  ===========================
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
  = [4.59] 02.04.2021 =
5
  * Update: PHP constant URE_WP_ADMIN_URL was replaced with direct 'admin_url()' call to respect the 'admin_url' filter applied by the get_admin_url() WordPress API function.
1
  CHANGES LOG (full version).
2
  ===========================
3
+ = [4.60] 24.06.2021 =
4
+ * New: Notification box was replaced with one based on the [jpillora/nofifyjs](https://notifyjs.jpillora.com/) jQuery plugin. It does not move down page content. It disappears automatically after 5 seconds. Click on it to remove it manually.
5
+ * Fix: "Add capability" shows warning styled notification when needed (invalid characters, etc.) instead of a successful one.
6
+ * Fix: Capabilities group uncheck and revert selection is blocked for the administrator role to exclude accident deletion of permissions from it.
7
+
8
+ = [4.59.1] 11.05.2021 =
9
+ * New: Multisite: When update role at the main site with "Apply to all sites" option and PHP constant URE_MULTISITE_DIRECT_UPDATE === 1 (update roles directly in database, not via WordPress API),
10
+ * URE overwrites all subsite roles with roles from the main site. It's possible now to leave selected role(s) for selected subsite(s) unchanged: add filter 'ure_network_update_leave_roles' and
11
+ * return from it the array like this one - array( (int) blog_id => array('role_id1', 'role_id2', ... );
12
+ * Update: "Other roles" section at user profile is available now only for users with 'promote_users' capability.
13
+ * Update: Notice at the top of URE page about action result is not removed automatically after 7 seconds as earlier.
14
+ * Update: 'ure_sort_wp_roles_list' filter accepts these values for the single input parameter: false - leave roles list as it is; true, 'id' - sort roles list by role ID; 'name' - sort roles by role name.
15
 
16
  = [4.59] 02.04.2021 =
17
  * Update: PHP constant URE_WP_ADMIN_URL was replaced with direct 'admin_url()' call to respect the 'admin_url' filter applied by the get_admin_url() WordPress API function.
includes/classes/ajax-processor.php CHANGED
@@ -115,21 +115,20 @@ class URE_Ajax_Processor {
115
 
116
  protected function add_capability() {
117
 
118
- $notification = URE_Capability::add( 'role' );
119
  $editor = URE_Editor::get_instance();
120
  $editor->init1();
121
  $message = $editor->init_current_role_name();
122
- if (empty( $message ) ) {
123
  $view = new URE_View();
124
  $html = $view->_show_capabilities( true, true );
125
- $result = 'success';
126
  } else {
127
  $html = '';
128
- $result = 'error';
129
- $notification = $message;
130
  }
131
 
132
- $answer = array('result'=>'success', 'html'=>$html, 'message'=>$notification);
133
 
134
  return $answer;
135
  }
115
 
116
  protected function add_capability() {
117
 
118
+ $response = URE_Capability::add( 'role' );
119
  $editor = URE_Editor::get_instance();
120
  $editor->init1();
121
  $message = $editor->init_current_role_name();
122
+ if ( empty( $message ) ) {
123
  $view = new URE_View();
124
  $html = $view->_show_capabilities( true, true );
 
125
  } else {
126
  $html = '';
127
+ $response['result'] = 'error';
128
+ $response['message'] = $message;
129
  }
130
 
131
+ $answer = array('result'=>$response['result'], 'html'=>$html, 'message'=>$response['message']);
132
 
133
  return $answer;
134
  }
includes/classes/capability.php CHANGED
@@ -75,33 +75,38 @@ class URE_Capability {
75
  public static function add( $ure_object ) {
76
  global $wp_roles;
77
 
 
78
  if ( !current_user_can( 'ure_create_capabilities' ) ) {
79
- return esc_html__( 'Insufficient permissions to work with User Role Editor', 'user-role-editor' );
 
80
  }
81
 
82
  $mess = '';
83
- if (!isset($_POST['capability_id']) || empty($_POST['capability_id'])) {
84
- return esc_html__( 'Wrong Request', 'user-role-editor' );
 
85
  }
86
 
87
  $data = self::validate( $_POST['capability_id'] );
88
  if ( !$data['result'] ) {
89
- return $data['message'];
 
90
  }
91
 
92
  $cap_id = $data['cap_id'];
93
  $lib = URE_Lib::get_instance();
94
  $full_capabilities = $lib->init_full_capabilities( $ure_object );
95
  if ( !isset( $full_capabilities[$cap_id] ) ) {
96
- $admin_role = $lib->get_admin_role();
97
  $wp_roles->use_db = true;
98
  $wp_roles->add_cap( $admin_role, $cap_id );
99
- $mess = sprintf( esc_html__( 'Capability %s was added successfully', 'user-role-editor' ), $cap_id );
 
100
  } else {
101
- $mess = sprintf( esc_html__( 'Capability %s exists already', 'user-role-editor' ), $cap_id );
102
  }
103
 
104
- return $mess;
105
  }
106
  // end of add()
107
 
75
  public static function add( $ure_object ) {
76
  global $wp_roles;
77
 
78
+ $response = array('result'=>'error', 'capability_id'=>'', 'html'=>'', 'message'=>'');
79
  if ( !current_user_can( 'ure_create_capabilities' ) ) {
80
+ $response['message'] = esc_html__( 'Insufficient permissions to work with User Role Editor', 'user-role-editor' );
81
+ return $response;
82
  }
83
 
84
  $mess = '';
85
+ if ( !isset( $_POST['capability_id'] ) || empty( $_POST['capability_id'] ) ) {
86
+ $response['message'] = esc_html__( 'Wrong Request', 'user-role-editor' );
87
+ return $response;
88
  }
89
 
90
  $data = self::validate( $_POST['capability_id'] );
91
  if ( !$data['result'] ) {
92
+ $response['message'] = $data['message'];
93
+ return $response;
94
  }
95
 
96
  $cap_id = $data['cap_id'];
97
  $lib = URE_Lib::get_instance();
98
  $full_capabilities = $lib->init_full_capabilities( $ure_object );
99
  if ( !isset( $full_capabilities[$cap_id] ) ) {
100
+ $admin_role = $lib->get_admin_role();
101
  $wp_roles->use_db = true;
102
  $wp_roles->add_cap( $admin_role, $cap_id );
103
+ $response['result'] = 'success';
104
+ $response['message'] = sprintf( esc_html__( 'Capability %s was added successfully', 'user-role-editor' ), $cap_id );
105
  } else {
106
+ $response['message'] = sprintf( esc_html__( 'Capability %s exists already', 'user-role-editor' ), $cap_id );
107
  }
108
 
109
+ return $response;
110
  }
111
  // end of add()
112
 
includes/classes/user-role-editor.php CHANGED
@@ -729,7 +729,10 @@ class User_Role_Editor {
729
  }
730
 
731
  wp_enqueue_script('jquery-ui-dialog', '', array('jquery-ui-core', 'jquery-ui-button', 'jquery'));
732
- wp_enqueue_script('jquery-ui-selectable', '', array('jquery-ui-core', 'jquery'));
 
 
 
733
  wp_register_script('ure', plugins_url('/js/ure.js', URE_PLUGIN_FULL_PATH ), array(), URE_VERSION );
734
  wp_enqueue_script('ure');
735
  wp_localize_script('ure', 'ure_data', array(
729
  }
730
 
731
  wp_enqueue_script('jquery-ui-dialog', '', array('jquery-ui-core', 'jquery-ui-button', 'jquery'));
732
+ wp_enqueue_script('jquery-ui-selectable', '', array('jquery-ui-core', 'jquery'));
733
+ wp_enqueue_script('notifyjs', plugins_url('/js/notify.min.js', URE_PLUGIN_FULL_PATH ), array(), URE_VERSION );
734
+ //wp_enqueue_script('notifyjs', plugins_url('/js/notify.js', URE_PLUGIN_FULL_PATH ), array(), URE_VERSION );
735
+
736
  wp_register_script('ure', plugins_url('/js/ure.js', URE_PLUGIN_FULL_PATH ), array(), URE_VERSION );
737
  wp_enqueue_script('ure');
738
  wp_localize_script('ure', 'ure_data', array(
js/notify.js ADDED
@@ -0,0 +1,625 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Notify.js - http://notifyjs.com/ Copyright (c) 2015 MIT */
2
+ (function (factory) {
3
+ // UMD start
4
+ // https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js
5
+ if (typeof define === 'function' && define.amd) {
6
+ // AMD. Register as an anonymous module.
7
+ define(['jquery'], factory);
8
+ } else if (typeof module === 'object' && module.exports) {
9
+ // Node/CommonJS
10
+ module.exports = function( root, jQuery ) {
11
+ if ( jQuery === undefined ) {
12
+ // require('jQuery') returns a factory that requires window to
13
+ // build a jQuery instance, we normalize how we use modules
14
+ // that require this pattern but the window provided is a noop
15
+ // if it's defined (how jquery works)
16
+ if ( typeof window !== 'undefined' ) {
17
+ jQuery = require('jquery');
18
+ }
19
+ else {
20
+ jQuery = require('jquery')(root);
21
+ }
22
+ }
23
+ factory(jQuery);
24
+ return jQuery;
25
+ };
26
+ } else {
27
+ // Browser globals
28
+ factory(jQuery);
29
+ }
30
+ }(function ($) {
31
+ //IE8 indexOf polyfill
32
+ var indexOf = [].indexOf || function(item) {
33
+ for (var i = 0, l = this.length; i < l; i++) {
34
+ if (i in this && this[i] === item) {
35
+ return i;
36
+ }
37
+ }
38
+ return -1;
39
+ };
40
+
41
+ var pluginName = "notify";
42
+ var pluginClassName = pluginName + "js";
43
+ var blankFieldName = pluginName + "!blank";
44
+
45
+ var positions = {
46
+ t: "top",
47
+ m: "middle",
48
+ b: "bottom",
49
+ l: "left",
50
+ c: "center",
51
+ r: "right"
52
+ };
53
+ var hAligns = ["l", "c", "r"];
54
+ var vAligns = ["t", "m", "b"];
55
+ var mainPositions = ["t", "b", "l", "r"];
56
+ var opposites = {
57
+ t: "b",
58
+ m: null,
59
+ b: "t",
60
+ l: "r",
61
+ c: null,
62
+ r: "l"
63
+ };
64
+
65
+ var parsePosition = function(str) {
66
+ var pos;
67
+ pos = [];
68
+ $.each(str.split(/\W+/), function(i, word) {
69
+ var w;
70
+ w = word.toLowerCase().charAt(0);
71
+ if (positions[w]) {
72
+ return pos.push(w);
73
+ }
74
+ });
75
+ return pos;
76
+ };
77
+
78
+ var styles = {};
79
+
80
+ var coreStyle = {
81
+ name: "core",
82
+ html: "<div class=\"" + pluginClassName + "-wrapper\">\n <div class=\"" + pluginClassName + "-arrow\"></div>\n <div class=\"" + pluginClassName + "-container\"></div>\n</div>",
83
+ css: "." + pluginClassName + "-corner {\n position: fixed;\n margin: 5px;\n z-index: 1000000;\n}\n\n." + pluginClassName + "-corner ." + pluginClassName + "-wrapper,\n." + pluginClassName + "-corner ." + pluginClassName + "-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n." + pluginClassName + "-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n." + pluginClassName + "-container {\n display: none;\n z-index: 1;\n position: absolute;\n}\n\n." + pluginClassName + "-hidable {\n cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n position: relative;\n}\n\n." + pluginClassName + "-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"
84
+ };
85
+
86
+ var stylePrefixes = {
87
+ "border-radius": ["-webkit-", "-moz-"]
88
+ };
89
+
90
+ var getStyle = function(name) {
91
+ return styles[name];
92
+ };
93
+
94
+ var removeStyle = function(name) {
95
+ if (!name) {
96
+ throw "Missing Style name";
97
+ }
98
+ if (styles[name]) {
99
+ delete styles[name];
100
+ }
101
+ };
102
+
103
+ var addStyle = function(name, def) {
104
+ if (!name) {
105
+ throw "Missing Style name";
106
+ }
107
+ if (!def) {
108
+ throw "Missing Style definition";
109
+ }
110
+ if (!def.html) {
111
+ throw "Missing Style HTML";
112
+ }
113
+ //remove existing style
114
+ var existing = styles[name];
115
+ if (existing && existing.cssElem) {
116
+ if (window.console) {
117
+ console.warn(pluginName + ": overwriting style '" + name + "'");
118
+ }
119
+ styles[name].cssElem.remove();
120
+ }
121
+ def.name = name;
122
+ styles[name] = def;
123
+ var cssText = "";
124
+ if (def.classes) {
125
+ $.each(def.classes, function(className, props) {
126
+ cssText += "." + pluginClassName + "-" + def.name + "-" + className + " {\n";
127
+ $.each(props, function(name, val) {
128
+ if (stylePrefixes[name]) {
129
+ $.each(stylePrefixes[name], function(i, prefix) {
130
+ return cssText += " " + prefix + name + ": " + val + ";\n";
131
+ });
132
+ }
133
+ return cssText += " " + name + ": " + val + ";\n";
134
+ });
135
+ return cssText += "}\n";
136
+ });
137
+ }
138
+ if (def.css) {
139
+ cssText += "/* styles for " + def.name + " */\n" + def.css;
140
+ }
141
+ if (cssText) {
142
+ def.cssElem = insertCSS(cssText);
143
+ def.cssElem.attr("id", "notify-" + def.name);
144
+ }
145
+ var fields = {};
146
+ var elem = $(def.html);
147
+ findFields("html", elem, fields);
148
+ findFields("text", elem, fields);
149
+ def.fields = fields;
150
+ };
151
+
152
+ var insertCSS = function(cssText) {
153
+ var e, elem, error;
154
+ elem = createElem("style");
155
+ elem.attr("type", 'text/css');
156
+ $("head").append(elem);
157
+ try {
158
+ elem.html(cssText);
159
+ } catch (_) {
160
+ elem[0].styleSheet.cssText = cssText;
161
+ }
162
+ return elem;
163
+ };
164
+
165
+ var findFields = function(type, elem, fields) {
166
+ var attr;
167
+ if (type !== "html") {
168
+ type = "text";
169
+ }
170
+ attr = "data-notify-" + type;
171
+ return find(elem, "[" + attr + "]").each(function() {
172
+ var name;
173
+ name = $(this).attr(attr);
174
+ if (!name) {
175
+ name = blankFieldName;
176
+ }
177
+ fields[name] = type;
178
+ });
179
+ };
180
+
181
+ var find = function(elem, selector) {
182
+ if (elem.is(selector)) {
183
+ return elem;
184
+ } else {
185
+ return elem.find(selector);
186
+ }
187
+ };
188
+
189
+ var pluginOptions = {
190
+ clickToHide: true,
191
+ autoHide: true,
192
+ autoHideDelay: 5000,
193
+ arrowShow: true,
194
+ arrowSize: 5,
195
+ breakNewLines: true,
196
+ elementPosition: "bottom",
197
+ globalPosition: "top right",
198
+ style: "bootstrap",
199
+ className: "error",
200
+ showAnimation: "slideDown",
201
+ showDuration: 400,
202
+ hideAnimation: "slideUp",
203
+ hideDuration: 200,
204
+ gap: 5
205
+ };
206
+
207
+ var inherit = function(a, b) {
208
+ var F;
209
+ F = function() {};
210
+ F.prototype = a;
211
+ return $.extend(true, new F(), b);
212
+ };
213
+
214
+ var defaults = function(opts) {
215
+ return $.extend(pluginOptions, opts);
216
+ };
217
+
218
+ var createElem = function(tag) {
219
+ return $("<" + tag + "></" + tag + ">");
220
+ };
221
+
222
+ var globalAnchors = {};
223
+
224
+ var getAnchorElement = function(element) {
225
+ var radios;
226
+ if (element.is('[type=radio]')) {
227
+ radios = element.parents('form:first').find('[type=radio]').filter(function(i, e) {
228
+ return $(e).attr("name") === element.attr("name");
229
+ });
230
+ element = radios.first();
231
+ }
232
+ return element;
233
+ };
234
+
235
+ var incr = function(obj, pos, val) {
236
+ var opp, temp;
237
+ if (typeof val === "string") {
238
+ val = parseInt(val, 10);
239
+ } else if (typeof val !== "number") {
240
+ return;
241
+ }
242
+ if (isNaN(val)) {
243
+ return;
244
+ }
245
+ opp = positions[opposites[pos.charAt(0)]];
246
+ temp = pos;
247
+ if (obj[opp] !== undefined) {
248
+ pos = positions[opp.charAt(0)];
249
+ val = -val;
250
+ }
251
+ if (obj[pos] === undefined) {
252
+ obj[pos] = val;
253
+ } else {
254
+ obj[pos] += val;
255
+ }
256
+ return null;
257
+ };
258
+
259
+ var realign = function(alignment, inner, outer) {
260
+ if (alignment === "l" || alignment === "t") {
261
+ return 0;
262
+ } else if (alignment === "c" || alignment === "m") {
263
+ return outer / 2 - inner / 2;
264
+ } else if (alignment === "r" || alignment === "b") {
265
+ return outer - inner;
266
+ }
267
+ throw "Invalid alignment";
268
+ };
269
+
270
+ var encode = function(text) {
271
+ encode.e = encode.e || createElem("div");
272
+ return encode.e.text(text).html();
273
+ };
274
+
275
+ function Notification(elem, data, options) {
276
+ if (typeof options === "string") {
277
+ options = {
278
+ className: options
279
+ };
280
+ }
281
+ this.options = inherit(pluginOptions, $.isPlainObject(options) ? options : {});
282
+ this.loadHTML();
283
+ this.wrapper = $(coreStyle.html);
284
+ if (this.options.clickToHide) {
285
+ this.wrapper.addClass(pluginClassName + "-hidable");
286
+ }
287
+ this.wrapper.data(pluginClassName, this);
288
+ this.arrow = this.wrapper.find("." + pluginClassName + "-arrow");
289
+ this.container = this.wrapper.find("." + pluginClassName + "-container");
290
+ this.container.append(this.userContainer);
291
+ if (elem && elem.length) {
292
+ this.elementType = elem.attr("type");
293
+ this.originalElement = elem;
294
+ this.elem = getAnchorElement(elem);
295
+ this.elem.data(pluginClassName, this);
296
+ this.elem.before(this.wrapper);
297
+ }
298
+ this.container.hide();
299
+ this.run(data);
300
+ }
301
+
302
+ Notification.prototype.loadHTML = function() {
303
+ var style;
304
+ style = this.getStyle();
305
+ this.userContainer = $(style.html);
306
+ this.userFields = style.fields;
307
+ };
308
+
309
+ Notification.prototype.show = function(show, userCallback) {
310
+ var args, callback, elems, fn, hidden;
311
+ callback = (function(_this) {
312
+ return function() {
313
+ if (!show && !_this.elem) {
314
+ _this.destroy();
315
+ }
316
+ if (userCallback) {
317
+ return userCallback();
318
+ }
319
+ };
320
+ })(this);
321
+ hidden = this.container.parent().parents(':hidden').length > 0;
322
+ elems = this.container.add(this.arrow);
323
+ args = [];
324
+ if (hidden && show) {
325
+ fn = "show";
326
+ } else if (hidden && !show) {
327
+ fn = "hide";
328
+ } else if (!hidden && show) {
329
+ fn = this.options.showAnimation;
330
+ args.push(this.options.showDuration);
331
+ } else if (!hidden && !show) {
332
+ fn = this.options.hideAnimation;
333
+ args.push(this.options.hideDuration);
334
+ } else {
335
+ return callback();
336
+ }
337
+ args.push(callback);
338
+ return elems[fn].apply(elems, args);
339
+ };
340
+
341
+ Notification.prototype.setGlobalPosition = function() {
342
+ var p = this.getPosition();
343
+ var pMain = p[0];
344
+ var pAlign = p[1];
345
+ var main = positions[pMain];
346
+ var align = positions[pAlign];
347
+ var key = pMain + "|" + pAlign;
348
+ var anchor = globalAnchors[key];
349
+ if (!anchor || !document.body.contains(anchor[0])) {
350
+ anchor = globalAnchors[key] = createElem("div");
351
+ var css = {};
352
+ css[main] = 0;
353
+ if (align === "middle") {
354
+ css.top = '45%';
355
+ } else if (align === "center") {
356
+ css.left = '45%';
357
+ } else {
358
+ css[align] = 0;
359
+ }
360
+ anchor.css(css).addClass(pluginClassName + "-corner");
361
+ $("body").append(anchor);
362
+ }
363
+ return anchor.prepend(this.wrapper);
364
+ };
365
+
366
+ Notification.prototype.setElementPosition = function() {
367
+ var arrowColor, arrowCss, arrowSize, color, contH, contW, css, elemH, elemIH, elemIW, elemPos, elemW, gap, j, k, len, len1, mainFull, margin, opp, oppFull, pAlign, pArrow, pMain, pos, posFull, position, ref, wrapPos;
368
+ position = this.getPosition();
369
+ pMain = position[0];
370
+ pAlign = position[1];
371
+ pArrow = position[2];
372
+ elemPos = this.elem.position();
373
+ elemH = this.elem.outerHeight();
374
+ elemW = this.elem.outerWidth();
375
+ elemIH = this.elem.innerHeight();
376
+ elemIW = this.elem.innerWidth();
377
+ wrapPos = this.wrapper.position();
378
+ contH = this.container.height();
379
+ contW = this.container.width();
380
+ mainFull = positions[pMain];
381
+ opp = opposites[pMain];
382
+ oppFull = positions[opp];
383
+ css = {};
384
+ css[oppFull] = pMain === "b" ? elemH : pMain === "r" ? elemW : 0;
385
+ incr(css, "top", elemPos.top - wrapPos.top);
386
+ incr(css, "left", elemPos.left - wrapPos.left);
387
+ ref = ["top", "left"];
388
+ for (j = 0, len = ref.length; j < len; j++) {
389
+ pos = ref[j];
390
+ margin = parseInt(this.elem.css("margin-" + pos), 10);
391
+ if (margin) {
392
+ incr(css, pos, margin);
393
+ }
394
+ }
395
+ gap = Math.max(0, this.options.gap - (this.options.arrowShow ? arrowSize : 0));
396
+ incr(css, oppFull, gap);
397
+ if (!this.options.arrowShow) {
398
+ this.arrow.hide();
399
+ } else {
400
+ arrowSize = this.options.arrowSize;
401
+ arrowCss = $.extend({}, css);
402
+ arrowColor = this.userContainer.css("border-color") || this.userContainer.css("border-top-color") || this.userContainer.css("background-color") || "white";
403
+ for (k = 0, len1 = mainPositions.length; k < len1; k++) {
404
+ pos = mainPositions[k];
405
+ posFull = positions[pos];
406
+ if (pos === opp) {
407
+ continue;
408
+ }
409
+ color = posFull === mainFull ? arrowColor : "transparent";
410
+ arrowCss["border-" + posFull] = arrowSize + "px solid " + color;
411
+ }
412
+ incr(css, positions[opp], arrowSize);
413
+ if (indexOf.call(mainPositions, pAlign) >= 0) {
414
+ incr(arrowCss, positions[pAlign], arrowSize * 2);
415
+ }
416
+ }
417
+ if (indexOf.call(vAligns, pMain) >= 0) {
418
+ incr(css, "left", realign(pAlign, contW, elemW));
419
+ if (arrowCss) {
420
+ incr(arrowCss, "left", realign(pAlign, arrowSize, elemIW));
421
+ }
422
+ } else if (indexOf.call(hAligns, pMain) >= 0) {
423
+ incr(css, "top", realign(pAlign, contH, elemH));
424
+ if (arrowCss) {
425
+ incr(arrowCss, "top", realign(pAlign, arrowSize, elemIH));
426
+ }
427
+ }
428
+ if (this.container.is(":visible")) {
429
+ css.display = "block";
430
+ }
431
+ this.container.removeAttr("style").css(css);
432
+ if (arrowCss) {
433
+ return this.arrow.removeAttr("style").css(arrowCss);
434
+ }
435
+ };
436
+
437
+ Notification.prototype.getPosition = function() {
438
+ var pos, ref, ref1, ref2, ref3, ref4, ref5, text;
439
+ text = this.options.position || (this.elem ? this.options.elementPosition : this.options.globalPosition);
440
+ pos = parsePosition(text);
441
+ if (pos.length === 0) {
442
+ pos[0] = "b";
443
+ }
444
+ if (ref = pos[0], indexOf.call(mainPositions, ref) < 0) {
445
+ throw "Must be one of [" + mainPositions + "]";
446
+ }
447
+ if (pos.length === 1 || ((ref1 = pos[0], indexOf.call(vAligns, ref1) >= 0) && (ref2 = pos[1], indexOf.call(hAligns, ref2) < 0)) || ((ref3 = pos[0], indexOf.call(hAligns, ref3) >= 0) && (ref4 = pos[1], indexOf.call(vAligns, ref4) < 0))) {
448
+ pos[1] = (ref5 = pos[0], indexOf.call(hAligns, ref5) >= 0) ? "m" : "l";
449
+ }
450
+ if (pos.length === 2) {
451
+ pos[2] = pos[1];
452
+ }
453
+ return pos;
454
+ };
455
+
456
+ Notification.prototype.getStyle = function(name) {
457
+ var style;
458
+ if (!name) {
459
+ name = this.options.style;
460
+ }
461
+ if (!name) {
462
+ name = "default";
463
+ }
464
+ style = styles[name];
465
+ if (!style) {
466
+ throw "Missing style: " + name;
467
+ }
468
+ return style;
469
+ };
470
+
471
+ Notification.prototype.updateClasses = function() {
472
+ var classes, style;
473
+ classes = ["base"];
474
+ if ($.isArray(this.options.className)) {
475
+ classes = classes.concat(this.options.className);
476
+ } else if (this.options.className) {
477
+ classes.push(this.options.className);
478
+ }
479
+ style = this.getStyle();
480
+ classes = $.map(classes, function(n) {
481
+ return pluginClassName + "-" + style.name + "-" + n;
482
+ }).join(" ");
483
+ return this.userContainer.attr("class", classes);
484
+ };
485
+
486
+ Notification.prototype.run = function(data, options) {
487
+ var d, datas, name, type, value;
488
+ if ($.isPlainObject(options)) {
489
+ $.extend(this.options, options);
490
+ } else if ($.type(options) === "string") {
491
+ this.options.className = options;
492
+ }
493
+ if (this.container && !data) {
494
+ this.show(false);
495
+ return;
496
+ } else if (!this.container && !data) {
497
+ return;
498
+ }
499
+ datas = {};
500
+ if ($.isPlainObject(data)) {
501
+ datas = data;
502
+ } else {
503
+ datas[blankFieldName] = data;
504
+ }
505
+ for (name in datas) {
506
+ d = datas[name];
507
+ type = this.userFields[name];
508
+ if (!type) {
509
+ continue;
510
+ }
511
+ if (type === "text") {
512
+ d = encode(d);
513
+ if (this.options.breakNewLines) {
514
+ d = d.replace(/\n/g, '<br/>');
515
+ }
516
+ }
517
+ value = name === blankFieldName ? '' : '=' + name;
518
+ find(this.userContainer, "[data-notify-" + type + value + "]").html(d);
519
+ }
520
+ this.updateClasses();
521
+ if (this.elem) {
522
+ this.setElementPosition();
523
+ } else {
524
+ this.setGlobalPosition();
525
+ }
526
+ this.show(true);
527
+ if (this.options.autoHide) {
528
+ clearTimeout(this.autohideTimer);
529
+ this.autohideTimer = setTimeout(this.show.bind(this, false), this.options.autoHideDelay);
530
+ }
531
+ };
532
+
533
+ Notification.prototype.destroy = function() {
534
+ this.wrapper.data(pluginClassName, null);
535
+ this.wrapper.remove();
536
+ };
537
+
538
+ $[pluginName] = function(elem, data, options) {
539
+ if ((elem && elem.nodeName) || elem.jquery) {
540
+ $(elem)[pluginName](data, options);
541
+ } else {
542
+ options = data;
543
+ data = elem;
544
+ new Notification(null, data, options);
545
+ }
546
+ return elem;
547
+ };
548
+
549
+ $.fn[pluginName] = function(data, options) {
550
+ $(this).each(function() {
551
+ var prev = getAnchorElement($(this)).data(pluginClassName);
552
+ if (prev) {
553
+ prev.destroy();
554
+ }
555
+ var curr = new Notification($(this), data, options);
556
+ });
557
+ return this;
558
+ };
559
+
560
+ $.extend($[pluginName], {
561
+ defaults: defaults,
562
+ addStyle: addStyle,
563
+ removeStyle: removeStyle,
564
+ pluginOptions: pluginOptions,
565
+ getStyle: getStyle,
566
+ insertCSS: insertCSS
567
+ });
568
+
569
+ //always include the default bootstrap style
570
+ addStyle("bootstrap", {
571
+ html: "<div>\n<span data-notify-text></span>\n</div>",
572
+ classes: {
573
+ base: {
574
+ "font-weight": "bold",
575
+ "padding": "8px 15px 8px 14px",
576
+ "text-shadow": "0 1px 0 rgba(255, 255, 255, 0.5)",
577
+ "background-color": "#fcf8e3",
578
+ "border": "1px solid #fbeed5",
579
+ "border-radius": "4px",
580
+ "white-space": "nowrap",
581
+ "padding-left": "25px",
582
+ "background-repeat": "no-repeat",
583
+ "background-position": "3px 7px"
584
+ },
585
+ error: {
586
+ "color": "#B94A48",
587
+ "background-color": "#F2DEDE",
588
+ "border-color": "#EED3D7",
589
+ "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=)"
590
+ },
591
+ success: {
592
+ "color": "#468847",
593
+ "background-color": "#DFF0D8",
594
+ "border-color": "#D6E9C6",
595
+ "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAutJREFUeNq0lctPE0Ecx38zu/RFS1EryqtgJFA08YCiMZIAQQ4eRG8eDGdPJiYeTIwHTfwPiAcvXIwXLwoXPaDxkWgQ6islKlJLSQWLUraPLTv7Gme32zoF9KSTfLO7v53vZ3d/M7/fIth+IO6INt2jjoA7bjHCJoAlzCRw59YwHYjBnfMPqAKWQYKjGkfCJqAF0xwZjipQtA3MxeSG87VhOOYegVrUCy7UZM9S6TLIdAamySTclZdYhFhRHloGYg7mgZv1Zzztvgud7V1tbQ2twYA34LJmF4p5dXF1KTufnE+SxeJtuCZNsLDCQU0+RyKTF27Unw101l8e6hns3u0PBalORVVVkcaEKBJDgV3+cGM4tKKmI+ohlIGnygKX00rSBfszz/n2uXv81wd6+rt1orsZCHRdr1Imk2F2Kob3hutSxW8thsd8AXNaln9D7CTfA6O+0UgkMuwVvEFFUbbAcrkcTA8+AtOk8E6KiQiDmMFSDqZItAzEVQviRkdDdaFgPp8HSZKAEAL5Qh7Sq2lIJBJwv2scUqkUnKoZgNhcDKhKg5aH+1IkcouCAdFGAQsuWZYhOjwFHQ96oagWgRoUov1T9kRBEODAwxM2QtEUl+Wp+Ln9VRo6BcMw4ErHRYjH4/B26AlQoQQTRdHWwcd9AH57+UAXddvDD37DmrBBV34WfqiXPl61g+vr6xA9zsGeM9gOdsNXkgpEtTwVvwOklXLKm6+/p5ezwk4B+j6droBs2CsGa/gNs6RIxazl4Tc25mpTgw/apPR1LYlNRFAzgsOxkyXYLIM1V8NMwyAkJSctD1eGVKiq5wWjSPdjmeTkiKvVW4f2YPHWl3GAVq6ymcyCTgovM3FzyRiDe2TaKcEKsLpJvNHjZgPNqEtyi6mZIm4SRFyLMUsONSSdkPeFtY1n0mczoY3BHTLhwPRy9/lzcziCw9ACI+yql0VLzcGAZbYSM5CCSZg1/9oc/nn7+i8N9p/8An4JMADxhH+xHfuiKwAAAABJRU5ErkJggg==)"
596
+ },
597
+ info: {
598
+ "color": "#3A87AD",
599
+ "background-color": "#D9EDF7",
600
+ "border-color": "#BCE8F1",
601
+ "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYFAhkSsdes/QAAA8dJREFUOMvVlGtMW2UYx//POaWHXg6lLaW0ypAtw1UCgbniNOLcVOLmAjHZolOYlxmTGXVZdAnRfXQm+7SoU4mXaOaiZsEpC9FkiQs6Z6bdCnNYruM6KNBw6YWewzl9z+sHImEWv+vz7XmT95f/+3/+7wP814v+efDOV3/SoX3lHAA+6ODeUFfMfjOWMADgdk+eEKz0pF7aQdMAcOKLLjrcVMVX3xdWN29/GhYP7SvnP0cWfS8caSkfHZsPE9Fgnt02JNutQ0QYHB2dDz9/pKX8QjjuO9xUxd/66HdxTeCHZ3rojQObGQBcuNjfplkD3b19Y/6MrimSaKgSMmpGU5WevmE/swa6Oy73tQHA0Rdr2Mmv/6A1n9w9suQ7097Z9lM4FlTgTDrzZTu4StXVfpiI48rVcUDM5cmEksrFnHxfpTtU/3BFQzCQF/2bYVoNbH7zmItbSoMj40JSzmMyX5qDvriA7QdrIIpA+3cdsMpu0nXI8cV0MtKXCPZev+gCEM1S2NHPvWfP/hL+7FSr3+0p5RBEyhEN5JCKYr8XnASMT0xBNyzQGQeI8fjsGD39RMPk7se2bd5ZtTyoFYXftF6y37gx7NeUtJJOTFlAHDZLDuILU3j3+H5oOrD3yWbIztugaAzgnBKJuBLpGfQrS8wO4FZgV+c1IxaLgWVU0tMLEETCos4xMzEIv9cJXQcyagIwigDGwJgOAtHAwAhisQUjy0ORGERiELgG4iakkzo4MYAxcM5hAMi1WWG1yYCJIcMUaBkVRLdGeSU2995TLWzcUAzONJ7J6FBVBYIggMzmFbvdBV44Corg8vjhzC+EJEl8U1kJtgYrhCzgc/vvTwXKSib1paRFVRVORDAJAsw5FuTaJEhWM2SHB3mOAlhkNxwuLzeJsGwqWzf5TFNdKgtY5qHp6ZFf67Y/sAVadCaVY5YACDDb3Oi4NIjLnWMw2QthCBIsVhsUTU9tvXsjeq9+X1d75/KEs4LNOfcdf/+HthMnvwxOD0wmHaXr7ZItn2wuH2SnBzbZAbPJwpPx+VQuzcm7dgRCB57a1uBzUDRL4bfnI0RE0eaXd9W89mpjqHZnUI5Hh2l2dkZZUhOqpi2qSmpOmZ64Tuu9qlz/SEXo6MEHa3wOip46F1n7633eekV8ds8Wxjn37Wl63VVa+ej5oeEZ/82ZBETJjpJ1Rbij2D3Z/1trXUvLsblCK0XfOx0SX2kMsn9dX+d+7Kf6h8o4AIykuffjT8L20LU+w4AZd5VvEPY+XpWqLV327HR7DzXuDnD8r+ovkBehJ8i+y8YAAAAASUVORK5CYII=)"
602
+ },
603
+ warn: {
604
+ "color": "#C09853",
605
+ "background-color": "#FCF8E3",
606
+ "border-color": "#FBEED5",
607
+ "background-image": "url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABJlBMVEXr6eb/2oD/wi7/xjr/0mP/ykf/tQD/vBj/3o7/uQ//vyL/twebhgD/4pzX1K3z8e349vK6tHCilCWbiQymn0jGworr6dXQza3HxcKkn1vWvV/5uRfk4dXZ1bD18+/52YebiAmyr5S9mhCzrWq5t6ufjRH54aLs0oS+qD751XqPhAybhwXsujG3sm+Zk0PTwG6Shg+PhhObhwOPgQL4zV2nlyrf27uLfgCPhRHu7OmLgAafkyiWkD3l49ibiAfTs0C+lgCniwD4sgDJxqOilzDWowWFfAH08uebig6qpFHBvH/aw26FfQTQzsvy8OyEfz20r3jAvaKbhgG9q0nc2LbZxXanoUu/u5WSggCtp1anpJKdmFz/zlX/1nGJiYmuq5Dx7+sAAADoPUZSAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfdBgUBGhh4aah5AAAAlklEQVQY02NgoBIIE8EUcwn1FkIXM1Tj5dDUQhPU502Mi7XXQxGz5uVIjGOJUUUW81HnYEyMi2HVcUOICQZzMMYmxrEyMylJwgUt5BljWRLjmJm4pI1hYp5SQLGYxDgmLnZOVxuooClIDKgXKMbN5ggV1ACLJcaBxNgcoiGCBiZwdWxOETBDrTyEFey0jYJ4eHjMGWgEAIpRFRCUt08qAAAAAElFTkSuQmCC)"
608
+ }
609
+ }
610
+ });
611
+
612
+ $(function() {
613
+ insertCSS(coreStyle.css).attr("id", "core-notify");
614
+ $(document).on("click", "." + pluginClassName + "-hidable", function(e) {
615
+ $(this).trigger("notify-hide");
616
+ });
617
+ $(document).on("notify-hide", "." + pluginClassName + "-wrapper", function(e) {
618
+ var elem = $(this).data(pluginClassName);
619
+ if(elem) {
620
+ elem.show(false);
621
+ }
622
+ });
623
+ });
624
+
625
+ }));
js/notify.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(e){typeof define=="function"&&define.amd?define(["jquery"],e):typeof module=="object"&&module.exports?module.exports=function(t,n){return n===undefined&&(typeof window!="undefined"?n=require("jquery"):n=require("jquery")(t)),e(n),n}:e(jQuery)})(function(e){function A(t,n,i){typeof i=="string"&&(i={className:i}),this.options=E(w,e.isPlainObject(i)?i:{}),this.loadHTML(),this.wrapper=e(h.html),this.options.clickToHide&&this.wrapper.addClass(r+"-hidable"),this.wrapper.data(r,this),this.arrow=this.wrapper.find("."+r+"-arrow"),this.container=this.wrapper.find("."+r+"-container"),this.container.append(this.userContainer),t&&t.length&&(this.elementType=t.attr("type"),this.originalElement=t,this.elem=N(t),this.elem.data(r,this),this.elem.before(this.wrapper)),this.container.hide(),this.run(n)}var t=[].indexOf||function(e){for(var t=0,n=this.length;t<n;t++)if(t in this&&this[t]===e)return t;return-1},n="notify",r=n+"js",i=n+"!blank",s={t:"top",m:"middle",b:"bottom",l:"left",c:"center",r:"right"},o=["l","c","r"],u=["t","m","b"],a=["t","b","l","r"],f={t:"b",m:null,b:"t",l:"r",c:null,r:"l"},l=function(t){var n;return n=[],e.each(t.split(/\W+/),function(e,t){var r;r=t.toLowerCase().charAt(0);if(s[r])return n.push(r)}),n},c={},h={name:"core",html:'<div class="'+r+'-wrapper">\n <div class="'+r+'-arrow"></div>\n <div class="'+r+'-container"></div>\n</div>',css:"."+r+"-corner {\n position: fixed;\n margin: 5px;\n z-index: 1050;\n}\n\n."+r+"-corner ."+r+"-wrapper,\n."+r+"-corner ."+r+"-container {\n position: relative;\n display: block;\n height: inherit;\n width: inherit;\n margin: 3px;\n}\n\n."+r+"-wrapper {\n z-index: 1;\n position: absolute;\n display: inline-block;\n height: 0;\n width: 0;\n}\n\n."+r+"-container {\n display: none;\n z-index: 1;\n position: absolute;\n}\n\n."+r+"-hidable {\n cursor: pointer;\n}\n\n[data-notify-text],[data-notify-html] {\n position: relative;\n}\n\n."+r+"-arrow {\n position: absolute;\n z-index: 2;\n width: 0;\n height: 0;\n}"},p={"border-radius":["-webkit-","-moz-"]},d=function(e){return c[e]},v=function(e){if(!e)throw"Missing Style name";c[e]&&delete c[e]},m=function(t,i){if(!t)throw"Missing Style name";if(!i)throw"Missing Style definition";if(!i.html)throw"Missing Style HTML";var s=c[t];s&&s.cssElem&&(window.console&&console.warn(n+": overwriting style '"+t+"'"),c[t].cssElem.remove()),i.name=t,c[t]=i;var o="";i.classes&&e.each(i.classes,function(t,n){return o+="."+r+"-"+i.name+"-"+t+" {\n",e.each(n,function(t,n){return p[t]&&e.each(p[t],function(e,r){return o+=" "+r+t+": "+n+";\n"}),o+=" "+t+": "+n+";\n"}),o+="}\n"}),i.css&&(o+="/* styles for "+i.name+" */\n"+i.css),o&&(i.cssElem=g(o),i.cssElem.attr("id","notify-"+i.name));var u={},a=e(i.html);y("html",a,u),y("text",a,u),i.fields=u},g=function(t){var n,r,i;r=x("style"),r.attr("type","text/css"),e("head").append(r);try{r.html(t)}catch(s){r[0].styleSheet.cssText=t}return r},y=function(t,n,r){var s;return t!=="html"&&(t="text"),s="data-notify-"+t,b(n,"["+s+"]").each(function(){var n;n=e(this).attr(s),n||(n=i),r[n]=t})},b=function(e,t){return e.is(t)?e:e.find(t)},w={clickToHide:!0,autoHide:!0,autoHideDelay:5e3,arrowShow:!0,arrowSize:5,breakNewLines:!0,elementPosition:"bottom",globalPosition:"top right",style:"bootstrap",className:"error",showAnimation:"slideDown",showDuration:400,hideAnimation:"slideUp",hideDuration:200,gap:5},E=function(t,n){var r;return r=function(){},r.prototype=t,e.extend(!0,new r,n)},S=function(t){return e.extend(w,t)},x=function(t){return e("<"+t+"></"+t+">")},T={},N=function(t){var n;return t.is("[type=radio]")&&(n=t.parents("form:first").find("[type=radio]").filter(function(n,r){return e(r).attr("name")===t.attr("name")}),t=n.first()),t},C=function(e,t,n){var r,i;if(typeof n=="string")n=parseInt(n,10);else if(typeof n!="number")return;if(isNaN(n))return;return r=s[f[t.charAt(0)]],i=t,e[r]!==undefined&&(t=s[r.charAt(0)],n=-n),e[t]===undefined?e[t]=n:e[t]+=n,null},k=function(e,t,n){if(e==="l"||e==="t")return 0;if(e==="c"||e==="m")return n/2-t/2;if(e==="r"||e==="b")return n-t;throw"Invalid alignment"},L=function(e){return L.e=L.e||x("div"),L.e.text(e).html()};A.prototype.loadHTML=function(){var t;t=this.getStyle(),this.userContainer=e(t.html),this.userFields=t.fields},A.prototype.show=function(e,t){var n,r,i,s,o;r=function(n){return function(){!e&&!n.elem&&n.destroy();if(t)return t()}}(this),o=this.container.parent().parents(":hidden").length>0,i=this.container.add(this.arrow),n=[];if(o&&e)s="show";else if(o&&!e)s="hide";else if(!o&&e)s=this.options.showAnimation,n.push(this.options.showDuration);else{if(!!o||!!e)return r();s=this.options.hideAnimation,n.push(this.options.hideDuration)}return n.push(r),i[s].apply(i,n)},A.prototype.setGlobalPosition=function(){var t=this.getPosition(),n=t[0],i=t[1],o=s[n],u=s[i],a=n+"|"+i,f=T[a];if(!f||!document.body.contains(f[0])){f=T[a]=x("div");var l={};l[o]=0,u==="middle"?l.top="45%":u==="center"?l.left="45%":l[u]=0,f.css(l).addClass(r+"-corner"),e("body").append(f)}return f.prepend(this.wrapper)},A.prototype.setElementPosition=function(){var n,r,i,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N,L,A,O,M,_,D,P,H,B,j;H=this.getPosition(),_=H[0],O=H[1],M=H[2],g=this.elem.position(),d=this.elem.outerHeight(),y=this.elem.outerWidth(),v=this.elem.innerHeight(),m=this.elem.innerWidth(),j=this.wrapper.position(),c=this.container.height(),h=this.container.width(),T=s[_],L=f[_],A=s[L],p={},p[A]=_==="b"?d:_==="r"?y:0,C(p,"top",g.top-j.top),C(p,"left",g.left-j.left),B=["top","left"];for(w=0,S=B.length;w<S;w++)D=B[w],N=parseInt(this.elem.css("margin-"+D),10),N&&C(p,D,N);b=Math.max(0,this.options.gap-(this.options.arrowShow?i:0)),C(p,A,b);if(!this.options.arrowShow)this.arrow.hide();else{i=this.options.arrowSize,r=e.extend({},p),n=this.userContainer.css("border-color")||this.userContainer.css("border-top-color")||this.userContainer.css("background-color")||"white";for(E=0,x=a.length;E<x;E++){D=a[E],P=s[D];if(D===L)continue;l=P===T?n:"transparent",r["border-"+P]=i+"px solid "+l}C(p,s[L],i),t.call(a,O)>=0&&C(r,s[O],i*2)}t.call(u,_)>=0?(C(p,"left",k(O,h,y)),r&&C(r,"left",k(O,i,m))):t.call(o,_)>=0&&(C(p,"top",k(O,c,d)),r&&C(r,"top",k(O,i,v))),this.container.is(":visible")&&(p.display="block"),this.container.removeAttr("style").css(p);if(r)return this.arrow.removeAttr("style").css(r)},A.prototype.getPosition=function(){var e,n,r,i,s,f,c,h;h=this.options.position||(this.elem?this.options.elementPosition:this.options.globalPosition),e=l(h),e.length===0&&(e[0]="b");if(n=e[0],t.call(a,n)<0)throw"Must be one of ["+a+"]";if(e.length===1||(r=e[0],t.call(u,r)>=0)&&(i=e[1],t.call(o,i)<0)||(s=e[0],t.call(o,s)>=0)&&(f=e[1],t.call(u,f)<0))e[1]=(c=e[0],t.call(o,c)>=0)?"m":"l";return e.length===2&&(e[2]=e[1]),e},A.prototype.getStyle=function(e){var t;e||(e=this.options.style),e||(e="default"),t=c[e];if(!t)throw"Missing style: "+e;return t},A.prototype.updateClasses=function(){var t,n;return t=["base"],e.isArray(this.options.className)?t=t.concat(this.options.className):this.options.className&&t.push(this.options.className),n=this.getStyle(),t=e.map(t,function(e){return r+"-"+n.name+"-"+e}).join(" "),this.userContainer.attr("class",t)},A.prototype.run=function(t,n){var r,s,o,u,a;e.isPlainObject(n)?e.extend(this.options,n):e.type(n)==="string"&&(this.options.className=n);if(this.container&&!t){this.show(!1);return}if(!this.container&&!t)return;s={},e.isPlainObject(t)?s=t:s[i]=t;for(o in s){r=s[o],u=this.userFields[o];if(!u)continue;u==="text"&&(r=L(r),this.options.breakNewLines&&(r=r.replace(/\n/g,"<br/>"))),a=o===i?"":"="+o,b(this.userContainer,"[data-notify-"+u+a+"]").html(r)}this.updateClasses(),this.elem?this.setElementPosition():this.setGlobalPosition(),this.show(!0),this.options.autoHide&&(clearTimeout(this.autohideTimer),this.autohideTimer=setTimeout(this.show.bind(this,!1),this.options.autoHideDelay))},A.prototype.destroy=function(){this.wrapper.data(r,null),this.wrapper.remove()},e[n]=function(t,r,i){return t&&t.nodeName||t.jquery?e(t)[n](r,i):(i=r,r=t,new A(null,r,i)),t},e.fn[n]=function(t,n){return e(this).each(function(){var i=N(e(this)).data(r);i&&i.destroy();var s=new A(e(this),t,n)}),this},e.extend(e[n],{defaults:S,addStyle:m,removeStyle:v,pluginOptions:w,getStyle:d,insertCSS:g}),m("bootstrap",{html:"<div>\n<span data-notify-text></span>\n</div>",classes:{base:{"font-weight":"bold",padding:"8px 15px 8px 14px","text-shadow":"0 1px 0 rgba(255, 255, 255, 0.5)","background-color":"#fcf8e3",border:"1px solid #fbeed5","border-radius":"4px","white-space":"nowrap","padding-left":"25px","background-repeat":"no-repeat","background-position":"3px 7px"},error:{color:"#B94A48","background-color":"#F2DEDE","border-color":"#EED3D7","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAtRJREFUeNqkVc1u00AQHq+dOD+0poIQfkIjalW0SEGqRMuRnHos3DjwAH0ArlyQeANOOSMeAA5VjyBxKBQhgSpVUKKQNGloFdw4cWw2jtfMOna6JOUArDTazXi/b3dm55socPqQhFka++aHBsI8GsopRJERNFlY88FCEk9Yiwf8RhgRyaHFQpPHCDmZG5oX2ui2yilkcTT1AcDsbYC1NMAyOi7zTX2Agx7A9luAl88BauiiQ/cJaZQfIpAlngDcvZZMrl8vFPK5+XktrWlx3/ehZ5r9+t6e+WVnp1pxnNIjgBe4/6dAysQc8dsmHwPcW9C0h3fW1hans1ltwJhy0GxK7XZbUlMp5Ww2eyan6+ft/f2FAqXGK4CvQk5HueFz7D6GOZtIrK+srupdx1GRBBqNBtzc2AiMr7nPplRdKhb1q6q6zjFhrklEFOUutoQ50xcX86ZlqaZpQrfbBdu2R6/G19zX6XSgh6RX5ubyHCM8nqSID6ICrGiZjGYYxojEsiw4PDwMSL5VKsC8Yf4VRYFzMzMaxwjlJSlCyAQ9l0CW44PBADzXhe7xMdi9HtTrdYjFYkDQL0cn4Xdq2/EAE+InCnvADTf2eah4Sx9vExQjkqXT6aAERICMewd/UAp/IeYANM2joxt+q5VI+ieq2i0Wg3l6DNzHwTERPgo1ko7XBXj3vdlsT2F+UuhIhYkp7u7CarkcrFOCtR3H5JiwbAIeImjT/YQKKBtGjRFCU5IUgFRe7fF4cCNVIPMYo3VKqxwjyNAXNepuopyqnld602qVsfRpEkkz+GFL1wPj6ySXBpJtWVa5xlhpcyhBNwpZHmtX8AGgfIExo0ZpzkWVTBGiXCSEaHh62/PoR0p/vHaczxXGnj4bSo+G78lELU80h1uogBwWLf5YlsPmgDEd4M236xjm+8nm4IuE/9u+/PH2JXZfbwz4zw1WbO+SQPpXfwG/BBgAhCNZiSb/pOQAAAAASUVORK5CYII=)"},success:{color:"#468847","background-color":"#DFF0D8","border-color":"#D6E9C6","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAutJREFUeNq0lctPE0Ecx38zu/RFS1EryqtgJFA08YCiMZIAQQ4eRG8eDGdPJiYeTIwHTfwPiAcvXIwXLwoXPaDxkWgQ6islKlJLSQWLUraPLTv7Gme32zoF9KSTfLO7v53vZ3d/M7/fIth+IO6INt2jjoA7bjHCJoAlzCRw59YwHYjBnfMPqAKWQYKjGkfCJqAF0xwZjipQtA3MxeSG87VhOOYegVrUCy7UZM9S6TLIdAamySTclZdYhFhRHloGYg7mgZv1Zzztvgud7V1tbQ2twYA34LJmF4p5dXF1KTufnE+SxeJtuCZNsLDCQU0+RyKTF27Unw101l8e6hns3u0PBalORVVVkcaEKBJDgV3+cGM4tKKmI+ohlIGnygKX00rSBfszz/n2uXv81wd6+rt1orsZCHRdr1Imk2F2Kob3hutSxW8thsd8AXNaln9D7CTfA6O+0UgkMuwVvEFFUbbAcrkcTA8+AtOk8E6KiQiDmMFSDqZItAzEVQviRkdDdaFgPp8HSZKAEAL5Qh7Sq2lIJBJwv2scUqkUnKoZgNhcDKhKg5aH+1IkcouCAdFGAQsuWZYhOjwFHQ96oagWgRoUov1T9kRBEODAwxM2QtEUl+Wp+Ln9VRo6BcMw4ErHRYjH4/B26AlQoQQTRdHWwcd9AH57+UAXddvDD37DmrBBV34WfqiXPl61g+vr6xA9zsGeM9gOdsNXkgpEtTwVvwOklXLKm6+/p5ezwk4B+j6droBs2CsGa/gNs6RIxazl4Tc25mpTgw/apPR1LYlNRFAzgsOxkyXYLIM1V8NMwyAkJSctD1eGVKiq5wWjSPdjmeTkiKvVW4f2YPHWl3GAVq6ymcyCTgovM3FzyRiDe2TaKcEKsLpJvNHjZgPNqEtyi6mZIm4SRFyLMUsONSSdkPeFtY1n0mczoY3BHTLhwPRy9/lzcziCw9ACI+yql0VLzcGAZbYSM5CCSZg1/9oc/nn7+i8N9p/8An4JMADxhH+xHfuiKwAAAABJRU5ErkJggg==)"},info:{color:"#3A87AD","background-color":"#D9EDF7","border-color":"#BCE8F1","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH3QYFAhkSsdes/QAAA8dJREFUOMvVlGtMW2UYx//POaWHXg6lLaW0ypAtw1UCgbniNOLcVOLmAjHZolOYlxmTGXVZdAnRfXQm+7SoU4mXaOaiZsEpC9FkiQs6Z6bdCnNYruM6KNBw6YWewzl9z+sHImEWv+vz7XmT95f/+3/+7wP814v+efDOV3/SoX3lHAA+6ODeUFfMfjOWMADgdk+eEKz0pF7aQdMAcOKLLjrcVMVX3xdWN29/GhYP7SvnP0cWfS8caSkfHZsPE9Fgnt02JNutQ0QYHB2dDz9/pKX8QjjuO9xUxd/66HdxTeCHZ3rojQObGQBcuNjfplkD3b19Y/6MrimSaKgSMmpGU5WevmE/swa6Oy73tQHA0Rdr2Mmv/6A1n9w9suQ7097Z9lM4FlTgTDrzZTu4StXVfpiI48rVcUDM5cmEksrFnHxfpTtU/3BFQzCQF/2bYVoNbH7zmItbSoMj40JSzmMyX5qDvriA7QdrIIpA+3cdsMpu0nXI8cV0MtKXCPZev+gCEM1S2NHPvWfP/hL+7FSr3+0p5RBEyhEN5JCKYr8XnASMT0xBNyzQGQeI8fjsGD39RMPk7se2bd5ZtTyoFYXftF6y37gx7NeUtJJOTFlAHDZLDuILU3j3+H5oOrD3yWbIztugaAzgnBKJuBLpGfQrS8wO4FZgV+c1IxaLgWVU0tMLEETCos4xMzEIv9cJXQcyagIwigDGwJgOAtHAwAhisQUjy0ORGERiELgG4iakkzo4MYAxcM5hAMi1WWG1yYCJIcMUaBkVRLdGeSU2995TLWzcUAzONJ7J6FBVBYIggMzmFbvdBV44Corg8vjhzC+EJEl8U1kJtgYrhCzgc/vvTwXKSib1paRFVRVORDAJAsw5FuTaJEhWM2SHB3mOAlhkNxwuLzeJsGwqWzf5TFNdKgtY5qHp6ZFf67Y/sAVadCaVY5YACDDb3Oi4NIjLnWMw2QthCBIsVhsUTU9tvXsjeq9+X1d75/KEs4LNOfcdf/+HthMnvwxOD0wmHaXr7ZItn2wuH2SnBzbZAbPJwpPx+VQuzcm7dgRCB57a1uBzUDRL4bfnI0RE0eaXd9W89mpjqHZnUI5Hh2l2dkZZUhOqpi2qSmpOmZ64Tuu9qlz/SEXo6MEHa3wOip46F1n7633eekV8ds8Wxjn37Wl63VVa+ej5oeEZ/82ZBETJjpJ1Rbij2D3Z/1trXUvLsblCK0XfOx0SX2kMsn9dX+d+7Kf6h8o4AIykuffjT8L20LU+w4AZd5VvEPY+XpWqLV327HR7DzXuDnD8r+ovkBehJ8i+y8YAAAAASUVORK5CYII=)"},warn:{color:"#C09853","background-color":"#FCF8E3","border-color":"#FBEED5","background-image":"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAMAAAC6V+0/AAABJlBMVEXr6eb/2oD/wi7/xjr/0mP/ykf/tQD/vBj/3o7/uQ//vyL/twebhgD/4pzX1K3z8e349vK6tHCilCWbiQymn0jGworr6dXQza3HxcKkn1vWvV/5uRfk4dXZ1bD18+/52YebiAmyr5S9mhCzrWq5t6ufjRH54aLs0oS+qD751XqPhAybhwXsujG3sm+Zk0PTwG6Shg+PhhObhwOPgQL4zV2nlyrf27uLfgCPhRHu7OmLgAafkyiWkD3l49ibiAfTs0C+lgCniwD4sgDJxqOilzDWowWFfAH08uebig6qpFHBvH/aw26FfQTQzsvy8OyEfz20r3jAvaKbhgG9q0nc2LbZxXanoUu/u5WSggCtp1anpJKdmFz/zlX/1nGJiYmuq5Dx7+sAAADoPUZSAAAAAXRSTlMAQObYZgAAAAFiS0dEAIgFHUgAAAAJcEhZcwAACxMAAAsTAQCanBgAAAAHdElNRQfdBgUBGhh4aah5AAAAlklEQVQY02NgoBIIE8EUcwn1FkIXM1Tj5dDUQhPU502Mi7XXQxGz5uVIjGOJUUUW81HnYEyMi2HVcUOICQZzMMYmxrEyMylJwgUt5BljWRLjmJm4pI1hYp5SQLGYxDgmLnZOVxuooClIDKgXKMbN5ggV1ACLJcaBxNgcoiGCBiZwdWxOETBDrTyEFey0jYJ4eHjMGWgEAIpRFRCUt08qAAAAAElFTkSuQmCC)"}}}),e(function(){g(h.css).attr("id","core-notify"),e(document).on("click","."+r+"-hidable",function(t){e(this).trigger("notify-hide")}),e(document).on("notify-hide","."+r+"-wrapper",function(t){var n=e(this).data(r);n&&n.show(!1)})})})
js/ure.js CHANGED
@@ -22,7 +22,7 @@
22
 
23
 
24
  jQuery(function() {
25
-
26
  jQuery( '#ure_add_role' ).button({
27
  label: ure_data.add_role
28
  }).on('click', (function ( event ) {
@@ -65,7 +65,7 @@ jQuery(function() {
65
  }));
66
 
67
 
68
-
69
  if ( jQuery('#ure_select_all_caps').length>0 ) {
70
  jQuery('#ure_select_all_caps').on('click', ( ure_main.auto_select_caps ) );
71
  }
@@ -81,7 +81,11 @@ jQuery(function() {
81
  });
82
  ure_main.select_selectable_element( jQuery('#ure_caps_groups_list'), jQuery('#ure_caps_group_all') );
83
  jQuery('#granted_only').on('click', ( ure_main.show_granted_caps_only ) );
84
-
 
 
 
 
85
  });
86
 
87
 
@@ -94,7 +98,7 @@ var ure_main = {
94
 
95
  ajax_error: function ( jqXHR, textStatus, errorThrown) {
96
  jQuery('#ure_task_status').hide();
97
- ure_main.show_notice( textStatus, 'error' );
98
  },
99
 
100
 
@@ -129,6 +133,10 @@ var ure_main = {
129
  auto_select_caps: function (event) {
130
 
131
  if ( event.shiftKey ) {
 
 
 
 
132
  jQuery('.ure-cap-cb').each(function () { // reverse selection
133
  if ( ure_main.apply_selection( this.id ) ) {
134
  jQuery(this).prop('checked', !jQuery(this).prop('checked'));
@@ -137,7 +145,14 @@ var ure_main = {
137
  } else {
138
  jQuery('.ure-cap-cb').each(function () { // switch On/Off all checkboxes
139
  if ( ure_main.apply_selection( this.id ) ) {
140
- jQuery(this).prop('checked', jQuery('#ure_select_all_caps').prop('checked'));
 
 
 
 
 
 
 
141
  }
142
  });
143
  }
@@ -218,52 +233,7 @@ var ure_main = {
218
  el.parentNode.removeChild(el);
219
  }
220
  },
221
-
222
-
223
- show_notice: function(msg_text, msg_type) {
224
-
225
- var class_name = 'notice-'+ msg_type;
226
- // try to use exising notice div with needed type
227
- var divs = document.getElementsByClassName( class_name );
228
- if ( divs === null || ( typeof divs === 'object' && divs.length===0 ) ) {
229
- // create notice div
230
- var div = document.createElement('div');
231
- div.classList.add('notice', 'is-dismissible', class_name);
232
- } else {
233
- var div = divs[0];
234
- }
235
-
236
- /* create paragraph element to hold message */
237
- var par = document.createElement('p');
238
- /* Add message text */
239
- par.appendChild(document.createTextNode(msg_text));
240
- // Optionally add a link here
241
-
242
- /* Add the whole message to notice div */
243
- div.appendChild(par);
244
-
245
- /* Create Dismiss icon */
246
- var but = document.createElement('button');
247
- but.setAttribute('type', 'button');
248
- but.classList.add('notice-dismiss');
249
- /* Add screen reader text to Dismiss icon */
250
- var bSpan = document.createElement('span');
251
- bSpan.classList.add('screen-reader-text');
252
- bSpan.appendChild(document.createTextNode('Dismiss this notice'));
253
- but.appendChild(bSpan);
254
- /* Add Dismiss icon to notice */
255
- div.appendChild(but);
256
-
257
- /* Insert notice after the first h1 */
258
- var h1 = document.getElementsByTagName('h1')[0];
259
- h1.parentNode.insertBefore(div, h1.nextSibling);
260
- /* Make the notice dismissable when the Dismiss icon is clicked */
261
- but.addEventListener('click', function () {
262
- div.parentNode.removeChild(div);
263
- });
264
- // setTimeout(this.hide_notice, 7000, div); // remove automatically after 7 sec.
265
- },
266
-
267
 
268
  show_granted_caps_only: function () {
269
  var show_deprecated = jQuery('#ure_show_deprecated_caps').prop('checked');
@@ -377,11 +347,11 @@ var ure_main = {
377
  refresh_role_view: function ( response ) {
378
  jQuery('#ure_task_status').hide();
379
  if (response!==null && response.result=='error') {
380
- ure_main.show_notice( response.message, 'error' );
381
  return;
382
  }
383
 
384
- // remove "Granted Only" filter is it was set before current role change
385
  var granted_only = jQuery('#granted_only').prop('checked');
386
  if (granted_only) {
387
  jQuery('#granted_only').prop('checked', false);
@@ -452,15 +422,15 @@ var ure_main = {
452
  'Add Role': function () {
453
  var role_id = jQuery('#user_role_id').val();
454
  if ( role_id=='' ) {
455
- ure_main.show_notice( ure_data.role_name_required, 'warning' );
456
  return false;
457
  }
458
  if ( !( /^[\w-]*$/.test( role_id ) ) ) {
459
- ure_main.show_notice( ure_data.role_name_valid_chars, 'warning' );
460
  return false;
461
  }
462
  if ( ( /^[0-9]*$/.test( role_id ) ) ) {
463
- ure_main.show_notice( ure_data.numeric_role_name_prohibited, 'warning' );
464
  return false;
465
  }
466
  var role_name = jQuery('#user_role_name').val();
@@ -564,9 +534,9 @@ var ure_main = {
564
  jQuery( '#ure_delete_role' ).show();
565
  }
566
  }
567
- ure_main.show_notice( data.message, 'success' );
568
  } else {
569
- ure_main.show_notice( data.message, 'error' );
570
  }
571
  },
572
 
@@ -586,11 +556,11 @@ var ure_main = {
586
  'Add Capability': function () {
587
  var capability_id = jQuery( '#capability_id' ).val();
588
  if ( capability_id == '' ) {
589
- ure_main.show_notice( ure_data.capability_name_required, 'warning' );
590
  return false;
591
  }
592
  if ( !( /^[\w-]*$/.test( capability_id ) ) ) {
593
- ure_main.show_notice( ure_data.capability_name_valid_chars, 'warning' );
594
  return false;
595
  }
596
  jQuery('#ure_task_status').show();
@@ -632,9 +602,9 @@ var ure_main = {
632
  jQuery( '#ure_caps_list' ).html( data.html );
633
  ure_main.refresh_role_view( data );
634
  }
635
- ure_main.show_notice( data.message, 'success' );
636
  } else {
637
- ure_main.show_notice( data.message, 'error' );
638
  }
639
  },
640
 
@@ -699,9 +669,9 @@ var ure_main = {
699
  }
700
  ure_main.count_caps_in_groups();
701
  }
702
- ure_main.show_notice( data.message, 'success' );
703
  } else {
704
- ure_main.show_notice( data.message, 'error' );
705
  }
706
  },
707
 
@@ -726,12 +696,12 @@ var ure_main = {
726
  jQuery('#ure_delete_capability_dialog .ure-input').html( response.html );
727
  ure_main.show_delete_capability_dialog();
728
  } else if (data.result === 'failure') {
729
- ure_main.show_notice( data.message, 'error' );
730
  } else {
731
- ure_main.show_notice( 'Wrong response: ' + response, 'error' )
732
  }
733
  } else {
734
- ure_main.show_notice( 'Wrong response: ' + response, 'error' )
735
  }
736
  },
737
  error: this.ajax_error
@@ -829,9 +799,9 @@ var ure_main = {
829
  ure_main.role_change( role_id );
830
  }
831
  }
832
- ure_main.show_notice( data.message, 'success' );
833
  } else {
834
- ure_main.show_notice( data.message, 'error' );
835
  }
836
  },
837
 
@@ -894,9 +864,9 @@ var ure_main = {
894
  jQuery( '#user_role option[value="'+ data.role_id+'"]' ).text( data.role_name +' ('+ data.role_id +')' );
895
  ure_current_role_name = data.role_name;
896
  }
897
- ure_main.show_notice( data.message, 'success' );
898
  } else {
899
- ure_main.show_notice( data.message, 'error' );
900
  }
901
  },
902
 
@@ -923,7 +893,7 @@ var ure_main = {
923
  if ( data.result=='success' ) {
924
  jQuery( '#ure_pro_advertisement' ).hide();
925
  } else {
926
- ure_main.show_notice( data.message, 'error' );
927
  }
928
  },
929
 
@@ -990,9 +960,9 @@ var ure_main = {
990
  jQuery('#ure_task_status').hide();
991
  if ( data.result=='success' ) {
992
  ure_main.count_caps_in_groups();
993
- ure_main.show_notice( data.message, 'success' );
994
  } else {
995
- ure_main.show_notice( data.message, 'error' );
996
  }
997
  }
998
 
22
 
23
 
24
  jQuery(function() {
25
+
26
  jQuery( '#ure_add_role' ).button({
27
  label: ure_data.add_role
28
  }).on('click', (function ( event ) {
65
  }));
66
 
67
 
68
+
69
  if ( jQuery('#ure_select_all_caps').length>0 ) {
70
  jQuery('#ure_select_all_caps').on('click', ( ure_main.auto_select_caps ) );
71
  }
81
  });
82
  ure_main.select_selectable_element( jQuery('#ure_caps_groups_list'), jQuery('#ure_caps_group_all') );
83
  jQuery('#granted_only').on('click', ( ure_main.show_granted_caps_only ) );
84
+
85
+ // We have to move notifyjs div on the top manually, as #wpadminbar z-index is 99999
86
+ jQuery("head").append('<style type="text/css"></style>');
87
+ var new_css_element = jQuery("head").children(':last');
88
+ new_css_element.html('.notifyjs-corner {z-index:1000000;}');
89
  });
90
 
91
 
98
 
99
  ajax_error: function ( jqXHR, textStatus, errorThrown) {
100
  jQuery('#ure_task_status').hide();
101
+ jQuery.notify( textStatus, 'error');
102
  },
103
 
104
 
133
  auto_select_caps: function (event) {
134
 
135
  if ( event.shiftKey ) {
136
+ if ( 'administrator'===ure_current_role ) {
137
+ // do not uncheck any capability for administrator role
138
+ return;
139
+ }
140
  jQuery('.ure-cap-cb').each(function () { // reverse selection
141
  if ( ure_main.apply_selection( this.id ) ) {
142
  jQuery(this).prop('checked', !jQuery(this).prop('checked'));
145
  } else {
146
  jQuery('.ure-cap-cb').each(function () { // switch On/Off all checkboxes
147
  if ( ure_main.apply_selection( this.id ) ) {
148
+ if ( 'administrator'===ure_current_role ) {
149
+ // do not uncheck any capability for administrator role
150
+ if ( jQuery('#ure_select_all_caps').prop('checked') ) {
151
+ jQuery(this).prop('checked', jQuery('#ure_select_all_caps').prop('checked'));
152
+ }
153
+ } else {
154
+ jQuery(this).prop('checked', jQuery('#ure_select_all_caps').prop('checked'));
155
+ }
156
  }
157
  });
158
  }
233
  el.parentNode.removeChild(el);
234
  }
235
  },
236
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
237
 
238
  show_granted_caps_only: function () {
239
  var show_deprecated = jQuery('#ure_show_deprecated_caps').prop('checked');
347
  refresh_role_view: function ( response ) {
348
  jQuery('#ure_task_status').hide();
349
  if (response!==null && response.result=='error') {
350
+ jQuery.notify( response.message, 'error');
351
  return;
352
  }
353
 
354
+ // remove "Granted Only" filter if it was set before current role change
355
  var granted_only = jQuery('#granted_only').prop('checked');
356
  if (granted_only) {
357
  jQuery('#granted_only').prop('checked', false);
422
  'Add Role': function () {
423
  var role_id = jQuery('#user_role_id').val();
424
  if ( role_id=='' ) {
425
+ jQuery.notify( ure_data.role_name_required, 'warn');
426
  return false;
427
  }
428
  if ( !( /^[\w-]*$/.test( role_id ) ) ) {
429
+ jQuery.notify( ure_data.role_name_valid_chars, 'warn');
430
  return false;
431
  }
432
  if ( ( /^[0-9]*$/.test( role_id ) ) ) {
433
+ jQuery.notify( ure_data.numeric_role_name_prohibited, 'warn');
434
  return false;
435
  }
436
  var role_name = jQuery('#user_role_name').val();
534
  jQuery( '#ure_delete_role' ).show();
535
  }
536
  }
537
+ jQuery.notify( data.message, 'success' );
538
  } else {
539
+ jQuery.notify( data.message, 'error' );
540
  }
541
  },
542
 
556
  'Add Capability': function () {
557
  var capability_id = jQuery( '#capability_id' ).val();
558
  if ( capability_id == '' ) {
559
+ jQuery.notify( ure_data.capability_name_required, 'warn' );
560
  return false;
561
  }
562
  if ( !( /^[\w-]*$/.test( capability_id ) ) ) {
563
+ jQuery.notify( ure_data.capability_name_valid_chars, 'warn' );
564
  return false;
565
  }
566
  jQuery('#ure_task_status').show();
602
  jQuery( '#ure_caps_list' ).html( data.html );
603
  ure_main.refresh_role_view( data );
604
  }
605
+ jQuery.notify( data.message, 'success' );
606
  } else {
607
+ jQuery.notify( data.message, 'error' );
608
  }
609
  },
610
 
669
  }
670
  ure_main.count_caps_in_groups();
671
  }
672
+ jQuery.notify( data.message, 'success' );
673
  } else {
674
+ jQuery.notify( data.message, 'error' );
675
  }
676
  },
677
 
696
  jQuery('#ure_delete_capability_dialog .ure-input').html( response.html );
697
  ure_main.show_delete_capability_dialog();
698
  } else if (data.result === 'failure') {
699
+ jQuery.notify( data.message, 'error' );
700
  } else {
701
+ jQuery.notify( 'Wrong response: ' + response, 'error' )
702
  }
703
  } else {
704
+ jQuery.notify( 'Wrong response: ' + response, 'error' )
705
  }
706
  },
707
  error: this.ajax_error
799
  ure_main.role_change( role_id );
800
  }
801
  }
802
+ jQuery.notify( data.message, 'success' );
803
  } else {
804
+ jQuery.notify( data.message, 'error' );
805
  }
806
  },
807
 
864
  jQuery( '#user_role option[value="'+ data.role_id+'"]' ).text( data.role_name +' ('+ data.role_id +')' );
865
  ure_current_role_name = data.role_name;
866
  }
867
+ jQuery.notify( data.message, 'success' );
868
  } else {
869
+ jQuery.notify( data.message, 'error' );
870
  }
871
  },
872
 
893
  if ( data.result=='success' ) {
894
  jQuery( '#ure_pro_advertisement' ).hide();
895
  } else {
896
+ jQuery.notify( data.message, 'error' );
897
  }
898
  },
899
 
960
  jQuery('#ure_task_status').hide();
961
  if ( data.result=='success' ) {
962
  ure_main.count_caps_in_groups();
963
+ jQuery.notify( data.message, 'success');
964
  } else {
965
+ jQuery.notify( data.message, 'error');
966
  }
967
  }
968
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: shinephp
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
- Tested up to: 5.7.1
7
- Stable tag: 4.59.1
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -80,6 +80,12 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
80
 
81
 
82
  == Changelog =
 
 
 
 
 
 
83
  = [4.59.1] 11.05.2021 =
84
  * New: Multisite: When update role at the main site with "Apply to all sites" option and PHP constant URE_MULTISITE_DIRECT_UPDATE === 1 (update roles directly in database, not via WordPress API),
85
  * URE overwrites all subsite roles with roles from the main site. It's possible now to leave selected role(s) for selected subsite(s) unchanged: add filter 'ure_network_update_leave_roles' and
@@ -93,25 +99,6 @@ https://translate.wordpress.org/projects/wp-plugins/user-role-editor/
93
  * Update: Editing roles and capabilities granted to selected user ("Capabilities" link under user row at the "Users" list) executes 'add_user_role' or 'remove_user_role' actions only in case it really grants or revokes roles and/or capabilities.
94
  Previous versions fully revoked and granted again all roles during user permissions update even in case roles list was not changed. It was leaded to the false execution of the mentioned add/remove role actions.
95
 
96
- = [4.58.3] 02.03.2021 =
97
- * Update: URE automatically adds custom taxonomies user capabilities to administrator role before opening "Users->User Role Editor" page.
98
- * Fix: Role changes were not saved with option "Confirm role update" switched off.
99
-
100
- = [4.58.2] 15.01.2021 =
101
- * Fix: Additional options turned ON for a role was not saved during role update.
102
- * Update: All JavaScript files are loaded with URE plugin version number as a query string for cache busting purpose.
103
-
104
- = [4.58.1] 11.01.2021 =
105
- * Fix: User lost assigned role(s) after click "Update" at the user permissions page, opened via "Selected user->Capabilities" or "User Profile->Capabilities->Edit" link.
106
-
107
- = [4.58] 11.01.2021 =
108
- * Update: Users->User Role Editor: Update button saves changes via AJAX without full page reload.
109
- * Fix: New user registered via frontend (wp-login.php?action=register) automatically receives additional (other) default role(s) according to selection made at User Role Editor settings "Other default roles" tab.
110
- * Fix: "PHP Deprecated: Required parameter $max_ind follows optional parameter $used in ..\wp-content\plugins\user-role-editor\includes\classes\advertisement.php on line 31" PHP 8.0 notice was fixed.
111
- * Fix: "JQMIGRATE: jquery.fn.resize() event shorthand is deprecated" notice was fixed.
112
- * Fix: "JQMIGRATE: jQuery.fn.click() event shorthand is deprecated" notice was fixed.
113
- * Fix: "JQMIGRATE: Number-typed values are deprecated for jQuery.fn.css( (property name), value )" notice was fixed.
114
-
115
  File changelog.txt contains the full list of changes.
116
 
117
  == Additional Documentation ==
@@ -121,7 +108,9 @@ You can find more information about "User Role Editor" plugin at [this page](htt
121
  I am ready to answer on your questions about plugin usage. Use [plugin page comments](http://www.shinephp.com/user-role-editor-wordpress-plugin/) for that.
122
 
123
  == Upgrade Notice ==
124
- = [4.56.1] 05.09.2020 =
125
- * New: WordPress multisite: Main site: Users->User Role Editor->Apply to All->Update: 'ure_after_network_roles_update' action hook was added. It is executed after all roles were replicated from the main site to the all other subsites of the network.
126
- * Fix: "Granted Only" filter did not work.
127
- * Fix: Warning was fixed: wp-content/plugins/user-role-editor/js/ure.js: jQuery.fn.attr('checked') might use property instead of attribute.
 
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=vladimir%40shinephp%2ecom&lc=RU&item_name=ShinePHP%2ecom&item_number=User%20Role%20Editor%20WordPress%20plugin&currency_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted
4
  Tags: user, role, editor, security, access, permission, capability
5
  Requires at least: 4.0
6
+ Tested up to: 5.7.2
7
+ Stable tag: 4.60
8
  Requires PHP: 5.6
9
  License: GPLv2 or later
10
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
80
 
81
 
82
  == Changelog =
83
+
84
+ = [4.60] 24.06.2021 =
85
+ * New: Notification box was replaced with one based on the [jpillora/nofifyjs](https://notifyjs.jpillora.com/) jQuery plugin. It does not move down page content. It disappears automatically after 5 seconds. Click on it to remove it manually.
86
+ * Fix: "Add capability" shows warning styled notification when needed (invalid characters, etc.) instead of a successful one.
87
+ * Fix: Capabilities group uncheck and revert selection is blocked for the administrator role to exclude accident deletion of permissions from it.
88
+
89
  = [4.59.1] 11.05.2021 =
90
  * New: Multisite: When update role at the main site with "Apply to all sites" option and PHP constant URE_MULTISITE_DIRECT_UPDATE === 1 (update roles directly in database, not via WordPress API),
91
  * URE overwrites all subsite roles with roles from the main site. It's possible now to leave selected role(s) for selected subsite(s) unchanged: add filter 'ure_network_update_leave_roles' and
99
  * Update: Editing roles and capabilities granted to selected user ("Capabilities" link under user row at the "Users" list) executes 'add_user_role' or 'remove_user_role' actions only in case it really grants or revokes roles and/or capabilities.
100
  Previous versions fully revoked and granted again all roles during user permissions update even in case roles list was not changed. It was leaded to the false execution of the mentioned add/remove role actions.
101
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  File changelog.txt contains the full list of changes.
103
 
104
  == Additional Documentation ==
108
  I am ready to answer on your questions about plugin usage. Use [plugin page comments](http://www.shinephp.com/user-role-editor-wordpress-plugin/) for that.
109
 
110
  == Upgrade Notice ==
111
+
112
+ = [4.60] 23.06.2021 =
113
+ * New: Notification box was replaced with one based on the [jpillora/nofifyjs](https://notifyjs.jpillora.com/) jQuery plugin. It does not move down page content. It disappears automatically after 5 seconds. Click on it to remove it manually.
114
+ * Fix: "Add capability" shows warning styled notification when needed (invalid characters, etc.) instead of a successful one.
115
+ * Fix: Capabilities group uncheck and revert selection is blocked for the administrator role to exclude accident deletion of permissions from it.
116
+
user-role-editor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: User Role Editor
4
  Plugin URI: https://www.role-editor.com
5
  Description: Change/add/delete WordPress user roles and capabilities.
6
- Version: 4.59.1
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: user-role-editor
@@ -23,7 +23,7 @@ if ( defined( 'URE_PLUGIN_URL' ) ) {
23
  wp_die( 'It seems that other version of User Role Editor is active. Please deactivate it before use this version' );
24
  }
25
 
26
- define( 'URE_VERSION', '4.59.1' );
27
  define( 'URE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
28
  define( 'URE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
29
  define( 'URE_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );
3
  Plugin Name: User Role Editor
4
  Plugin URI: https://www.role-editor.com
5
  Description: Change/add/delete WordPress user roles and capabilities.
6
+ Version: 4.60
7
  Author: Vladimir Garagulya
8
  Author URI: https://www.role-editor.com
9
  Text Domain: user-role-editor
23
  wp_die( 'It seems that other version of User Role Editor is active. Please deactivate it before use this version' );
24
  }
25
 
26
+ define( 'URE_VERSION', '4.60' );
27
  define( 'URE_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
28
  define( 'URE_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
29
  define( 'URE_PLUGIN_BASE_NAME', plugin_basename( __FILE__ ) );