From 17fdd8e0f6f5278fa57c1500a21021f45e5438e5 Mon Sep 17 00:00:00 2001 From: JoryHogeveen Date: Mon, 24 Sep 2018 19:59:01 +0200 Subject: [PATCH] 1.8.2-rc2 + JS codestyle --- assets/js/view-admin-as.js | 160 ++++++++++++++++----------------- assets/js/view-admin-as.min.js | 2 +- view-admin-as.php | 4 +- 3 files changed, 83 insertions(+), 83 deletions(-) diff --git a/assets/js/view-admin-as.js b/assets/js/view-admin-as.js index ecf595b0..3e2329fc 100644 --- a/assets/js/view-admin-as.js +++ b/assets/js/view-admin-as.js @@ -39,12 +39,12 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { ( function( $ ) { VAA_View_Admin_As.prefix = '#wpadminbar #wp-admin-bar-vaa '; - VAA_View_Admin_As.root = '#wp-admin-bar-vaa'; + VAA_View_Admin_As.root = '#wp-admin-bar-vaa'; var $document = $( document ), - $window = $( window ), - $body = $('body'), - $vaa = $( VAA_View_Admin_As.prefix ); // Validated in load(). + $window = $( window ), + $body = $('body'), + $vaa = $( VAA_View_Admin_As.prefix ); // Validated in load(). VAA_View_Admin_As.maxHeightListenerElements = null; VAA_View_Admin_As._mobile = false; @@ -169,7 +169,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { */ $( '[vaa-showhide]', $vaa ).each( function() { var $this = $(this), - args = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-showhide') ), + args = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-showhide') ), delay = 200; if ( 'object' !== typeof args ) { args = { 0: { target: args, delay: delay } }; @@ -243,7 +243,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // @since 1.7.4 Auto resizable. // @since 1.8.2 Enhance height calc + provide trigger for content changes $( '.vaa-resizable', $vaa ).each( function() { - var $this = $(this), + var $this = $(this), maxHeight = parseInt( $this.css( 'max-heights' ), 10 ), height, innerHeight, newHeight; @@ -508,7 +508,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $.post( VAA_View_Admin_As.ajaxurl, post_data, function( response ) { var success = ( response.hasOwnProperty( 'success' ) && true === response.success ), - data = {}, + data = {}, display = false; // Maybe show debug info in console. @@ -630,8 +630,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { * @return {void} Nothing. */ VAA_View_Admin_As.item_notice = function( parent, notice, type, timeout ) { - var root = '.vaa-notice', - html = notice + '', + var root = '.vaa-notice', + html = notice + '', $element = $( parent ); type = ( 'undefined' === typeof type ) ? 'notice' : type; @@ -713,9 +713,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { /* * Overlay handlers. */ - var root = '#vaa-overlay', - $overlay = $( root ), - $popup = $( root + ' .vaa-popup' ), + var root = '#vaa-overlay', + $overlay = $( root ), + $popup = $( root + ' .vaa-popup' ), $popup_content = $( root + ' .vaa-popup-content' ); var textarea = $( 'textarea', $popup_content ); @@ -749,7 +749,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { * @return {void} Nothing. */ VAA_View_Admin_As.download = function( data ) { - var content = '', + var content = '', filename = ''; if ( 'string' === typeof data ) { content = data; @@ -794,7 +794,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $( VAA_View_Admin_As.root + ' [vaa-auto-js]' ).each( function() { var $this = $(this), - data = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-auto-js') ); + data = VAA_View_Admin_As.maybe_json_decode( $this.attr('vaa-auto-js') ); if ( 'object' !== typeof data ) { return; } @@ -840,10 +840,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { if ( 'object' !== typeof data ) { return; } - var $elem = $( elem ), - setting = ( data.hasOwnProperty( 'setting' ) ) ? String( data.setting ) : null, - confirm = ( data.hasOwnProperty( 'confirm' ) ) ? Boolean( data.confirm ) : false, - refresh = ( data.hasOwnProperty( 'refresh' ) ) ? Boolean( data.refresh ) : false; + var $elem = $( elem ), + setting = ( data.hasOwnProperty( 'setting' ) ) ? String( data.setting ) : null, + confirm = ( data.hasOwnProperty( 'confirm' ) ) ? Boolean( data.confirm ) : false, + refresh = ( data.hasOwnProperty( 'refresh' ) ) ? Boolean( data.refresh ) : false; // Callback overwrite. if ( data.hasOwnProperty('callback') ) { @@ -900,7 +900,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return null; } var stop = false, - val = null; + val = null; if ( data.hasOwnProperty( 'values' ) ) { val = {}; $.each( data.values, function( val_key, auto_js ) { @@ -914,7 +914,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { if ( null !== val_val ) { val[ val_key ] = val_val; } else if ( auto_js.required ) { - val = null; + val = null; stop = true; return false; } @@ -1015,9 +1015,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { data = {}; } var $elem = $( elem ), - val = null, - attr = ( data.hasOwnProperty( 'attr' ) ) ? String( data.attr ) : false, - json = ( data.hasOwnProperty( 'json' ) ) ? Boolean( data.json ) : false, + val = null, + attr = ( data.hasOwnProperty( 'attr' ) ) ? String( data.attr ) : false, + json = ( data.hasOwnProperty( 'json' ) ) ? Boolean( data.json ) : false, value = ( attr ) ? $elem.attr( attr ) : $elem.val(); if ( 'checkbox' === $elem.attr( 'type' ) ) { @@ -1057,21 +1057,21 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { **/ VAA_View_Admin_As.init_users = function() { - var root = VAA_View_Admin_As.root + '-users', - root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ), - ajax_delay_timer, - $search_node = $( root_prefix + ' .ab-vaa-search.search-users' ); + var root = VAA_View_Admin_As.root + '-users', + root_prefix = VAA_View_Admin_As.prefix + root, + $root = $( root_prefix ), + $search_node = $( root_prefix + ' .ab-vaa-search.search-users' ), + ajax_delay_timer; if ( $search_node.length ) { - var search_ajax = $search_node.hasClass('search-ajax'), + var search_ajax = $search_node.hasClass('search-ajax'), $search_results = $search_node.find( '.ab-vaa-results' ), - no_results = '
' + VAA_View_Admin_As.__no_users_found + '
'; + no_results = '
' + VAA_View_Admin_As.__no_users_found + '
'; // Search users. $root.on( 'keyup', '.ab-vaa-search.search-users input', function() { - var $this = $(this), + var $this = $(this), search = $this.val(); if ( 1 <= search.trim().length ) { @@ -1106,7 +1106,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { $search_results.empty(); $( VAA_View_Admin_As.prefix + '.vaa-user-item' ).each( function() { var $this = $(this), - name = $this.find( '.ab-item' ).text(); + name = $this.find( '.ab-item' ).text(); if ( -1 < name.toLowerCase().indexOf( search.toLowerCase() ) ) { var exists = false; $search_results.find( '.vaa-user-item .ab-item' ).each(function() { @@ -1158,8 +1158,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { ajax_delay_timer = setTimeout( function() { $results_container.html( '
. . .
' ); - var $loading = $( '.ab-item', $results_container ), - loading = '. . . ', + var $loading = $( '.ab-item', $results_container ), + loading = '. . . ', loading_interval = setInterval( function() { if ( 20 < loading.length ) { loading = '. . . '; @@ -1212,9 +1212,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { **/ VAA_View_Admin_As.init_caps = function() { - var root = VAA_View_Admin_As.root + '-caps', + var root = VAA_View_Admin_As.root + '-caps', root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ); + $root = $( root_prefix ); VAA_View_Admin_As.caps_filter_settings = { selectedRole : 'default', @@ -1225,12 +1225,12 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Filter capability handler. VAA_View_Admin_As.filter_capabilities = function() { - var reverse = ( true === VAA_View_Admin_As.caps_filter_settings.selectedRoleReverse ), - isDefault = ( 'default' === VAA_View_Admin_As.caps_filter_settings.selectedRole ), + var reverse = ( true === VAA_View_Admin_As.caps_filter_settings.selectedRoleReverse ), + isDefault = ( 'default' === VAA_View_Admin_As.caps_filter_settings.selectedRole ), filterString = VAA_View_Admin_As.caps_filter_settings.filterString; $( root_prefix + '-select-options .vaa-cap-item' ).each( function() { - var $this = $(this), + var $this = $(this), exists = ( $( 'input', this ).attr('value') in VAA_View_Admin_As.caps_filter_settings.selectedRoleCaps ), name; @@ -1362,7 +1362,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { /** * Combine views tool. * @since 1.8.0 - * @return {null} Nothing. + * @return {void} Nothing. */ VAA_View_Admin_As.init_combine_views = function() { @@ -1370,12 +1370,12 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { prefix = 'vaa-combine-views', root_prefix = VAA_View_Admin_As.prefix + root, $root = $( root_prefix ), + is_active = false, combine_types = $.extend( [], VAA_View_Admin_As.view_types ), combine_selectors = [], selection = {}, $selection_container = root_prefix + ' #' + prefix + '-selection', - $combine_items, - is_active = false; + $combine_items; if ( ! $root.length ) { return; @@ -1452,24 +1452,24 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Late selection init needed for frontend. var $elements = $( elements ); $elements.each( function () { - var $this = $( this ), - $parent = $this.parent(), - val = null, - text = $this.text(), + var $this = $( this ), + $parent = $this.parent(), + val = null, + text = $this.text(), $data_el = $this.find('.vaa-view-data'), - type_label, + label, attr; if ( $parent.find('.vaa-combine-item').length ) { // Already exists. return true; } if ( $data_el.length ) { - val = $data_el.attr('vaa-view-value'); - text = $data_el.text(); - type_label = $data_el.attr('vaa-view-type-label'); + val = $data_el.attr('vaa-view-value'); + text = $data_el.text(); + label = $data_el.attr('vaa-view-type-label'); } if ( 'caps' === type ) { - val = ''; + val = ''; text = $( VAA_View_Admin_As.root + '-caps-title > .ab-item' ).text(); } attr = [ @@ -1480,8 +1480,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { 'vaa-view-text="' + text + '"', 'style="display:none;"' ]; - if ( type_label ) { - attr.push( 'vaa-view-type-label="' + type_label + '"' ); + if ( label ) { + attr.push( 'vaa-view-type-label="' + label + '"' ); } $parent.prepend( '' ); } ); @@ -1542,8 +1542,8 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { */ function deactivate_combine_type( types, update ) { if ( 'object' !== typeof types ) { - type = types; - types = {}; + type = types; + types = {}; types[ type ] = 0; } for ( var type in types ) { @@ -1563,7 +1563,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Remove view types that are deselected. $( root_prefix + ' .vaa-combine-selection' ).each( function() { var $this = $(this), - type = $this.attr('vaa-view-type'); + type = $this.attr('vaa-view-type'); if ( ! selection.hasOwnProperty( type ) ) { $this.slideUp( 'fast', function() { $( this ).remove() } ); } @@ -1571,9 +1571,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // Append or update view types selection. $.each( selection, function( type, data ) { - var text = data.el.attr('vaa-view-text') + '', + var text = data.el.attr('vaa-view-text') + '', $existing = $( root_prefix + ' .vaa-combine-selection-' + type ), - label = data.el.attr( 'vaa-view-type-label' ); + label = data.el.attr( 'vaa-view-type-label' ); if ( label ) { text = '' + label + ': ' + text; } @@ -1623,7 +1623,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } var $this = $( this ), - type = $this.attr('vaa-view-type'); + type = $this.attr('vaa-view-type'); if ( this.checked ) { parse_combine_type( $this, type ); } else { @@ -1704,10 +1704,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { */ VAA_View_Admin_As.init_module_role_defaults = function() { - var root = VAA_View_Admin_As.root + '-role-defaults', - prefix = 'vaa-role-defaults', + var root = VAA_View_Admin_As.root + '-role-defaults', + prefix = 'vaa-role-defaults', root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ); + $root = $( root_prefix ); if ( ! $root.length ) { return; @@ -1719,9 +1719,9 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } e.preventDefault(); - var val = $( root_prefix + '-meta-add input#' + prefix + '-meta-new' ).val(); - var item = $( root_prefix + '-meta-add #' + prefix + '-meta-template' ).html().toString(); - val = val.replace( / /g, '_' ); + var val = $( root_prefix + '-meta-add input#' + prefix + '-meta-new' ).val(), + item = $( root_prefix + '-meta-add #' + prefix + '-meta-template' ).html().toString(); + val = val.replace( / /g, '_' ); item = item.replace( /vaa_new_item/g, val ); if ( $( root_prefix + '-meta-select input[value="' + val + '"]' ).length ) { VAA_View_Admin_As.item_notice( $(this).parent(), VAA_View_Admin_As.__key_already_exists, 'error', 2000 ); @@ -1758,7 +1758,7 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { if ( $search.length ) { var $search_results = $root.find( root + '-bulk-users-select' ); $search.on( 'keyup', 'input#' + prefix + '-bulk-users-search', function() { - var $this = $(this), + var $this = $(this), search = $this.val(); if ( 1 <= search.trim().length ) { @@ -1788,10 +1788,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { /** * Capability functions. */ - var root = VAA_View_Admin_As.root + '-caps-manager-role-manager', - prefix = 'vaa-caps-manager-role-manager', + var root = VAA_View_Admin_As.root + '-caps-manager-role-manager', + prefix = 'vaa-caps-manager-role-manager', root_prefix = VAA_View_Admin_As.prefix + root, - $root = $( root_prefix ); + $root = $( root_prefix ); if ( ! $root.length ) { return; @@ -1799,17 +1799,17 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { // @since 1.7.0 Update capabilities when selecting a role. $root.on( 'change', 'select#' + prefix + '-edit-role', function() { - var $this = $(this), - role = $this.val(), - caps = {}, + var $this = $(this), + role = $this.val(), + caps = {}, $selected_role = $( root_prefix + ' select#' + prefix + '-edit-role option[value="' + role + '"]' ); if ( $selected_role.attr('data-caps') ) { caps = JSON.parse( $selected_role.attr('data-caps') ); } // Reset role filters. - VAA_View_Admin_As.caps_filter_settings.selectedRole = 'default'; - VAA_View_Admin_As.caps_filter_settings.selectedRoleCaps = {}; + VAA_View_Admin_As.caps_filter_settings.selectedRole = 'default'; + VAA_View_Admin_As.caps_filter_settings.selectedRoleCaps = {}; VAA_View_Admin_As.caps_filter_settings.selectedRoleReverse = false; VAA_View_Admin_As.filter_capabilities(); @@ -1822,13 +1822,13 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } e.preventDefault(); - var role = $( root_prefix + ' select#' + prefix + '-edit-role' ).val(), + var role = $( root_prefix + ' select#' + prefix + '-edit-role' ).val(), refresh = ( VAA_View_Admin_As.view.hasOwnProperty( 'role' ) && role === VAA_View_Admin_As.view.role ); if ( ! role ) { return false; } if ( '__new__' === role ) { - role = $( root_prefix + ' input#' + prefix + '-new-role' ).val(); + role = $( root_prefix + ' input#' + prefix + '-new-role' ).val(); refresh = true; } var data = { @@ -1845,10 +1845,10 @@ if ( 'undefined' === typeof VAA_View_Admin_As ) { return; } e.preventDefault(); - var existing = VAA_View_Admin_As.get_selected_capabilities(); - var val = $( root_prefix + '-new-cap input#' + prefix + '-new-cap' ).val(); - var item = $( root_prefix + '-new-cap #' + prefix + '-cap-template' ).html().toString(); - val = val.replace( / /g, '_' ); + var existing = VAA_View_Admin_As.get_selected_capabilities(), + val = $( root_prefix + '-new-cap input#' + prefix + '-new-cap' ).val(), + item = $( root_prefix + '-new-cap #' + prefix + '-cap-template' ).html().toString(); + val = val.replace( / /g, '_' ); item = item.replace( /vaa_new_item/g, val ); if ( 'undefined' !== typeof existing[ val ] ) { VAA_View_Admin_As.item_notice( $(this).parent(), VAA_View_Admin_As.__key_already_exists, 'error', 2000 ); diff --git a/assets/js/view-admin-as.min.js b/assets/js/view-admin-as.min.js index f4fd37c7..e57df90c 100644 --- a/assets/js/view-admin-as.min.js +++ b/assets/js/view-admin-as.min.js @@ -8,4 +8,4 @@ * @version 1.8.2 * @preserve */ -if("undefined"===typeof VAA_View_Admin_As){var VAA_View_Admin_As={}}(function($){VAA_View_Admin_As.prefix="#wpadminbar #wp-admin-bar-vaa ";VAA_View_Admin_As.root="#wp-admin-bar-vaa";var $document=$(document),$window=$(window),$body=$("body"),$vaa=$(VAA_View_Admin_As.prefix);VAA_View_Admin_As.maxHeightListenerElements=null;VAA_View_Admin_As._mobile=false;if(!VAA_View_Admin_As.hasOwnProperty("_debug")){VAA_View_Admin_As._debug=false}if(!VAA_View_Admin_As.hasOwnProperty("ajaxurl")){if("undefined"===typeof ajaxurl){var ajaxurl=window.location.origin+"/wp-admin/admin-ajax.php"}VAA_View_Admin_As.ajaxurl=ajaxurl}VAA_View_Admin_As._touchmove=false;$document.on("touchmove",function(){VAA_View_Admin_As._touchmove=true});$document.on("touchstart",function(){VAA_View_Admin_As._touchmove=false});VAA_View_Admin_As.maybe_json_decode=function(val){if(0===val.indexOf("{")||0===val.indexOf("[")){try{val=JSON.parse(val)}catch(err){}}return val};VAA_View_Admin_As.init=function(){if(!$vaa.length){$vaa=$(VAA_View_Admin_As.prefix)}if(VAA_View_Admin_As._loader_icon){var loader_icon=new Image;loader_icon.src=VAA_View_Admin_As._loader_icon}VAA_View_Admin_As.maxHeightListenerElements=$(VAA_View_Admin_As.prefix+".vaa-auto-max-height");VAA_View_Admin_As.init_caps();VAA_View_Admin_As.init_users();VAA_View_Admin_As.init_combine_views();VAA_View_Admin_As.init_module_role_defaults();VAA_View_Admin_As.init_module_role_manager();VAA_View_Admin_As.init_auto_js();$(".ab-vaa-toggle",$vaa).each(function(){var $this=$(this),$toggle=$this.parent().children().not(".ab-vaa-toggle");if(!$this.hasClass("active")){$toggle.hide()}$this.on("click touchend",function(e){e.preventDefault();e.stopPropagation();if(true===VAA_View_Admin_As._touchmove){return}if($(this).hasClass("active")){$toggle.slideUp("fast");$(this).removeClass("active")}else{$toggle.slideDown("fast");$(this).addClass("active")}VAA_View_Admin_As.autoMaxHeight()});$this.on("keyup",function(e){e.preventDefault();var key=parseInt(e.which,10);if($(this).hasClass("active")&&(13===key||32===key||38===key)){$toggle.slideUp("fast");$(this).removeClass("active")}else if(13===key||32===key||40===key){$toggle.slideDown("fast");$(this).addClass("active")}VAA_View_Admin_As.autoMaxHeight()})});$("[vaa-showhide]",$vaa).each(function(){var $this=$(this),args=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-showhide")),delay=200;if("object"!==typeof args){args={0:{target:args,delay:delay}}}$.each(args,function(key,data){var timeout=null,$target=$(data.target);if(!data.hasOwnProperty("delay")){data.delay=delay}$target.hide();$this.on("mouseenter",function(){timeout=setTimeout(function(){$target.slideDown("fast")},data.delay)}).on("mouseleave",function(){if(timeout){clearTimeout(timeout)}$target.slideUp("fast")})})});$("[vaa-condition-target]",$vaa).each(function(){var $this=$(this),$target=$($this.attr("vaa-condition-target")),checkbox="checkbox"===$target.attr("type"),compare=$this.attr("vaa-condition");if(checkbox){if("undefined"!==typeof compare){compare=Boolean(compare)}else{compare=true}}$this.hide();$target.on("change.vaa",function(){if(checkbox&&$target.is(":checked")){if(compare){$this.slideDown("fast")}else{$this.slideUp("fast")}}else if(!checkbox&&compare===$target.val()){$this.slideDown("fast")}else{$this.slideUp("fast")}VAA_View_Admin_As.autoMaxHeight()}).trigger("change.vaa")});if($body.hasClass("mobile")||783>$body.innerWidth()){$body.addClass("vaa-mobile");VAA_View_Admin_As._mobile=true;VAA_View_Admin_As.init_touch()}VAA_View_Admin_As.maxHeightListenerElements.each(function(){$(this).parents(".menupop").on("mouseenter",VAA_View_Admin_As.autoMaxHeight)});$(".vaa-resizable",$vaa).each(function(){var $this=$(this),maxHeight=parseInt($this.css("max-heights"),10),height,innerHeight,newHeight;$this.find(".ab-empty-item:empty").remove();$this.on("vaa-resizable",function(){if($this.is(":empty")){$this.css({"max-height":"",height:"",resize:""});return}newHeight=maxHeight;height=$this.height();$this.css({"max-height":"",height:"",resize:""});if(height){$this.css({"max-height":"none"});innerHeight=$this.height();$this.css({"max-height":""});if(innerHeight=maxHeight){if(innerHeight=maxHeight)){$this.css({"max-height":"none",height:newHeight?newHeight+"px":"",resize:"vertical"})}}).trigger("vaa-resizable")});$vaa.on("click touchend",".vaa-reset-item > .ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}if("vaa_reload"===$("button",this).attr("name")){window.location.reload()}else{VAA_View_Admin_As.ajax({reset:true},true);return false}});$.each(VAA_View_Admin_As.view_types,function(index,type){$vaa.on("click touchend",".vaa-"+type+"-item > a.ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this);if(VAA_View_Admin_As._mobile){var $parent=$this.parent();if($parent.hasClass("menupop")&&!$parent.hasClass("active")){$parent.addClass("active");$this.next().show();return false}}$this.data("vaa-continue-event",true).trigger("vaa-apply-view");if(!$this.parent().hasClass("not-a-view")&&$this.data("vaa-continue-event")){var view_data={},val=$this.find(".vaa-view-data").attr("vaa-view-value");view_data[type]=VAA_View_Admin_As.maybe_json_decode(val);if("object"===typeof view_data[type]){view_data=view_data[type]}VAA_View_Admin_As.ajax(view_data,true);return false}})});$vaa.on("click touchend",".remove",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}$(this).parent().slideUp("fast",function(){$(this).remove()})})};VAA_View_Admin_As.init_touch=function(){var $root=$(".vaa-mobile "+VAA_View_Admin_As.prefix);$root.on("click touchend"," > .ab-sub-wrapper .ab-item",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();var $sub=$(this).parent(".menupop").children(".ab-sub-wrapper");if($sub.length){if($sub.hasClass("active")){$sub.slideUp("fast").removeClass("active")}else{$sub.slideDown("fast").addClass("active")}}});$root.on("click touchend","input, textarea, select",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.stopPropagation();var $this=$(this);if($this.is('[type="checkbox"]')){e.preventDefault();if($this.is(":checked")){$this.prop("checked",false)}else{$this.prop("checked",true)}$this.trigger("change");return false}else if($this.is('[type="radio"]')){e.preventDefault();$('input[name="'+$this.attr["name"]+'"]').removeAttr("checked");$this.prop("checked",true);$this.trigger("change");return false}return true});$root.on("click touchend","label",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();$("#"+$(this).attr("for")).trigger(e.type);return false})};VAA_View_Admin_As.overlay=function(html){var $overlay=$("#vaa-overlay");if(false===html){$overlay.fadeOut("fast",function(){$(this).remove()});$document.off("mouseup.vaa_overlay");return}if(!$overlay.length){html='
'+html+"
";$body.append(html);$overlay=$("body #vaa-overlay")}else if(html.length){$overlay.html(html)}$overlay.fadeIn("fast");$overlay.find(".remove").click(function(){VAA_View_Admin_As.overlay(false)});$document.on("mouseup.vaa_overlay",function(e){$overlay.find(".vaa-popup").each(function(){if(!$(this).is(e.target)&&0===$(this).has(e.target).length){VAA_View_Admin_As.overlay(false);return false}})})};VAA_View_Admin_As.ajax=function(data,refresh){$(".vaa-notice","#wpadminbar").remove();var loader_icon="";if(VAA_View_Admin_As._loader_icon){loader_icon=' style="background-image: url('+VAA_View_Admin_As._loader_icon+')"'}VAA_View_Admin_As.overlay('");var post_data={action:"view_admin_as",_vaa_nonce:VAA_View_Admin_As._vaa_nonce,view_admin_as:JSON.stringify(data)};var isView=false;$.each(VAA_View_Admin_As.view_types,function(index,type){if("undefined"!==typeof data[type]){isView=true;return true}});if($(VAA_View_Admin_As.prefix+"#vaa-settings-view-mode-single").is(":checked")&&isView){$body.append('');var $form=$("#vaa_single_mode_form");$form.append('');$form.append('');$form.append('');$form.find("#data").val(post_data.view_admin_as);$form.submit()}else{$.post(VAA_View_Admin_As.ajaxurl,post_data,function(response){var success=response.hasOwnProperty("success")&&true===response.success,data={},display=false;VAA_View_Admin_As.debug(response);if(response.hasOwnProperty("data")){if("object"===typeof response.data){data=response.data;if(data.hasOwnProperty("display")){display=data.display}}}if(success){if("download"===refresh){VAA_View_Admin_As.download(data);VAA_View_Admin_As.overlay(false);return}else if(refresh){VAA_View_Admin_As.refresh(data);return}else{if(!data.hasOwnProperty("text")){data.text=VAA_View_Admin_As.__success}}}if(!data.hasOwnProperty("type")){data.type=success?"success":"error"}if("popup"===display){VAA_View_Admin_As.popup(data,data.type)}else{if(!data.hasOwnProperty("text")){data.text=response.data}VAA_View_Admin_As.notice(String(data.text),data.type,5e3);$("body #vaa-overlay").addClass(data.type).fadeOut("fast",function(){$(this).remove()})}})}};VAA_View_Admin_As.refresh=function(data){if(data.hasOwnProperty("redirect")){window.location.replace(String(data.redirect))}else{window.location.hash="";window.location.reload()}};VAA_View_Admin_As.notice=function(notice,type,timeout){var root="#wpadminbar .vaa-notice",html=notice+'';type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;if(VAA_View_Admin_As._mobile){html='";$(VAA_View_Admin_As.prefix+"> .ab-sub-wrapper").prepend(html).children(".vaa-notice").slideDown("fast");$("html, body").animate({scrollTop:"0"});if(timeout){setTimeout(function(){$(root).slideUp("fast",function(){$(this).remove()})},timeout)}}else{html='
  • '+html+"
  • ";$("#wp-admin-bar-top-secondary").append(html);$(root+" .remove").click(function(){$(this).parent().remove()});if(timeout){setTimeout(function(){$(root).fadeOut("fast",function(){$(this).remove()})},timeout)}}};VAA_View_Admin_As.item_notice=function(parent,notice,type,timeout){var root=".vaa-notice",html=notice+'',$element=$(parent);type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;html='";$element.append(html).children(".vaa-notice").slideDown("fast");if(timeout){setTimeout(function(){$(root,$element).slideUp("fast",function(){$(this).remove()})},timeout)}};VAA_View_Admin_As.item_confirm=function(parent,text){$(parent).find(".vaa-notice").slideUp("fast",function(){$(this).remove()});text='";VAA_View_Admin_As.item_notice(parent,text,"warning",0);return $(parent).find(".vaa-confirm")};VAA_View_Admin_As.popup=function(data,type){type="undefined"===typeof type?"notice":type;var html="";html+='
    ';html+='';html+='
    ';if("object"!==typeof data){data={text:data}}if(data.hasOwnProperty("text")){html+="

    "+String(data.text)+"

    "}if(data.hasOwnProperty("list")&&"object"===typeof data.list){html+="
      ";$.each(data.list,function(key,value){html+="
    • "+String(value)+"
    • "});html+="
    "}if(data.hasOwnProperty("textarea")){html+='"}html+="
    ";VAA_View_Admin_As.overlay(html);var root="#vaa-overlay",$overlay=$(root),$popup=$(root+" .vaa-popup"),$popup_content=$(root+" .vaa-popup-content");var textarea=$("textarea",$popup_content);if(textarea.length){textarea.on("click",function(){$(this).select()})}var popupMaxHeight=function(){if(textarea.length){textarea.each(function(){$(this).css({height:"auto","overflow-y":"hidden"}).height(this.scrollHeight)})}var max_height=$overlay.height()*.8-24;$popup.css("max-height",max_height);$popup_content.css("max-height",max_height)};popupMaxHeight();$window.on("resize",function(){popupMaxHeight()})};VAA_View_Admin_As.download=function(data){var content="",filename="";if("string"===typeof data){content=data}else{if(data.hasOwnProperty("download")){content=String(data.download)}else if(data.hasOwnProperty("textarea")){content=String(data.textarea)}else if(data.hasOwnProperty("content")){content=String(data.content)}}content=VAA_View_Admin_As.maybe_json_decode(content);if("object"===typeof content){content=JSON.stringify(content,null,"\t")}if(!content){return}if(data.hasOwnProperty("filename")){filename=data.filename}var link="data:application/octet-stream;charset=utf-8,"+encodeURIComponent(content);$body.append('');document.getElementById("vaa_temp_download").click();$("a#vaa_temp_download").remove()};VAA_View_Admin_As.init_auto_js=function(){$(VAA_View_Admin_As.root+" [vaa-auto-js]").each(function(){var $this=$(this),data=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-auto-js"));if("object"!==typeof data){return}if(!data.hasOwnProperty("event")){data.event="change"}if("click"===data.event){data.event="click touchend"}$this.on(data.event,function(e){if("change"!==data.event&&true===VAA_View_Admin_As._touchmove){return}e.preventDefault();VAA_View_Admin_As.do_auto_js(data,this);return false})});VAA_View_Admin_As.do_auto_js=function(data,elem){if("object"!==typeof data){return}var $elem=$(elem),setting=data.hasOwnProperty("setting")?String(data.setting):null,confirm=data.hasOwnProperty("confirm")?Boolean(data.confirm):false,refresh=data.hasOwnProperty("refresh")?Boolean(data.refresh):false;if(data.hasOwnProperty("callback")){VAA_View_Admin_As[data.callback](data);return}var val=VAA_View_Admin_As.get_auto_js_values_recursive(data,elem);if(null!==val){if(!setting){return}var view_data={};view_data[setting]=val;if(data.hasOwnProperty("download")&&data.download){refresh="download"}if(confirm){confirm=VAA_View_Admin_As.item_confirm($elem.parent(),VAA_View_Admin_As.__confirm);$(confirm).on("click",function(){VAA_View_Admin_As.ajax(view_data,refresh)})}else{VAA_View_Admin_As.ajax(view_data,refresh)}}else{}};VAA_View_Admin_As.get_auto_js_values_recursive=function(data,elem){if("object"!==typeof data){return null}var stop=false,val=null;if(data.hasOwnProperty("values")){val={};$.each(data.values,function(val_key,auto_js){if("object"!==typeof auto_js||null===auto_js){auto_js={}}auto_js.required=auto_js.hasOwnProperty("required")?Boolean(auto_js.required):true;var val_val=VAA_View_Admin_As.get_auto_js_values_recursive(auto_js,elem);if(null!==val_val){val[val_key]=val_val}else if(auto_js.required){val=null;stop=true;return false}});if(stop){return null}}else{val=VAA_View_Admin_As.parse_auto_js_value(data,elem)}return val};VAA_View_Admin_As.parse_auto_js_value=function(data,elem){if("object"!==typeof data){return null}var $elem=data.hasOwnProperty("element")?$(data.element):$(elem),parser=data.hasOwnProperty("parser")?String(data.parser):"",val=null;switch(parser){case"multiple":case"multi":val={};$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();val[value]=this.checked}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);val[$this.attr("name")]=value}});break;case"selected":val=[];$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();if(this.checked&&value){val.push(value)}}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);if(value){val.push(value)}}});break;default:val=VAA_View_Admin_As.get_auto_js_value($elem,data);break}return val};VAA_View_Admin_As.get_auto_js_value=function(elem,data){if("object"!==typeof data){data={}}var $elem=$(elem),val=null,attr=data.hasOwnProperty("attr")?String(data.attr):false,json=data.hasOwnProperty("json")?Boolean(data.json):false,value=attr?$elem.attr(attr):$elem.val();if("checkbox"===$elem.attr("type")){var checked=$elem.is(":checked");if(attr){if(checked&&value){val=value}}else{val=checked}}else{if(value){val=value}}if(json){try{val=JSON.parse(val)}catch(err){val=null;VAA_View_Admin_As.popup("
    "+err+"
    ","error")}}return val}};VAA_View_Admin_As.init_users=function(){var root=VAA_View_Admin_As.root+"-users",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix),ajax_delay_timer,$search_node=$(root_prefix+" .ab-vaa-search.search-users");if($search_node.length){var search_ajax=$search_node.hasClass("search-ajax"),$search_results=$search_node.find(".ab-vaa-results"),no_results='
    '+VAA_View_Admin_As.__no_users_found+"
    ";$root.on("keyup",".ab-vaa-search.search-users input",function(){var $this=$(this),search=$this.val();if(1<=search.trim().length){if(search_ajax){search={search:search,return:"links"};var search_by=$root.find(".ab-vaa-search.search-users select").val();if(search_by){search["search_by"]=search_by}VAA_View_Admin_As.search_users_ajax(search,$search_results)}else{search_users(search)}}else{VAA_View_Admin_As.search_users_ajax(null,$search_results)}})}function search_users(search){$search_results.empty();$(VAA_View_Admin_As.prefix+".vaa-user-item").each(function(){var $this=$(this),name=$this.find(".ab-item").text();if(-1 .ab-item > .vaa-view-data");role=role?role.text():"";if(role&&false!==exists&&exists.length){exists.find(".user-role").text(exists.find(".user-role").text().replace(")",", "+role+")"))}else{role=role?'  ('+role+")":"";$this.clone().appendTo($search_results).children(".ab-item").append(role)}}});if(""===$.trim($search_results.html())){$search_results.html(no_results)}VAA_View_Admin_As.autoMaxHeight()}VAA_View_Admin_As.search_users_ajax=function(search,results_container){clearTimeout(ajax_delay_timer);var $results_container=$(results_container);if(!search){$results_container.empty();if($results_container.hasClass("vaa-resizable")){$results_container.trigger("vaa-resizable")}return}ajax_delay_timer=setTimeout(function(){$results_container.html('
    . . .
    ');var $loading=$(".ab-item",$results_container),loading=". . . ",loading_interval=setInterval(function(){if(20 .ab-item"}}combine_types.push("caps");combine_selectors["caps"]=VAA_View_Admin_As.prefix+VAA_View_Admin_As.root+"-caps > .menupop > .ab-item";VAA_View_Admin_As.reinit_combine_views=function(){if(is_active){enable_combine_views()}else{add_combine_checkboxes()}$.each(selection,function(type,data){data.el=$(data.el);if(!data.el.length||!data.el.closest("body").length){data.el=$(VAA_View_Admin_As.prefix+".vaa-combine-item[vaa-view-type="+data.type+"][vaa-view-value="+data.value+"]")}if(data.el.length){data.el.prop("checked",true);activate_combine_type(data.el,data.type,data.value)}})};function enable_combine_views(){is_active=true;add_combine_checkboxes();$combine_items=$(VAA_View_Admin_As.prefix+".vaa-combine-item");$combine_items.fadeIn("fast");update_selection_list()}function disable_combine_views(){is_active=false;$(VAA_View_Admin_As.prefix+".vaa-combine-item").fadeOut("fast");if($selection_container.is(":visible")){$selection_container.slideUp("fast")}else{$selection_container.hide()}}function add_combine_checkboxes(elements,type){if(!elements||!type){for(var key in combine_selectors){if(combine_selectors.hasOwnProperty(key)){add_combine_checkboxes(combine_selectors[key],key)}}return}var $elements=$(elements);$elements.each(function(){var $this=$(this),$parent=$this.parent(),val=null,text=$this.text(),$data_el=$this.find(".vaa-view-data"),type_label,attr;if($parent.find(".vaa-combine-item").length){return true}if($data_el.length){val=$data_el.attr("vaa-view-value");text=$data_el.text();type_label=$data_el.attr("vaa-view-type-label")}if("caps"===type){val="";text=$(VAA_View_Admin_As.root+"-caps-title > .ab-item").text()}attr=['type="checkbox"','class="checkbox vaa-right vaa-combine-item vaa-combine-'+type+'"','vaa-view-type="'+type+'"',"vaa-view-value='"+val+"'",'vaa-view-text="'+text+'"','style="display:none;"'];if(type_label){attr.push('vaa-view-type-label="'+type_label+'"')}$parent.prepend("")})}function parse_combine_type(element,type){var $element=$(element),val;if("caps"===type){val=type}else{val=VAA_View_Admin_As.maybe_json_decode($element.attr("vaa-view-value"));if("object"===typeof val){$.each(val,function(val_type,data){var $val_element=$(VAA_View_Admin_As.prefix+".vaa-combine-"+val_type+"[vaa-view-value="+data+"]");activate_combine_type($val_element,val_type,data)});$element.prop({checked:true,disabled:false});return}}activate_combine_type($element,type,val)}function activate_combine_type(element,type,value){var $element=$(element);deactivate_combine_type(type,false);selection[type]={el:$element,type:type,value:value};$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:true});$element.prop({checked:true,disabled:false});update_selection_list()}function deactivate_combine_type(types,update){if("object"!==typeof types){type=types;types={};types[type]=0}for(var type in types){if(types.hasOwnProperty(type)){delete selection[type];$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:false})}}if(update){update_selection_list()}}function update_selection_list(){$(root_prefix+" .vaa-combine-selection").each(function(){var $this=$(this),type=$this.attr("vaa-view-type");if(!selection.hasOwnProperty(type)){$this.slideUp("fast",function(){$(this).remove()})}});$.each(selection,function(type,data){var text=data.el.attr("vaa-view-text")+'',$existing=$(root_prefix+" .vaa-combine-selection-"+type),label=data.el.attr("vaa-view-type-label");if(label){text=''+label+": "+text}if($existing.length){$existing.html(text);if("none"===$existing.css("display")||!$existing.is(":visible")){$existing.slideDown("fast")}}else{var attr=['class="ab-item ab-empty-item vaa-combine-selection vaa-combine-selection-'+type+'"','vaa-view-type="'+type+'"','style="display:none;"'];var html="
  • "+text+"
  • ";$selection_container.append(html);$(root_prefix+" .vaa-combine-selection-"+type).slideDown("fast")}});if(is_active&&!$.isEmptyObject(selection)){if("none"===$selection_container.css("display")||!$selection_container.is(":visible")){$selection_container.slideDown("fast")}}else{$selection_container.slideUp("fast")}}$root.on("change","input#"+prefix,function(){$selection_container=$($selection_container);if(true===VAA_View_Admin_As._touchmove){return}if(this.checked){enable_combine_views()}else{disable_combine_views()}});$vaa.on("change","input.vaa-combine-item",function(){if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this),type=$this.attr("vaa-view-type");if(this.checked){parse_combine_type($this,type)}else{var val=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-view-value"));if("object"===typeof val){deactivate_combine_type(val,true);return}deactivate_combine_type(type,true)}});$root.on("click touchend",".vaa-combine-selection .remove",function(){if(true===VAA_View_Admin_As._touchmove){return}deactivate_combine_type($(this).parent().attr("vaa-view-type"),true)});$root.on("click touchend","button#"+prefix+"-apply",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var view_data={};for(var type in selection){if(selection.hasOwnProperty(type)){if("caps"===type){view_data[type]=VAA_View_Admin_As.get_selected_capabilities()}else{view_data[type]=selection[type].value}}}if(!$.isEmptyObject(view_data)){VAA_View_Admin_As.ajax(view_data,true)}else{}});$.each(combine_types,function(index,type){$vaa.on("vaa-apply-view",".vaa-"+type+"-item > a.ab-item",function(e){if(!is_active){return}e.preventDefault();var $this=$(this);if(!$this.parent().hasClass("not-a-view")){if(!VAA_View_Admin_As._mobile){var $combine_item=$this.parent().children(".vaa-combine-item");if($combine_item.is(":checked")){$combine_item.prop("checked",false)}else{$combine_item.prop("checked",true)}$combine_item.trigger("change")}e.stopPropagation();e.stopImmediatePropagation();$this.data("vaa-continue-event",false);return false}})})};VAA_View_Admin_As.init_module_role_defaults=function(){var root=VAA_View_Admin_As.root+"-role-defaults",prefix="vaa-role-defaults",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix);if(!$root.length){return}$root.on("click touchend",root+"-meta-add button#"+prefix+"-meta-add",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var val=$(root_prefix+"-meta-add input#"+prefix+"-meta-new").val();var item=$(root_prefix+"-meta-add #"+prefix+"-meta-template").html().toString();val=val.replace(/ /g,"_");item=item.replace(/vaa_new_item/g,val);if($(root_prefix+'-meta-select input[value="'+val+'"]').length){VAA_View_Admin_As.item_notice($(this).parent(),VAA_View_Admin_As.__key_already_exists,"error",2e3)}else{$(root_prefix+"-meta-select > .ab-item").prepend(item)}});if($root.find(root+"-bulk-users-filter").length){$root.on("keyup",root+"-bulk-users-filter input#"+prefix+"-bulk-users-filter",function(e){e.preventDefault();var $items=$(root_prefix+"-bulk-users-select .ab-item.vaa-item");if(1<=$(this).val().length){var input_text=$(this).val();$items.each(function(){var name=$(".user-name",this).text();if(-1 .ab-item").prepend(item)}})};VAA_View_Admin_As.assign_file_content=function(data){if("function"!==typeof FileReader){return}var param=data.hasOwnProperty("param")?data.param:{},$target=param.hasOwnProperty("target")?$(param.target):null,$element=param.hasOwnProperty("element")?$(param.element):null,wait=true;if(!$target||!$element){return}var files=$element[0].files,length=files.length,val="";if(length){$.each(files,function(key,file){var reader=new FileReader;reader.onload=function(){var content=VAA_View_Admin_As.maybe_json_decode(this.result);if("object"===typeof content){content=JSON.stringify(content)}val+=content;length--;if(!length){wait=false}};reader.readAsText(file)})}var areWeThereYet=setInterval(function(){if(!wait){$target.val(val);clearInterval(areWeThereYet)}},100)};VAA_View_Admin_As.autoMaxHeight=function(){if(!VAA_View_Admin_As.maxHeightListenerElements){return null}setTimeout(function(){var scroll_top="undefined"!==typeof window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;VAA_View_Admin_As.maxHeightListenerElements.each(function(){var $element=$(this),count=0,wait=setInterval(function(){var offset=$element.offset(),offset_top=offset.top-scroll_top;if($element.is(":visible")&&0$body.innerWidth()){$body.addClass("vaa-mobile");VAA_View_Admin_As._mobile=true;VAA_View_Admin_As.init_touch()}VAA_View_Admin_As.maxHeightListenerElements.each(function(){$(this).parents(".menupop").on("mouseenter",VAA_View_Admin_As.autoMaxHeight)});$(".vaa-resizable",$vaa).each(function(){var $this=$(this),maxHeight=parseInt($this.css("max-heights"),10),height,innerHeight,newHeight;$this.find(".ab-empty-item:empty").remove();$this.on("vaa-resizable",function(){if($this.is(":empty")){$this.css({"max-height":"",height:"",resize:""});return}newHeight=maxHeight;height=$this.height();$this.css({"max-height":"",height:"",resize:""});if(height){$this.css({"max-height":"none"});innerHeight=$this.height();$this.css({"max-height":""});if(innerHeight=maxHeight){if(innerHeight=maxHeight)){$this.css({"max-height":"none",height:newHeight?newHeight+"px":"",resize:"vertical"})}}).trigger("vaa-resizable")});$vaa.on("click touchend",".vaa-reset-item > .ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}if("vaa_reload"===$("button",this).attr("name")){window.location.reload()}else{VAA_View_Admin_As.ajax({reset:true},true);return false}});$.each(VAA_View_Admin_As.view_types,function(index,type){$vaa.on("click touchend",".vaa-"+type+"-item > a.ab-item",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this);if(VAA_View_Admin_As._mobile){var $parent=$this.parent();if($parent.hasClass("menupop")&&!$parent.hasClass("active")){$parent.addClass("active");$this.next().show();return false}}$this.data("vaa-continue-event",true).trigger("vaa-apply-view");if(!$this.parent().hasClass("not-a-view")&&$this.data("vaa-continue-event")){var view_data={},val=$this.find(".vaa-view-data").attr("vaa-view-value");view_data[type]=VAA_View_Admin_As.maybe_json_decode(val);if("object"===typeof view_data[type]){view_data=view_data[type]}VAA_View_Admin_As.ajax(view_data,true);return false}})});$vaa.on("click touchend",".remove",function(e){e.preventDefault();if(true===VAA_View_Admin_As._touchmove){return}$(this).parent().slideUp("fast",function(){$(this).remove()})})};VAA_View_Admin_As.init_touch=function(){var $root=$(".vaa-mobile "+VAA_View_Admin_As.prefix);$root.on("click touchend"," > .ab-sub-wrapper .ab-item",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();var $sub=$(this).parent(".menupop").children(".ab-sub-wrapper");if($sub.length){if($sub.hasClass("active")){$sub.slideUp("fast").removeClass("active")}else{$sub.slideDown("fast").addClass("active")}}});$root.on("click touchend","input, textarea, select",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.stopPropagation();var $this=$(this);if($this.is('[type="checkbox"]')){e.preventDefault();if($this.is(":checked")){$this.prop("checked",false)}else{$this.prop("checked",true)}$this.trigger("change");return false}else if($this.is('[type="radio"]')){e.preventDefault();$('input[name="'+$this.attr["name"]+'"]').removeAttr("checked");$this.prop("checked",true);$this.trigger("change");return false}return true});$root.on("click touchend","label",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();e.stopPropagation();$("#"+$(this).attr("for")).trigger(e.type);return false})};VAA_View_Admin_As.overlay=function(html){var $overlay=$("#vaa-overlay");if(false===html){$overlay.fadeOut("fast",function(){$(this).remove()});$document.off("mouseup.vaa_overlay");return}if(!$overlay.length){html='
    '+html+"
    ";$body.append(html);$overlay=$("body #vaa-overlay")}else if(html.length){$overlay.html(html)}$overlay.fadeIn("fast");$overlay.find(".remove").click(function(){VAA_View_Admin_As.overlay(false)});$document.on("mouseup.vaa_overlay",function(e){$overlay.find(".vaa-popup").each(function(){if(!$(this).is(e.target)&&0===$(this).has(e.target).length){VAA_View_Admin_As.overlay(false);return false}})})};VAA_View_Admin_As.ajax=function(data,refresh){$(".vaa-notice","#wpadminbar").remove();var loader_icon="";if(VAA_View_Admin_As._loader_icon){loader_icon=' style="background-image: url('+VAA_View_Admin_As._loader_icon+')"'}VAA_View_Admin_As.overlay('");var post_data={action:"view_admin_as",_vaa_nonce:VAA_View_Admin_As._vaa_nonce,view_admin_as:JSON.stringify(data)};var isView=false;$.each(VAA_View_Admin_As.view_types,function(index,type){if("undefined"!==typeof data[type]){isView=true;return true}});if($(VAA_View_Admin_As.prefix+"#vaa-settings-view-mode-single").is(":checked")&&isView){$body.append('');var $form=$("#vaa_single_mode_form");$form.append('');$form.append('');$form.append('');$form.find("#data").val(post_data.view_admin_as);$form.submit()}else{$.post(VAA_View_Admin_As.ajaxurl,post_data,function(response){var success=response.hasOwnProperty("success")&&true===response.success,data={},display=false;VAA_View_Admin_As.debug(response);if(response.hasOwnProperty("data")){if("object"===typeof response.data){data=response.data;if(data.hasOwnProperty("display")){display=data.display}}}if(success){if("download"===refresh){VAA_View_Admin_As.download(data);VAA_View_Admin_As.overlay(false);return}else if(refresh){VAA_View_Admin_As.refresh(data);return}else{if(!data.hasOwnProperty("text")){data.text=VAA_View_Admin_As.__success}}}if(!data.hasOwnProperty("type")){data.type=success?"success":"error"}if("popup"===display){VAA_View_Admin_As.popup(data,data.type)}else{if(!data.hasOwnProperty("text")){data.text=response.data}VAA_View_Admin_As.notice(String(data.text),data.type,5e3);$("body #vaa-overlay").addClass(data.type).fadeOut("fast",function(){$(this).remove()})}})}};VAA_View_Admin_As.refresh=function(data){if(data.hasOwnProperty("redirect")){window.location.replace(String(data.redirect))}else{window.location.hash="";window.location.reload()}};VAA_View_Admin_As.notice=function(notice,type,timeout){var root="#wpadminbar .vaa-notice",html=notice+'';type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;if(VAA_View_Admin_As._mobile){html='";$(VAA_View_Admin_As.prefix+"> .ab-sub-wrapper").prepend(html).children(".vaa-notice").slideDown("fast");$("html, body").animate({scrollTop:"0"});if(timeout){setTimeout(function(){$(root).slideUp("fast",function(){$(this).remove()})},timeout)}}else{html='
  • '+html+"
  • ";$("#wp-admin-bar-top-secondary").append(html);$(root+" .remove").click(function(){$(this).parent().remove()});if(timeout){setTimeout(function(){$(root).fadeOut("fast",function(){$(this).remove()})},timeout)}}};VAA_View_Admin_As.item_notice=function(parent,notice,type,timeout){var root=".vaa-notice",html=notice+'',$element=$(parent);type="undefined"===typeof type?"notice":type;timeout="undefined"===typeof timeout?5e3:timeout;html='";$element.append(html).children(".vaa-notice").slideDown("fast");if(timeout){setTimeout(function(){$(root,$element).slideUp("fast",function(){$(this).remove()})},timeout)}};VAA_View_Admin_As.item_confirm=function(parent,text){$(parent).find(".vaa-notice").slideUp("fast",function(){$(this).remove()});text='";VAA_View_Admin_As.item_notice(parent,text,"warning",0);return $(parent).find(".vaa-confirm")};VAA_View_Admin_As.popup=function(data,type){type="undefined"===typeof type?"notice":type;var html="";html+='
    ';html+='';html+='
    ';if("object"!==typeof data){data={text:data}}if(data.hasOwnProperty("text")){html+="

    "+String(data.text)+"

    "}if(data.hasOwnProperty("list")&&"object"===typeof data.list){html+="
      ";$.each(data.list,function(key,value){html+="
    • "+String(value)+"
    • "});html+="
    "}if(data.hasOwnProperty("textarea")){html+='"}html+="
    ";VAA_View_Admin_As.overlay(html);var root="#vaa-overlay",$overlay=$(root),$popup=$(root+" .vaa-popup"),$popup_content=$(root+" .vaa-popup-content");var textarea=$("textarea",$popup_content);if(textarea.length){textarea.on("click",function(){$(this).select()})}var popupMaxHeight=function(){if(textarea.length){textarea.each(function(){$(this).css({height:"auto","overflow-y":"hidden"}).height(this.scrollHeight)})}var max_height=$overlay.height()*.8-24;$popup.css("max-height",max_height);$popup_content.css("max-height",max_height)};popupMaxHeight();$window.on("resize",function(){popupMaxHeight()})};VAA_View_Admin_As.download=function(data){var content="",filename="";if("string"===typeof data){content=data}else{if(data.hasOwnProperty("download")){content=String(data.download)}else if(data.hasOwnProperty("textarea")){content=String(data.textarea)}else if(data.hasOwnProperty("content")){content=String(data.content)}}content=VAA_View_Admin_As.maybe_json_decode(content);if("object"===typeof content){content=JSON.stringify(content,null,"\t")}if(!content){return}if(data.hasOwnProperty("filename")){filename=data.filename}var link="data:application/octet-stream;charset=utf-8,"+encodeURIComponent(content);$body.append('');document.getElementById("vaa_temp_download").click();$("a#vaa_temp_download").remove()};VAA_View_Admin_As.init_auto_js=function(){$(VAA_View_Admin_As.root+" [vaa-auto-js]").each(function(){var $this=$(this),data=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-auto-js"));if("object"!==typeof data){return}if(!data.hasOwnProperty("event")){data.event="change"}if("click"===data.event){data.event="click touchend"}$this.on(data.event,function(e){if("change"!==data.event&&true===VAA_View_Admin_As._touchmove){return}e.preventDefault();VAA_View_Admin_As.do_auto_js(data,this);return false})});VAA_View_Admin_As.do_auto_js=function(data,elem){if("object"!==typeof data){return}var $elem=$(elem),setting=data.hasOwnProperty("setting")?String(data.setting):null,confirm=data.hasOwnProperty("confirm")?Boolean(data.confirm):false,refresh=data.hasOwnProperty("refresh")?Boolean(data.refresh):false;if(data.hasOwnProperty("callback")){VAA_View_Admin_As[data.callback](data);return}var val=VAA_View_Admin_As.get_auto_js_values_recursive(data,elem);if(null!==val){if(!setting){return}var view_data={};view_data[setting]=val;if(data.hasOwnProperty("download")&&data.download){refresh="download"}if(confirm){confirm=VAA_View_Admin_As.item_confirm($elem.parent(),VAA_View_Admin_As.__confirm);$(confirm).on("click",function(){VAA_View_Admin_As.ajax(view_data,refresh)})}else{VAA_View_Admin_As.ajax(view_data,refresh)}}else{}};VAA_View_Admin_As.get_auto_js_values_recursive=function(data,elem){if("object"!==typeof data){return null}var stop=false,val=null;if(data.hasOwnProperty("values")){val={};$.each(data.values,function(val_key,auto_js){if("object"!==typeof auto_js||null===auto_js){auto_js={}}auto_js.required=auto_js.hasOwnProperty("required")?Boolean(auto_js.required):true;var val_val=VAA_View_Admin_As.get_auto_js_values_recursive(auto_js,elem);if(null!==val_val){val[val_key]=val_val}else if(auto_js.required){val=null;stop=true;return false}});if(stop){return null}}else{val=VAA_View_Admin_As.parse_auto_js_value(data,elem)}return val};VAA_View_Admin_As.parse_auto_js_value=function(data,elem){if("object"!==typeof data){return null}var $elem=data.hasOwnProperty("element")?$(data.element):$(elem),parser=data.hasOwnProperty("parser")?String(data.parser):"",val=null;switch(parser){case"multiple":case"multi":val={};$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();val[value]=this.checked}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);val[$this.attr("name")]=value}});break;case"selected":val=[];$elem.each(function(){var $this=$(this),value;if("checkbox"===$this.attr("type")){value=data.hasOwnProperty("attr")?$this.attr(data.attr):$this.val();if(this.checked&&value){val.push(value)}}else{value=VAA_View_Admin_As.get_auto_js_value(this,data);if(value){val.push(value)}}});break;default:val=VAA_View_Admin_As.get_auto_js_value($elem,data);break}return val};VAA_View_Admin_As.get_auto_js_value=function(elem,data){if("object"!==typeof data){data={}}var $elem=$(elem),val=null,attr=data.hasOwnProperty("attr")?String(data.attr):false,json=data.hasOwnProperty("json")?Boolean(data.json):false,value=attr?$elem.attr(attr):$elem.val();if("checkbox"===$elem.attr("type")){var checked=$elem.is(":checked");if(attr){if(checked&&value){val=value}}else{val=checked}}else{if(value){val=value}}if(json){try{val=JSON.parse(val)}catch(err){val=null;VAA_View_Admin_As.popup("
    "+err+"
    ","error")}}return val}};VAA_View_Admin_As.init_users=function(){var root=VAA_View_Admin_As.root+"-users",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix),$search_node=$(root_prefix+" .ab-vaa-search.search-users"),ajax_delay_timer;if($search_node.length){var search_ajax=$search_node.hasClass("search-ajax"),$search_results=$search_node.find(".ab-vaa-results"),no_results='
    '+VAA_View_Admin_As.__no_users_found+"
    ";$root.on("keyup",".ab-vaa-search.search-users input",function(){var $this=$(this),search=$this.val();if(1<=search.trim().length){if(search_ajax){search={search:search,return:"links"};var search_by=$root.find(".ab-vaa-search.search-users select").val();if(search_by){search["search_by"]=search_by}VAA_View_Admin_As.search_users_ajax(search,$search_results)}else{search_users(search)}}else{VAA_View_Admin_As.search_users_ajax(null,$search_results)}})}function search_users(search){$search_results.empty();$(VAA_View_Admin_As.prefix+".vaa-user-item").each(function(){var $this=$(this),name=$this.find(".ab-item").text();if(-1 .ab-item > .vaa-view-data");role=role?role.text():"";if(role&&false!==exists&&exists.length){exists.find(".user-role").text(exists.find(".user-role").text().replace(")",", "+role+")"))}else{role=role?'  ('+role+")":"";$this.clone().appendTo($search_results).children(".ab-item").append(role)}}});if(""===$.trim($search_results.html())){$search_results.html(no_results)}VAA_View_Admin_As.autoMaxHeight()}VAA_View_Admin_As.search_users_ajax=function(search,results_container){clearTimeout(ajax_delay_timer);var $results_container=$(results_container);if(!search){$results_container.empty();if($results_container.hasClass("vaa-resizable")){$results_container.trigger("vaa-resizable")}return}ajax_delay_timer=setTimeout(function(){$results_container.html('
    . . .
    ');var $loading=$(".ab-item",$results_container),loading=". . . ",loading_interval=setInterval(function(){if(20 .ab-item"}}combine_types.push("caps");combine_selectors["caps"]=VAA_View_Admin_As.prefix+VAA_View_Admin_As.root+"-caps > .menupop > .ab-item";VAA_View_Admin_As.reinit_combine_views=function(){if(is_active){enable_combine_views()}else{add_combine_checkboxes()}$.each(selection,function(type,data){data.el=$(data.el);if(!data.el.length||!data.el.closest("body").length){data.el=$(VAA_View_Admin_As.prefix+".vaa-combine-item[vaa-view-type="+data.type+"][vaa-view-value="+data.value+"]")}if(data.el.length){data.el.prop("checked",true);activate_combine_type(data.el,data.type,data.value)}})};function enable_combine_views(){is_active=true;add_combine_checkboxes();$combine_items=$(VAA_View_Admin_As.prefix+".vaa-combine-item");$combine_items.fadeIn("fast");update_selection_list()}function disable_combine_views(){is_active=false;$(VAA_View_Admin_As.prefix+".vaa-combine-item").fadeOut("fast");if($selection_container.is(":visible")){$selection_container.slideUp("fast")}else{$selection_container.hide()}}function add_combine_checkboxes(elements,type){if(!elements||!type){for(var key in combine_selectors){if(combine_selectors.hasOwnProperty(key)){add_combine_checkboxes(combine_selectors[key],key)}}return}var $elements=$(elements);$elements.each(function(){var $this=$(this),$parent=$this.parent(),val=null,text=$this.text(),$data_el=$this.find(".vaa-view-data"),label,attr;if($parent.find(".vaa-combine-item").length){return true}if($data_el.length){val=$data_el.attr("vaa-view-value");text=$data_el.text();label=$data_el.attr("vaa-view-type-label")}if("caps"===type){val="";text=$(VAA_View_Admin_As.root+"-caps-title > .ab-item").text()}attr=['type="checkbox"','class="checkbox vaa-right vaa-combine-item vaa-combine-'+type+'"','vaa-view-type="'+type+'"',"vaa-view-value='"+val+"'",'vaa-view-text="'+text+'"','style="display:none;"'];if(label){attr.push('vaa-view-type-label="'+label+'"')}$parent.prepend("")})}function parse_combine_type(element,type){var $element=$(element),val;if("caps"===type){val=type}else{val=VAA_View_Admin_As.maybe_json_decode($element.attr("vaa-view-value"));if("object"===typeof val){$.each(val,function(val_type,data){var $val_element=$(VAA_View_Admin_As.prefix+".vaa-combine-"+val_type+"[vaa-view-value="+data+"]");activate_combine_type($val_element,val_type,data)});$element.prop({checked:true,disabled:false});return}}activate_combine_type($element,type,val)}function activate_combine_type(element,type,value){var $element=$(element);deactivate_combine_type(type,false);selection[type]={el:$element,type:type,value:value};$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:true});$element.prop({checked:true,disabled:false});update_selection_list()}function deactivate_combine_type(types,update){if("object"!==typeof types){type=types;types={};types[type]=0}for(var type in types){if(types.hasOwnProperty(type)){delete selection[type];$(VAA_View_Admin_As.prefix+".vaa-combine-"+type).prop({checked:false,disabled:false})}}if(update){update_selection_list()}}function update_selection_list(){$(root_prefix+" .vaa-combine-selection").each(function(){var $this=$(this),type=$this.attr("vaa-view-type");if(!selection.hasOwnProperty(type)){$this.slideUp("fast",function(){$(this).remove()})}});$.each(selection,function(type,data){var text=data.el.attr("vaa-view-text")+'',$existing=$(root_prefix+" .vaa-combine-selection-"+type),label=data.el.attr("vaa-view-type-label");if(label){text=''+label+": "+text}if($existing.length){$existing.html(text);if("none"===$existing.css("display")||!$existing.is(":visible")){$existing.slideDown("fast")}}else{var attr=['class="ab-item ab-empty-item vaa-combine-selection vaa-combine-selection-'+type+'"','vaa-view-type="'+type+'"','style="display:none;"'];var html="
  • "+text+"
  • ";$selection_container.append(html);$(root_prefix+" .vaa-combine-selection-"+type).slideDown("fast")}});if(is_active&&!$.isEmptyObject(selection)){if("none"===$selection_container.css("display")||!$selection_container.is(":visible")){$selection_container.slideDown("fast")}}else{$selection_container.slideUp("fast")}}$root.on("change","input#"+prefix,function(){$selection_container=$($selection_container);if(true===VAA_View_Admin_As._touchmove){return}if(this.checked){enable_combine_views()}else{disable_combine_views()}});$vaa.on("change","input.vaa-combine-item",function(){if(true===VAA_View_Admin_As._touchmove){return}var $this=$(this),type=$this.attr("vaa-view-type");if(this.checked){parse_combine_type($this,type)}else{var val=VAA_View_Admin_As.maybe_json_decode($this.attr("vaa-view-value"));if("object"===typeof val){deactivate_combine_type(val,true);return}deactivate_combine_type(type,true)}});$root.on("click touchend",".vaa-combine-selection .remove",function(){if(true===VAA_View_Admin_As._touchmove){return}deactivate_combine_type($(this).parent().attr("vaa-view-type"),true)});$root.on("click touchend","button#"+prefix+"-apply",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var view_data={};for(var type in selection){if(selection.hasOwnProperty(type)){if("caps"===type){view_data[type]=VAA_View_Admin_As.get_selected_capabilities()}else{view_data[type]=selection[type].value}}}if(!$.isEmptyObject(view_data)){VAA_View_Admin_As.ajax(view_data,true)}else{}});$.each(combine_types,function(index,type){$vaa.on("vaa-apply-view",".vaa-"+type+"-item > a.ab-item",function(e){if(!is_active){return}e.preventDefault();var $this=$(this);if(!$this.parent().hasClass("not-a-view")){if(!VAA_View_Admin_As._mobile){var $combine_item=$this.parent().children(".vaa-combine-item");if($combine_item.is(":checked")){$combine_item.prop("checked",false)}else{$combine_item.prop("checked",true)}$combine_item.trigger("change")}e.stopPropagation();e.stopImmediatePropagation();$this.data("vaa-continue-event",false);return false}})})};VAA_View_Admin_As.init_module_role_defaults=function(){var root=VAA_View_Admin_As.root+"-role-defaults",prefix="vaa-role-defaults",root_prefix=VAA_View_Admin_As.prefix+root,$root=$(root_prefix);if(!$root.length){return}$root.on("click touchend",root+"-meta-add button#"+prefix+"-meta-add",function(e){if(true===VAA_View_Admin_As._touchmove){return}e.preventDefault();var val=$(root_prefix+"-meta-add input#"+prefix+"-meta-new").val(),item=$(root_prefix+"-meta-add #"+prefix+"-meta-template").html().toString();val=val.replace(/ /g,"_");item=item.replace(/vaa_new_item/g,val);if($(root_prefix+'-meta-select input[value="'+val+'"]').length){VAA_View_Admin_As.item_notice($(this).parent(),VAA_View_Admin_As.__key_already_exists,"error",2e3)}else{$(root_prefix+"-meta-select > .ab-item").prepend(item)}});if($root.find(root+"-bulk-users-filter").length){$root.on("keyup",root+"-bulk-users-filter input#"+prefix+"-bulk-users-filter",function(e){e.preventDefault();var $items=$(root_prefix+"-bulk-users-select .ab-item.vaa-item");if(1<=$(this).val().length){var input_text=$(this).val();$items.each(function(){var name=$(".user-name",this).text();if(-1 .ab-item").prepend(item)}})};VAA_View_Admin_As.assign_file_content=function(data){if("function"!==typeof FileReader){return}var param=data.hasOwnProperty("param")?data.param:{},$target=param.hasOwnProperty("target")?$(param.target):null,$element=param.hasOwnProperty("element")?$(param.element):null,wait=true;if(!$target||!$element){return}var files=$element[0].files,length=files.length,val="";if(length){$.each(files,function(key,file){var reader=new FileReader;reader.onload=function(){var content=VAA_View_Admin_As.maybe_json_decode(this.result);if("object"===typeof content){content=JSON.stringify(content)}val+=content;length--;if(!length){wait=false}};reader.readAsText(file)})}var areWeThereYet=setInterval(function(){if(!wait){$target.val(val);clearInterval(areWeThereYet)}},100)};VAA_View_Admin_As.autoMaxHeight=function(){if(!VAA_View_Admin_As.maxHeightListenerElements){return null}setTimeout(function(){var scroll_top="undefined"!==typeof window.pageYOffset?window.pageYOffset:(document.documentElement||document.body.parentNode||document.body).scrollTop;VAA_View_Admin_As.maxHeightListenerElements.each(function(){var $element=$(this),count=0,wait=setInterval(function(){var offset=$element.offset(),offset_top=offset.top-scroll_top;if($element.is(":visible")&&0