From 9c4d7930208823e84922e06b201e8648a4a61494 Mon Sep 17 00:00:00 2001 From: EkoJR Date: Mon, 12 Jun 2017 05:40:51 -0700 Subject: [PATCH] Added Filter Meta Box Changed Admin Page #75 Fixed script conflicts with MagicMembers & others #44 #74 Added more Internalization #6 --- .gitignore | 6 + admin/class-apl-admin.php | 375 +++++- admin/css/admin.css | 195 +++- admin/css/jquery.multiselect.css | 36 +- admin/js/admin-ui.js | 668 ++++------- admin/js/admin.js | 1296 +-------------------- admin/js/jquery.multiselect.filter.min.js | 4 +- admin/js/jquery.multiselect.min.js | 6 +- admin/meta-box-filter.php | 383 ++++++ advanced-post-list.php | 33 +- includes/class/class-apl-core.php | 82 +- readme.txt | 2 +- 12 files changed, 1217 insertions(+), 1869 deletions(-) create mode 100644 admin/meta-box-filter.php diff --git a/.gitignore b/.gitignore index 5ebd21a..15a5cb0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,9 @@ +################# +## CUSTOM +################# + +*.bk + ################# ## Eclipse ################# diff --git a/admin/class-apl-admin.php b/admin/class-apl-admin.php index a30cdd9..7390d57 100644 --- a/admin/class-apl-admin.php +++ b/admin/class-apl-admin.php @@ -30,7 +30,23 @@ class APL_Admin { * @access private * @var null $instance Singleton Class Instance. */ - private static $instance = null; + protected static $instance = null; + + /** + * Summary. + * + * @since 0.4.0 + * @access private + * @var array( string ) + */ + private $_ignore_post_types = array( + 'attachment', + 'revision', + 'nav_menu_item', + 'apl_post_list', + 'apl_design', + ); + /** * Summary. @@ -60,10 +76,10 @@ class APL_Admin { * @return void */ public static function get_instance() { - if ( null === self::$instance ) { - self::$instance = new self; + if ( null === static::$instance ) { + static::$instance = new static(); } - return self::$instance; + return static::$instance; } /** @@ -106,19 +122,27 @@ private function __wakeup() { * @return void */ private function __construct() { - + // Exit if Non-Admins access this object. Also wrapped in APL_Core. if ( ! is_admin() ) { - return new WP_Error( 'apl_admin_construct', esc_html__( 'You do not have admin capabilities.', 'advanced-post-list' ) ); + return new WP_Error( 'apl_admin', esc_html__( 'You do not have admin capabilities.', 'advanced-post-list' ) ); } $this->_requires(); + // Menu & Scripts + add_action( 'admin_menu', array( $this, 'admin_menu' ) ); + + // Screen Options + add_action( 'admin_head', array( $this, 'disable_screen_boxes' ) ); + add_action( 'load-edit.php', array( $this, 'post_list_screen_all' ) ); + add_action( 'load-post-new.php', array( $this, 'post_list_screen_add_new' ) ); + + // Editor Meta Boxes + add_action( 'add_meta_boxes', array( $this, 'post_list_meta_boxes' ) ); + /* // Early Hook add_action( 'plugins_loaded', array( $this, 'hook_action_plugins_loaded' ) ); - // Multilingual Support - add_action( 'load_textdomain', array( $this, 'hook_action_load_textdomain' ) ); - // Plugin Init Hook add_action( 'init', array( $this, 'hook_action_init' ) ); @@ -128,11 +152,342 @@ private function __construct() { // WordPress Footer add_action( 'wp_footer', array( $this, 'hook_action_wp_footer' ) ); */ - } private function _requires() { //require_once( APL_DIR . 'includes/example.php' ); } + + public function admin_menu() { + // Add APL Dashboard + // Add APL Settings API + // Add Help API + + // Enqueue Scripts & Styles + add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue' ) ); + } + + public function admin_enqueue( $hook ) { + $screen = get_current_screen(); + + /* + * ************** REMOVE SCRIPTS & STYLES ********************* + */ + wp_deregister_script( 'apl-admin-js' ); + wp_deregister_script( 'apl-admin-ui-js' ); + wp_deregister_script( 'apl-admin-ui-multiselect-js' ); + wp_deregister_script( 'apl-admin-ui-multiselect-filter-js' ); + + wp_deregister_style( 'apl-admin-css' ); + wp_deregister_style( 'apl-admin-ui-multiselect-css' ); + wp_deregister_style( 'apl-admin-ui-multiselect-filter-css' ); + + if ( 'apl_post_list' !== $screen->post_type ) { + return; + } else { + + /* + * ************** AJAX ACTION HOOKS *************************** + */ + add_action( 'wp_ajax_apl_load_preset', array( $this, 'hook_ajax_load_preset' ) ); + + /* + * ************** REGISTER SCRIPTS **************************** + */ + + // Step 4. + wp_register_script( + 'apl-admin-js', + APL_URL . 'admin/js/admin.js', + array( + 'jquery', + //'jquery-ui-core', + //'jquery-ui-widget', + //'jquery-ui-dialog', + ), + APL_VERSION, + false + ); + + wp_register_script( + 'apl-admin-ui-js', + APL_URL . 'admin/js/admin-ui.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + 'jquery-ui-tabs', + 'jquery-ui-spinner', + 'jquery-ui-slider', + 'jquery-ui-button', + 'jquery-ui-dialog', + 'jquery-ui-selectmenu', + //'jquery-ui-checkboxradio', + //'jquery-ui-accordion', + + ), + APL_VERSION, + false + ); + + wp_register_script( + 'apl-admin-ui-multiselect-js', + APL_URL . 'admin/js/jquery.multiselect.min.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + 'jquery-ui-selectmenu', + ), + APL_VERSION, + false + ); + + wp_register_script( + 'apl-admin-ui-multiselect-filter-js', + APL_URL . 'admin/js/jquery.multiselect.filter.min.js', + array( + 'jquery', + 'jquery-ui-core', + 'jquery-ui-widget', + ), + APL_VERSION, + false + ); + + wp_enqueue_script( 'apl-admin-js' ); + wp_enqueue_script( 'apl-admin-ui-js' ); + wp_enqueue_script( 'apl-admin-ui-multiselect-js' ); + wp_enqueue_script( 'apl-admin-ui-multiselect-filter-js' ); + + /* + * ************** REGISTER STYLES ***************************** + */ + + // Step 5. + wp_enqueue_style( + 'apl-admin-css', + APL_URL . 'admin/css/admin.css', + false, + APL_VERSION, + false + ); + + $wp_scripts = wp_scripts(); + wp_enqueue_style( + 'apl-admin-ui-css', + 'https://ajax.googleapis.com/ajax/libs/jqueryui/' . $wp_scripts->registered['jquery-ui-core']->ver . '/themes/smoothness/jquery-ui.css', + false, + APL_VERSION, + false + ); + + wp_enqueue_style( + 'apl-admin-ui-multiselect-css', + APL_URL . 'admin/css/jquery.multiselect.css', + false, + APL_VERSION, + false + ); + + wp_enqueue_style( + 'apl-admin-ui-multiselect-filter-css', + APL_URL . 'admin/css/jquery.multiselect.filter.css', + false, + APL_VERSION, + false + ); + + // POST LISTS DATA. + $data_post_lists = array(); + $args = array( + //'post_status' => 'publish', + 'post_type' => 'apl_post_list', + ); + $post_post_list = get_posts( $args ); + foreach ( $post_post_list as $key => $value ) { + $data_post_lists[ $value->post_name ] = new APL_Post_List( $value->post_name ); + } + + // DESIGNS DATA. + $data_designs = array(); + $args = array( + 'post_status' => 'publish', + 'post_type' => 'apl_design', + ); + $post_designs = get_posts( $args ); + foreach ( $post_designs as $key => $value ) { + $data_designs[ $value->post_name ] = new APL_Design( $value->post_name ); + } + + // POST => TAXONOMIES. + $data_post_tax = $this->get_post_tax(); + + // TAXONOMIES => TERMS + $data_tax_terms = $this->get_tax_terms(); + + $data_ui_trans = array( + 'tax_noneSelectedText' => esc_html__( 'Select Taxonomy', 'advanced-post-list' ), + 'tax_selectedText' => esc_html__( '# of # taxonomies selected', 'advanced-post-list' ), + ); + + $admin_localize = array(); + $admin_ui_localize = array( + //'post_type_objs' + //'taxonomy_objs' + //'term_objs' + 'post_tax' => $data_post_tax, + 'tax_terms' => $data_tax_terms, + 'trans' => $data_ui_trans, + ); + + wp_localize_script( 'apl-admin-js', 'apl_admin_local', $admin_localize ); + wp_localize_script( 'apl-admin-ui-js', 'apl_admin_ui_local', $admin_ui_localize ); + } + + + } + + public function disable_screen_boxes() { + echo ''; + echo ''; + } + + // Screen Options tab at top. + public function post_list_screen_all() { + $screen = get_current_screen(); + // Get out of here if we are not on our settings page. + if( ! is_object( $screen ) || $screen->id !== 'edit-apl_post_list' ) + return; + $options = $screen->get_options(); + } + + public function post_list_screen_add_new() { + $screen = get_current_screen(); + // Get out of here if we are not on our settings page. + if( ! is_object( $screen ) || $screen->id !== 'apl_post_list' ) { + return; + } + $options = $screen->get_options(); + + /* + $args = array( + 'label' => __('Members per page', 'pippin'), + 'default' => 10, + 'option' => 'pippin_per_page' + ); + add_screen_option( 'per_page', $args ); + */ + } + + public function post_list_meta_boxes() { + add_meta_box( + 'apl-post-list-filter', + __( 'Filter Settings', 'advanced-post-list' ), + array( $this, 'post_list_meta_box_filter' ), + 'apl_post_list', + 'advanced', + 'sorted' + ); + add_meta_box( + 'apl-post-list-display', + __( 'Display Settings', 'advanced-post-list' ), + array( $this, 'post_list_meta_box_display' ), + 'apl_post_list', + 'advanced', + 'core' + ); + } + public function post_list_meta_box_filter( $post, $metabox ) { + // ob_start. + + $apl_post_tax = $this->get_post_tax(); + $apl_tax_terms = $this->get_tax_terms(); + $apl_display_post_types = $this->get_display_post_types(); + + include( APL_DIR . 'admin/meta-box-filter.php' ); + + } + public function post_list_meta_box_display( $post, $metabox ) { + echo '

Hello2

'; + var_dump( $metabox ); + } + + /* + * ************************************************************************* + * **** PRIVATE FUNCTIONS ************************************************** + * ************************************************************************* + */ + private function get_post_tax() { + $rtn_post_tax = array(); + + // Get Post Type names. + $post_type_obj = get_post_types( '', 'objects' ); + + // Remove ignored Post Types. + foreach ( $this->_ignore_post_types as $value ) + { + unset( $post_type_obj[ $value ] ); + } + + // Add to rtn {post_type} => {array( taxonomies )}. + $rtn_post_tax['any']['name'] = __( 'Any / All', 'advanced-post-list' ); + $taxonomy_names = get_taxonomies( '', 'names' ); + foreach ( $taxonomy_names as $name ) { + $rtn_post_tax['any']['tax_arr'][] = $name; + } + + foreach ( $post_type_obj as $key => $value ) { + $rtn_post_tax[ $key ]['name'] = $value->labels->singular_name; + $rtn_post_tax[ $key ]['tax_arr'] = get_object_taxonomies( $key, 'names' ); + } + + // Return Post_Tax. + return $rtn_post_tax; + } + + private function get_tax_terms() { + $rtn_tax_terms = array(); + + // Get Taxonomy Names + $taxonomy_names = get_taxonomies( '', 'names' ); + + // Loop foreach taxonomy. Get terms, and foreach term add to taxonomy. + foreach ( $taxonomy_names as $taxonomy ) { + $args = array( + 'taxonomy' => $taxonomy, + 'hide_empty' => false, + ); + $terms = get_terms( $args ); + + // Set slug. + $rtn_tax_terms[ $taxonomy ] = array(); + foreach ( $terms as $term ) { + $rtn_tax_terms[ $taxonomy ][] = $term->slug; + } + } + + // Return Tax_Terms + return $rtn_tax_terms; + } + + // Get post types that aren't ignored ( without 'any' as used in post_tax ). + private function get_display_post_types() { + $rtn_post_types = array(); + + $post_type_objs = get_post_types( '', 'objects' ); + // Remove ignored Post Types. + foreach ( $this->_ignore_post_types as $value ) + { + unset( $post_type_objs[ $value ] ); + } + + foreach ( $post_type_objs as $key => $value ) { + $rtn_post_types[ $key ] = $value->labels->singular_name; + } + + return $rtn_post_types; + } + } diff --git a/admin/css/admin.css b/admin/css/admin.css index 64b7c5d..4e00e6b 100644 --- a/admin/css/admin.css +++ b/admin/css/admin.css @@ -1,74 +1,151 @@ - .txtHeader - { - width:610px; - position:absolute; - left:290px; - } - -/*OPTION SECTION ON APL_admin PAGE*/ -#containerOptions { - height: 416px; - max-width: 800px; - min-width: 720px; -} -#optionsHeader { - margin-bottom: 5px; - width: auto; - min-height: 20px; -} -#optionL { +/** + * APL Admin UI CSS + * + * Scripts: jQuery, jQuery UI, jQuery UI Multiselect + */ + +.ui-tabs-anchor { + padding: .1em 1em !important; +} + +.ui-multiselect-close { + display: none; +} + +.apl-filter-box-1 { + display: flex; + margin-bottom: 18px; +} + +.apl-left-minibar { float: left; - width: 48%; - height: 100%; - margin: 5px; + width: 20%; } -#optionR { - float: right; - width: 48%; - height: 100%; - margin: 5px; + +.apl-filter-post-tax-query { + float: left; + width: 80%; +} + +.apl-tabs-post_type-type { + height: 405px; +} + +.apl-tabs-post-type-taxonomies { + height: 300px; +} + +.apl-t-li-post-type { + float: right !important; +} + +.apl-t-li-post-type h5 { + margin: initial; +} + +.apl-tabs-post-type-taxonomies > ul { + min-height: 22px; +} + +.apl-t-terms { + overflow-x: hidden !important; +} + +.apl-t-terms label {} + +.apl-filter-box-2 { + display: flex; + margin-bottom: 18px; +} + +.apl-filter-box-2-left { + float: left; + margin-right: 3%; + width: 57%; } -.optionL-row { - min-height: 26px; + +.apl-filter-box-2-right { + float: left; + width: 40%; } -.optionR-row { - min-height: 26px; - margin-right: 25px; - margin-top: 9px; + +.apl-filter-field-left-row { + min-height: 42px; } -#options1 { - width: 335px; - margin-right: 25px; - margin-top: 5px; - margin-bottom: 5px; - margin-left: 5px; + +.apl-filter-field-right-row { + min-height: 42px; } -#options2 { - width: 335px; - margin-right: 25px; - margin-top: 5px; - margin-bottom: 5px; - margin-left: 5px; + +.apl-filter-field-row-full { + min-height: 42px; } -.info-icon { - cursor: help; +.apl-filter-field-left-row > div:first-child { + float: left; + width: 35%; } -.ui-button-text { - padding: .4em 1em !important; -} -.info_a_link { - cursor: help; - font-size: 75% + +.apl-filter-field-left-row > div:nth-child( 2 ) { + float: left; + width: 65%; } -/* -.ui-accordion-header { cursor: none; } +.apl-amount-alt { + height: 27px; + padding-top: 15px; +} -.ui-accordion-header { padding-left: 0 } +apl-filter-field-right-row > input { + float: right; +} +apl-filter-field-right-row > input:after { + clear: both; +} -.ui-button { margin-left: -1px; } +.apl-ui-ms { + display: inline-block; + overflow: hidden; + position: relative; + text-decoration: none; + cursor: pointer; + + padding: 0 !important; +} -.ui-autocomplete-input { margin: 0; padding: 0.48em 0 0.47em 0.45em; } -*/ +.apl-ui-ms > span.ui-icon { + right: 0.5em; + left: auto; + margin-top: -8px; + position: absolute; + top: 50%; +} + +.apl-ui-ms > span:nth-child(2) { + float: left; + text-align: left; + padding: 0.4em 1.5em 0.4em 1em; + display: block; + line-height: 1.4; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +button.apl-ui-ms-filter-2-row { + width: 48.0% !important; +} + +span.apl-ui-ms-filter-2-row { + width: 47.2% !important; +} + +input.apl-text-exclude-posts { + width: 100%; +} + +.apl-chkbox-input { + float: right; + margin-top: 5px !important; +} diff --git a/admin/css/jquery.multiselect.css b/admin/css/jquery.multiselect.css index ec4dd82..735fed3 100644 --- a/admin/css/jquery.multiselect.css +++ b/admin/css/jquery.multiselect.css @@ -1,30 +1,26 @@ .ui-multiselect { padding:2px 0 2px 4px; text-align:left } .ui-multiselect span.ui-icon { float:right } -.ui-multiselect-single .ui-multiselect-checkboxes input { position:absolute !important; top: auto !important; left:-9999px; } +.ui-multiselect-single .ui-multiselect-checkboxes input { left:-9999px; position:absolute !important; top: auto !important; } .ui-multiselect-single .ui-multiselect-checkboxes label { padding:5px !important } -.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px } +.ui-multiselect-header { margin-bottom:3px; padding:3px 0 3px 4px; } .ui-multiselect-header ul { font-size:0.9em } -.ui-multiselect-header ul li { float:left; padding:0 10px 0 0 } -.ui-multiselect-header a { text-decoration:none } -.ui-multiselect-header a:hover { text-decoration:underline } -.ui-multiselect-header span.ui-icon { float:left } -.ui-multiselect-header li.ui-multiselect-close { float:right; text-align:right; padding-right:0 } +.ui-multiselect-header ul li { float:left; padding:0 10px 0 0; } +.ui-multiselect-header a { text-decoration:none; } +.ui-multiselect-header a:hover { text-decoration:underline; } +.ui-multiselect-header span.ui-icon { float:left; } +.ui-multiselect-header .ui-multiselect-close { float:right; padding-right:0; text-align:right; } -.ui-multiselect-menu { display:none; padding:3px; position:absolute; z-index:10000; text-align: left } -.ui-multiselect-checkboxes { position:relative /* fixes bug in IE6/7 */; overflow-y:auto } -.ui-multiselect-checkboxes label { cursor:default; display:block; border:1px solid transparent; padding:3px 1px } +.ui-multiselect-menu { display:none; padding:3px; position:absolute; text-align: left; } +.ui-multiselect-checkboxes { overflow-y:auto; position:relative; } +.ui-multiselect-checkboxes label { border:1px solid transparent; cursor:default; display:block; padding:3px 1px; } .ui-multiselect-checkboxes label input { position:relative; top:1px } -.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; padding-right:3px } -.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label { text-align:center; font-weight:bold; border-bottom:1px solid } -.ui-multiselect-checkboxes li.ui-multiselect-optgroup-label a { display:block; padding:3px; margin:1px 0; text-decoration:none } - -/* remove label borders in IE6 because IE6 does not support transparency */ -* html .ui-multiselect-checkboxes label { border:none } - +.ui-multiselect-checkboxes label img { height: 30px; vertical-align: middle; padding-right: 3px;} +.ui-multiselect-checkboxes li { clear:both; font-size:0.9em; list-style: none; padding-right:3px; } +.ui-multiselect-checkboxes .ui-multiselect-optgroup { padding: 3px; } +.ui-multiselect-columns { display: inline-block; vertical-align: top; } +.ui-multiselect-checkboxes .ui-multiselect-optgroup a { border-bottom:1px solid; cursor: pointer; display:block; font-weight:bold; margin:1px 0; padding:3px; text-align:center; text-decoration:none; } @media print{ - .ui-multiselect-menu {display: none;} - + .ui-multiselect-menu {display: none;} } - diff --git a/admin/js/admin-ui.js b/admin/js/admin-ui.js index 7d7c237..876d96d 100644 --- a/admin/js/admin-ui.js +++ b/admin/js/admin-ui.js @@ -1,441 +1,263 @@ -jQuery(document).ready(function($) -{ - // postTax: is the Post Type and Taxonomy structure - var post_types = apl_admin_ui_settings.post_types; - var postTax = apl_admin_ui_settings.postTax; - var taxTerms = apl_admin_ui_settings.taxTerms; - // postTax_parent_selector: show which Post Types are heirarchical - var postTax_parent_selector = apl_admin_ui_settings.postTax_parent_selector; +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +jQuery( document ).ready( function($) { + var post_tax = apl_admin_ui_local.post_tax; + var tax_terms = apl_admin_ui_local.tax_terms; + var trans = apl_admin_ui_local.trans; - - // Sets everything up inside the accordian divider - // -Parent Selector (MultiSelect) - // -Category & Tag UI Tabs - // -3 Checks (Possibly move to APL-admin.js) - for (var post_type_name in postTax) - { - - //Sets the MultiSelect Post Parent Selector - $("#slctParentSelector-" + post_type_name).multiselect({ - noneSelectedText: "Select Parent", - selectedText: "# of # pages selected", - selectedList: 2, - height: 192, - buttonWidth:230, - menuWidth:275, - - //Function for when an option is clicked and update/refreshed the element - click: function(event, ui) - { - - for (var post_type in post_types) - { - // GET/INIT Parent IDs array - var parentIDs = $("#slctParentSelector-" + post_type).val(); - if (parentIDs === null) - { - parentIDs = new Array(); - } - // INIT Temp Array to replace Parent Selector - var tmp_array = new Array(); - - //Going to add clicked value - if (ui.checked === true) - { - tmp_array = parentIDs; - //Add the value at the end of the Array - tmp_array[parentIDs.length] = ui.value; - } - //Going to withhold clicked value - else - { - var i = 0; - for (var parent_index in parentIDs) - { - //Prevent the value from being copied to the array - if (parentIDs[parent_index] !== ui.value) - { - tmp_array[i] = parentIDs[parent_index]; - i++; - } - } - } - $("#slctParentSelector-" + post_type).val(tmp_array); - $("#slctParentSelector-" + post_type).multiselect('refresh'); - } - }//END of click function - });//END of multiselect - - //Disables the Parent Selector/MultiSelect if the Post Type is non-heirarchical/posts - if (postTax_parent_selector[post_type_name]['hierarchical'] === false) - { - $("#slctParentSelector-" + post_type_name).multiselect("disable"); - } + init_chkbox_post_type_toggle_tabs(); - //$( "#chkReq-" + post_type_name ).button(); - //$( "#chkIncld-" + post_type_name ).button(); - - // Sets up the Categories UI Tabs - $("#tabs-" + post_type_name + '-cats').tabs(); - $('#tabs-' + post_type_name + '-cats').children().each(function(index, domEle) - { - var div_size = $(this).parent().height(); - - if (index !== 0) - { - var tab_size = $(this).parent().children().first().height(); - var change = div_size - tab_size; - - var domPadding = $('#' + domEle.id).outerHeight() - $('#' + domEle.id).height(); - - change -= (domPadding); - $(domEle).height(change); - - - } - }); - - // Sets up the Tags UI Tabs - $("#tabs-" + post_type_name + '-tags').tabs(); - $('#tabs-' + post_type_name + '-tags').children().each(function(index, domEle) - { - var div_size = $(this).parent().height(); + init_tabs_post_type_taxonomies(); - if (index !== 0) - { - var tab_size = $(this).parent().children().first().height(); - var change = div_size - tab_size; - - var domPadding = $('#' + domEle.id).outerHeight() - $('#' + domEle.id).height(); - - change -= (domPadding); - $(domEle).height(change); - } - }); - - - for (var taxonomy in postTax[post_type_name].taxonomies) - { - - $('#chkReqTerms-' + post_type_name + '-' + taxonomy).click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#chkTerm-' + name_explode[1] + '-' + name_explode[2] + '-0').attr('checked', false); - } - }); - - $('#chkIncldTerms-' + post_type_name + '-' + taxonomy).click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#chkTerm-' + name_explode[1] + '-' + name_explode[2] + '-0').attr('checked', false); - } - }); - - $('#chkTerm-' + post_type_name + '-' + taxonomy + '-0').click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#chkReqTerms-' + name_explode[1] + '-' + name_explode[2]).attr('checked', false); - $('#chkIncldTerms-' + name_explode[1] + '-' + name_explode[2]).attr('checked', false); - for (var term_index in taxTerms[name_explode[2]].terms) - { - $('#' + name_explode[0] + '-' + name_explode[1] + '-' + name_explode[2] + '-' + taxTerms[name_explode[2]].terms[term_index]).attr('checked', false); + init_multiselect_post_type_taxonomies(); + + init_spinner_amount(); + + init_slider_amount(); + + init_selectmenu_order_by(); + + init_selectmenu_order(); + + init_selectmenu_author_operator(); + + init_multiselect_author_ids(); + + init_multiselect_post_status_1(); + + init_multiselect_post_status_2(); + + init_selectmenu_perm(); - } - } - }); - - for (var term_index in taxTerms[taxonomy].terms) - { - - $('#chkTerm-' + post_type_name + '-' + taxonomy + '-' + taxTerms[taxonomy].terms[term_index]).click(function(){ - if (this.checked === true) - { - var name = this.name; - var name_explode = name.split("-"); - $('#' + name_explode[0] + '-' + name_explode[1] + '-' + name_explode[2] + '-0').attr('checked', false); - } - }); - } - } - }//END of foreach post_type + function init_chkbox_post_type_toggle_tabs() { + $( '#apl-toggle-any' ).prop( 'checked', true ); + $.each( post_tax, function( k_post_type_slug, v_taxonomy_arr ) { + if ( 'any' !== k_post_type_slug ) { + $( '#apl-filter-' + k_post_type_slug ).hide(); + } - $("#cboPostVisibility").multiselect({ - header: false, - noneSelectedText: "1 Req.", - selectedList: 1, - //buttonWidth: 96, Does NOTHING now. - minWidth: 96, - menuWidth: 128, - height: 69, - - click:function(event, ui) - { - var elemCbo = $("#cboPostVisibility").val(); - if (elemCbo === null) - { - elemCbo = new Array(); - } - var tmp_array = new Array(); - - if (ui.checked === true) - { - tmp_array = elemCbo; - //Add the value at the end of the Array - tmp_array[elemCbo.length] = ui.value; - } - else - { - var i = 0; - for (var elemCbo_index in elemCbo) - { - //Prevent the value from being copied to the array - if (elemCbo[elemCbo_index] !== ui.value) - { - tmp_array[i] = elemCbo[elemCbo_index]; - i++; - } - } - } + $( '#apl-toggle-' + k_post_type_slug ).change( function() { + if ( $( this ).is( ':checked' ) ) { + if ( 'any' !== k_post_type_slug ) { + $( '#apl-filter-' + k_post_type_slug ).show(); - $("#cboPostVisibility").val(tmp_array); - $("#cboPostVisibility").multiselect('refresh'); - - - }, - - //Prevents an empty value to be stored. At least 1 option must be selected - close:function(event,ui) - { - var values = $("#cboPostVisibility").val(); - if (values === null) - { - var default_value = new Array('public'); - $("#cboPostVisibility").val(default_value); - $("#cboPostVisibility").multiselect('refresh'); - } - } - }); - $("#cboPostStatus").multiselect({ - header: false, - noneSelectedText: "Any", - selectedList: 1, - //buttonWidth: 128, - minWidth: 128, - menuWidth: 160, - - click:function(event, ui) - { - var elemCbo = $("#cboPostStatus").val(); - if (elemCbo === null) - { - elemCbo = new Array(); - } - var tmp_array = new Array(); - - if (ui.checked === true) - { - tmp_array = elemCbo; - //Add the value at the end of the Array - tmp_array[elemCbo.length] = ui.value; - } - else - { - var i = 0; - for (var elemCbo_index in elemCbo) - { - //Prevent the value from being copied to the array - if (elemCbo[elemCbo_index] !== ui.value) - { - tmp_array[i] = elemCbo[elemCbo_index]; - i++; - } - } - } + $.each( v_taxonomy_arr.tax_arr, function( k2_tax_index, v2_tax_slug ) { + var target_div = '#apl-t-div-' + k_post_type_slug + '-' + v2_tax_slug; + $( target_div ).show(); + return false; + }); - $("#cboPostStatus").val(tmp_array); - $("#cboPostStatus").multiselect('refresh'); - - - } - }); + if ( $( '#apl-toggle-any' ).is( ':checked' ) ) { + $( '#apl-toggle-any' ).prop( 'checked', false ); + $( '#apl-filter-any' ).hide(); + } + } else { + $( this ).prop( 'checked', false ); + } + } else { + $( '#apl-filter-' + k_post_type_slug ).hide(); + + $( '#apl-toggle-any' ).prop( 'checked', true ); + $( '#apl-filter-any' ).show(); + $.each( post_tax, function( k2_post_type_slug, v2_taxonomy_arr ) { + if ( 'any' !== k2_post_type_slug && $( '#apl-toggle-' + k2_post_type_slug ).is( ':checked' ) ) { + $( '#apl-toggle-any' ).prop( 'checked', false ); + $( '#apl-filter-any' ).hide(); + } + }); + } + $( '#apl-tabs-' + k_post_type_slug + '-type' ).tabs( 'refresh' ); + $( '#apl-tabs-' + k_post_type_slug + '-taxonomies' ).tabs( 'refresh' ); + }); + + }); + } - $("#slctAuthorOperator").multiselect({ - multiple: false, - header: false, - selectedList: 1, - //buttonWidth: 96, - minWidth: 96, - menuWidth: 128, - height:96, - click:function(event, ui){ + function init_tabs_post_type_taxonomies () { + $.each( post_tax, function( k_post_type_slug, v_taxonomy_arr ) { + + + var first_tax = true; + $.each( v_taxonomy_arr.tax_arr, function( k_index, v_tax_slug ) { + var target_tab = '#apl-t-li-' + k_post_type_slug + '-' + v_tax_slug; + var target_div = '#apl-t-div-' + k_post_type_slug + '-' + v_tax_slug; + + if ( ! first_tax ) { + $( target_tab ).hide(); + $( target_div ).hide(); + } + + first_tax = false; + }); + $( '#apl-tabs-' + k_post_type_slug +'-taxonomies' ).tabs({ + heightStyle: "fill" + }); + $( '#apl-tabs-' + k_post_type_slug +'-type' ).tabs({ + heightStyle: "fill" + }); + + }); + } + + function init_multiselect_post_type_taxonomies() { + $.each( post_tax, function( k_pt_slug, v_tax_arr ) { + $( '#apl-multiselect-' + k_pt_slug ).multiselect({ + header: false, + noneSelectedText: trans.tax_noneSelectedText, + selectedText: trans.tax_selectedText, + selectedList: 2, + height: 150, + minWidth:333, + menuWidth:333, + + click: function( event, ui ) { + var target_tab = '#apl-t-li-' + ui.value; + var target_div = '#apl-t-div-' + ui.value; + + if ( true == ui.checked ) { + $( target_tab ).show(); + $( target_div ).show(); + + $( '#apl-tabs-' + k_pt_slug + '-taxonomies' ).tabs( 'refresh' ); + } else { + $( target_tab ).hide(); + $( target_div ).hide(); + + $( '#apl-tabs-' + k_pt_slug + '-taxonomies' ).tabs( 'refresh' ); + $( target_div ).hide(); + } + }, + }); + + $( '#apl-multiselect-' + k_pt_slug ).multiselect( 'widget' ).find(':checkbox[value="' + k_pt_slug + '-' + v_tax_arr.tax_arr[ 0 ] + '"]').prop('checked', true); + + }); + } + + function init_spinner_amount() { + $( '.apl-spinner-amount' ).spinner({ + min: -1, + change: function( event, ui ) {}, + spin: function( event, ui ) {} + }); + } + + function init_slider_amount() { + $( '.apl-slider-amount' ).slider({ + value: $( '.apl-spinner-amount' ).spinner( 'value' ), + min: -1, + max: 101, + create: function() { + //$( '#apl_list_amount_slider' ).text( $( '#apl_list_amount_spinner' ).spinner( "value" ) ); + $( '.apl-slider-handle-amount' ).text( $( this ).slider( 'value' ) ); + }, + slide: function( event, ui ) { + $( '.apl-slider-handle-amount' ).text( ui.value ); + } + }); + } + + function init_selectmenu_order_by() { + $( '.apl-selectmenu-order-by' ).selectmenu({ + + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + } +// change: function( event, ui ) { +// +// } + }); + } + + function init_selectmenu_order() { + $( '.apl-selectmenu-order' ).selectmenu({ + disabled: true, + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + } + }); + } + + function init_selectmenu_author_operator() { + $( '.apl-selectmenu-author-operator' ).selectmenu({ + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + } + + }); + } + + function init_multiselect_author_ids() { + $( '.apl-multiselect-author-ids' ).multiselect({ + classes: 'apl-ui-ms apl-ui-ms-filter-2-row', + header: false, + noneSelectedText: 'string', + selectedText: 'string', + selectedList: 1, + height: 200, + minWidth:100, + menuWidth:100, + click: function( event, ui ) { + + } + }); + } + + function init_multiselect_post_status_1() { + $( '.apl-multiselect-post-status-1' ).multiselect({ + classes: 'apl-ui-ms apl-ui-ms-filter-2-row', + header: false, + noneSelectedText: 'string', + selectedText: 'string', + selectedList: 1, + height: 150, + /* minWidth:'45%', // admin.css button.apl-ui-ms-filter-2-row */ + menuWidth:150, + click: function( event, ui ) { + + } + }) + } + + function init_multiselect_post_status_2() { + $( '.apl-multiselect-post-status-2' ).multiselect({ + classes: 'apl-ui-ms apl-ui-ms-filter-2-row', + header: false, + noneSelectedText: 'string', + selectedText: 'string', + selectedList: 1, + height: 300, + minWidth:'45%', + menuWidth:150, + click: function( event, ui ) { + + } + }) + } + + function init_selectmenu_perm() { + $( '.apl-selectmenu-perm' ).selectmenu({ + create: function( event, ui ) { + $( '#' + this.id + '-button' ).addClass( 'apl-ui-ms-filter-2-row' ); + }, + change: function( event, ui ) { + + } + }); + } + + +}); - if (ui.value === "none") - { - var newArr = new Array(); - $("#cboAuthorIDs").val(newArr); - $("#cboAuthorIDs").multiselect('refresh'); - $("#cboAuthorIDs").multiselect("disable"); - } - else - { - $("#cboAuthorIDs").multiselect("enable"); - } - $("#slctAuthorOperator").val(ui.value); - $("#slctAuthorOperator").multiselect('refresh'); - } - }); - $("#cboAuthorIDs").multiselect({ - header: false, - noneSelectedText: '-None-', - selectedList: 1, - //buttonWidth: 128, - minWidth: 128, - menuWidth: 256, - - click:function(event, ui) - { - var elemCbo = $("#cboAuthorIDs").val(); - if (elemCbo === null) - { - elemCbo = new Array(); - } - var tmp_array = new Array(); - - if (ui.checked === true) - { - tmp_array = elemCbo; - //Add the value at the end of the Array - tmp_array[elemCbo.length] = ui.value; - } - else - { - var i = 0; - for (var elemCbo_index in elemCbo) - { - //Prevent the value from being copied to the array - if (elemCbo[elemCbo_index] !== ui.value) - { - tmp_array[i] = elemCbo[elemCbo_index]; - i++; - } - } - } - $("#cboAuthorIDs").val(tmp_array); - $("#cboAuthorIDs").multiselect('refresh'); - } - }); - $("#cboAuthorIDs").multiselect("disable"); - $("#slctUserPerm").multiselect({ - multiple: false, - header: false, - noneSelectedText: false, - selectedList: 1, - //buttonWidth: 96, - minWidth: 96, - menuWidth: 128, - height: 69, - - click:function(event, ui) - { - $("#slctUserPerm").val(ui.value); - $("#slctUserPerm").multiselect('refresh'); - } - }); - //(ELEMENT - Exclude Post IDs) - - //(ELEMENT - List Amount) - $("#slctOrderBy").multiselect({ - multiple: false, - header: false, - noneSelectedText: "Select an Option", - selectedList: 1, - //buttonWidth: 132, - minWidth: 132, - menuWidth: 192, - - click:function(event, ui) - { - $("#slctOrderBy").val(ui.value); - $("#slctOrderBy").multiselect('refresh'); - } - }); - $("#slctOrder").multiselect({ - multiple: false, - header: false, - noneSelectedText: "Select an Option", - selectedList: 1, - //buttonWidth: 128, - minWidth: 128, - menuWidth: 160, - height: 69, - - click:function(event, ui) - { - $("#slctOrder").val(ui.value); - $("#slctOrder").multiselect('refresh'); - } - }); - //(ELEMENT - Ignore Sticky Posts) - - //(ELEMENT - Exclude Current Post) - - //(ELEMENT - Exclude Duplicates from Current Post) - $("#btnSavePreset").button(); - $("#btnSaveSettings").button(); - $("#btnExport").button(); - $("#btnImport").button(); - $("#btnRestorePreset").button(); - $("#info10").click(function() - { - $("#d10").dialog({ width: 640, height: 480 }); - }); - $("#info11").click(function() - { - $("#d11").dialog({ width: 640, height: 480 }); - }); - $("#info12").click(function() - { - $("#d12").dialog({ width: 640}); - }); - $("#info13").click(function() - { - $("#d13").dialog({ width: 640, height: 480 }); - }); - $("#info14").click(function() - { - $("#d14").dialog({ width: 640 }); - }); - $("#info15").click(function() - { - $("#d15").dialog({ width: 640 }); - }); - $("#info16").click(function() - { - $("#d16").dialog({ width: 640 }); - }); - $("#divCustomPostTaxonomyContent").accordion({ - icons: false - }); - $("#divCustomPostTaxonomyContent").children().each(function(index, domEle) - { - if(domEle.localName === 'div') - { - $(domEle).height(356); - } - }); -}); \ No newline at end of file diff --git a/admin/js/admin.js b/admin/js/admin.js index c67fefe..9facedf 100644 --- a/admin/js/admin.js +++ b/admin/js/admin.js @@ -1,1293 +1,7 @@ -jQuery(document).ready(function($){ - - if( 'undefined' == typeof( apl_admin_settings ) ) - { - return; - } - - var plugin_url = apl_admin_settings.plugin_url; - - var savePresetNonce = apl_admin_settings.savePresetNonce; - var deletePresetNonce = apl_admin_settings.deletePresetNonce; - var restorePresetNonce = apl_admin_settings.restorePresetNonce; - var exportNonce = apl_admin_settings.exportNonce; - var importNonce = apl_admin_settings.importNonce; - var saveSettingsNonce = apl_admin_settings.saveSettingsNonce; - - var presetObj = apl_admin_settings.presetDb; - presetObj = JSON.parse( presetObj ); - - var apl_designs = apl_admin_settings.apl_designs; - apl_designs = JSON.parse( apl_designs ); - - var postTax = apl_admin_settings.postTax; - //postTax = JSON.parse(postTax); - - var taxTerms = apl_admin_settings.taxTerms; - - - - - function setPHPOutput(preset_name) - { - //$('#presetPHP').html('PHP code: if(function_exists("kalinsPost_show"){kalinsPost_show("' + data.preset_name + '");}'); - - //$('#presetPHP').html('PHP code: <?php if(function_exists("display_post_list")){display_post_list("' + preset_name + '");} ?>'); - $('#presetPHP').html('PHP code: <?php if (method_exists($advanced_post_list, "display_post_list")){echo $advanced_post_list->display_post_list("' + preset_name + '");} ?>'); - } - //build the file table - we build it all in javascript so we can - // simply rebuild it whenever an entry is added through ajax - function buildPresetTable() - { - - function tc(str) - { - return "" + str + ""; - } - - var tableHTML = ""; - - var count = 0; - for(var i in presetObj) - { - var shortcode = '[post_list name="' + i + '"]'; - tableHTML += "" + tc(count) + tc(i) + tc("") + tc("") + tc("") + tc(shortcode) + ""; - count++; - } - - tableHTML += "
#Preset NameLoadDownloadDeleteShortcode
"; - - $('#presetListDiv').html(tableHTML); - - count = 0; - for(j in presetObj) - { - - $('#btnDelete_' + count).attr('presetname', j); - $('#btnDelete_' + count).click(function() - { - if(confirm("Are you sure you want to delete " + $(this).attr('presetname') + "?")) - { - deletePreset($(this).attr('presetname')); - } - }); - $('#btnDelete_' + count).button(); - - $('#btnDownload_' + count).attr('presetname', j); - $('#btnDownload_' + count).click(function() - { - //FIX - REPLACE PHP CODE - var name = $(this).attr('presetname'); - apl_preset_export(name); - //var url = plugin_url + "includes/export.php?presetname=" + name; - //alert(url); - - //window.location = url; - }); - $('#btnDownload_' + count).button(); - - $('#btnLoad_' + count).attr('presetname', j); - $('#btnLoad_' + count).click(function() - { - loadPreset($(this).attr('presetname')); - }); - $('#btnLoad_' + count).button(); - - count++; - } - } - function apl_preset_export(preset_name) - { - var exportData = { - action : 'APL_handler_export', - _ajax_nonce : exportNonce, - export_type : 'preset', - filename : $.trim(preset_name) - }; - - - - //TESTING MODE SWITCH - //formData.append('alpha_mode', 'true'); - jQuery.ajax({ - url: ajaxurl, - type: 'POST', - //cache: false, - //contentType: false, - //processData: false, - - data: exportData, - - beforeSend: function(jqXHR, settings){ - var element = document.getElementById("APL_exportIF"); - if (element != null) - { - element.parentNode.removeChild(element); - } - }, - dataFilter: function(data, type){ - var dataRtn = convert_JSON_data(data); - return dataRtn; - }, - success: function(data, textStatus, jqXHR){ - //console.log("Hooray, it worked!"); - if (data._status != 'success') - { - apl_alert(data._error, (data._status.charAt(0).toUpperCase() + data._status.slice(1))); - } - else - { - var paramStr = ''; - paramStr += '?_ajax_nonce=' + data._ajax_nonce; - paramStr += '&action=' + data.action; - paramStr += '&filename=' + data.filename; - - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_exportIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - - //optionsHeader('Exporting Data Successful'); - } - }, - error: function(jqXHR, textStatus, errorThrown){ - alert(errorThrown.stack); - }, - complete: function(jqXHR, textStatus){ - - } - }); - } - //////////////////////////////////////////////////////////////////////////// - //// AJAX FUNCTIONS //////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - function deletePreset(id) - { - //alert("deleting: " + id); - - var data = { - action: 'APL_handler_delete_preset', - _ajax_nonce : deletePresetNonce - } - - data.preset_name = id; - - $('#createStatus').html("Deleting preset..."); - - // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - jQuery.post(ajaxurl, data, function(response) - { - //alert(response); - - var startPosition = response.indexOf("{"); - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - - var newFileData = JSON.parse(responseObjString); - - /*if(newFileData.status == "success"){ - $('#createStatus').html("Preset deleted successfully."); - }else{ - $('#createStatus').html(response); - }*/ - - presetObj = newFileData;//.preset_arr; - - buildPresetTable(); - - $('#createStatus').html("Preset deleted successfully."); - - }); - } - function loadPreset(id) - { - //////////////////////////////////////////////////////////////////////////// - ///////////////////////////////////////////////////////////////////////////// - $('#divPreview').html(""); - var newValues = presetObj[id]; - $("#txtPresetName").val(id); - - set_postTax(newValues._postTax); - set_parent(newValues._postParents); - - $("#txtDisplayAmount").val(newValues["_listCount"]); - $("#slctOrderBy").val(newValues["_listOrderBy"]); - $('#slctOrderBy').multiselect('refresh'); - $("#slctOrder").val(newValues["_listOrder"]); - $('#slctOrder').multiselect('refresh'); - - var postVisibilityArr = jQuery.makeArray(newValues._postVisibility); - $('#cboPostVisibility').val(postVisibilityArr); - $('#cboPostVisibility').multiselect('refresh'); - var postStatusArr = jQuery.makeArray(newValues._postStatus); - $('#cboPostStatus').val(postStatusArr); - $('#cboPostStatus').multiselect('refresh'); - - $("#slctUserPerm").val(newValues["_userPerm"]);//ADDED //string - $('#slctUserPerm').multiselect('refresh'); - $("#chkIgnoreSticky").attr('checked', newValues["_listIgnoreSticky"]);//ADDED //boolean - $("#chkExcldCurrent").attr('checked', newValues["_listExcludeCurrent"]); //boolean - $("#chkExcldDuplicates").attr('checked', newValues["_listExcludeDuplicates"]);//ADDED //boolean - - var tmpString = ''; - for (var i in newValues["_listExcludePosts"]) - { - if (newValues["_listExcludePosts"][i] != 0) - { - tmpString += newValues["_listExcludePosts"][i]; - if( i < (newValues["_listExcludePosts"].length - 1) ) - { - tmpString += ','; - } - } - - } - $("#txtExcldPosts").val(tmpString);//ADDED //string - - var postAuthorIDs = new Array(); - if (newValues["_postAuthorOperator"] === 'include' || newValues["_postAuthorOperator"] === 'exclude') - { - $("#slctAuthorOperator").val(newValues["_postAuthorOperator"]) - $("#cboAuthorIDs").multiselect("enable"); - - if (newValues["_postAuthorIDs"].length > 0) - { - postAuthorIDs = newValues["_postAuthorIDs"]; - } - $("#cboAuthorIDs").val(postAuthorIDs);//ADDED //array - $('#cboAuthorIDs').multiselect('refresh'); - - - } - else if (newValues["_postAuthorOperator"] === 'none') - { - $("#slctAuthorOperator").val(newValues["_postAuthorOperator"]) - $("#cboAuthorIDs").val(postAuthorIDs); - $("#cboAuthorIDs").multiselect("disable"); - $('#cboAuthorIDs').multiselect('refresh'); - } - else - { - $("#slctAuthorOperator").val('none') - $("#cboAuthorIDs").val(postAuthorIDs); - $("#cboAuthorIDs").multiselect("disable"); - $('#cboAuthorIDs').multiselect('refresh'); - } - $('#slctAuthorOperator').multiselect('refresh'); - - var design = apl_designs[ newValues['apl_design'] ] - - $("#txtExitMsg").val( design['empty'] ); - $("#txtBeforeList").val( design['before'] ); - $("#txtContent").val( design['content'] ); - $("#txtAfterList").val( design['after'] ); - - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - - setPHPOutput(id); - - setNoneHide(); - } - - function set_postTax(post_tax) - { - - reset_postTax(); - for (var post_type_name in post_tax) - { - - for (var taxonomy_name in post_tax[post_type_name]['taxonomies']) - { - $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).attr('checked', post_tax[post_type_name]['taxonomies'][taxonomy_name]['require_taxonomy']); - $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', post_tax[post_type_name]['taxonomies'][taxonomy_name]['require_terms']); - $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', post_tax[post_type_name]['taxonomies'][taxonomy_name]['include_terms']); - - for (var term in post_tax[post_type_name]['taxonomies'][taxonomy_name]['terms']) - { - $("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + post_tax[post_type_name]['taxonomies'][taxonomy_name]['terms'][term]).attr('checked',true) - } - - } - } - } - function reset_postTax() - { - for (var post_type_name in postTax) - { - for (var taxonomy_name in postTax[post_type_name].taxonomies) - { - $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).attr('checked', false); - $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', false); - $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).attr('checked', false); - - var terms = taxTerms[taxonomy_name].terms; - - $("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-0').attr('checked',false) - for (var term in terms) - { - $("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + terms[term]).attr('checked',false) - } - } - } - } - function set_parent(parentArr) - { - reset_parent(); - //parentArr.toArray(); - parentArr = jQuery.makeArray(parentArr); - - for (var post_type_name in postTax) - { - - $("#slctParentSelector-" + post_type_name).val(parentArr); - $("#slctParentSelector-" + post_type_name).multiselect('refresh'); - //$("#slctParentSelector-" + post_type_name).each(object, callback); - - } - - } - function reset_parent() - { - - for (var post_type_name in postTax) - { - $("#slctParentSelector-" + post_type_name).val([]); - $("#slctParentSelector-" + post_type_name).multiselect('refresh'); - - } - - } - - - - //////////////////////////////////////////////////////////////////////////// - //// AJAX BUTTONS ////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - $('#btnSavePreset').click(function() - { - if (!save_preset_precheck()) - { - save_preset(); - } - }); - //// RETURN TRUE IF AN EVENT OCCURED - function save_preset_precheck() - { - if (!check_required()) - { - - if (!check_preset_name()) - { - return false; - } - return true; - } - return true; - - } - function check_required() - { - //var event_occured = false; - for (var post_type_name in postTax) - { - var require_taxonomy = new Array(); - for (var taxonomy_name in postTax[post_type_name].taxonomies) - { - require_taxonomy[taxonomy_name] = new Array(); - require_taxonomy[taxonomy_name]['require'] = $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).is(':checked'); - var require_terms = $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - var include_terms = $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - require_taxonomy[taxonomy_name]['count'] = 0; - - var terms = taxTerms[taxonomy_name].terms; - for (var term in terms) - { - if ($("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + terms[term]).is(':checked')) - { - require_taxonomy[taxonomy_name]['count']++; - } - } - - - if (require_taxonomy[taxonomy_name]['count'] < 2 && require_terms === true && include_terms === false) - { - $( "#d03" ).dialog({ - resizable: false, - height:192, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - return true; - } - else if (require_taxonomy[taxonomy_name]['count'] < 2 && require_taxonomy[taxonomy_name]['require'] == true && include_terms == false) - { - $( "#d04" ).dialog({ - resizable: false, - height:224, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - return true; - } - - } - - for(var taxonomy01 in require_taxonomy) - { - if (require_taxonomy[taxonomy01]['require'] == true) - { - var other_taxonomy_used = false; - for(var taxonomy02 in require_taxonomy) - { - if (require_taxonomy[taxonomy02]['count'] > 0 && taxonomy01 != taxonomy02) - { - other_taxonomy_used = true; - } - } - if (other_taxonomy_used == false) - { - - $( "#d05" ).dialog( - { - resizable: false, - height:224, - modal: true, - buttons: - { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - return true; - - } - } - - } - - } - return false; - } - function check_preset_name() - { - var preset_name = $("#txtPresetName").val(); - if(presetObj[preset_name]) - { - $( "#d01" ).dialog({ - resizable: false, - height:192, - modal: true, - buttons: { - "Save Preset": function() - { - $( this ).dialog( "close" ); - save_preset(); - }, - "Cancel": function() - { - $( this ).dialog( "close" ); - - } - } - }); - return true; - } - else if(preset_name == "") - { - $( "#d02" ).dialog({ - resizable: false, - height:192, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - - } - } - }); - return true; - } - return false; - - } - - function save_preset() - { - var data = { - action: 'APL_handler_save_preset', - _ajax_nonce : savePresetNonce - }; - //css style bug fix - var btn_height = $('#btnSavePreset').height(); - var btn_width = $('#btnSavePreset').width(); - $('#btnSavePreset').html("Saving..."); - $('#btnSavePreset').height(btn_height); - $('#btnSavePreset').width(btn_width); - - data.presetName = $("#txtPresetName").val(); - - - data.postParents = JSON.stringify(get_parent()); - data.postTax = JSON.stringify(get_postTax()); - - - data.count = $("#txtDisplayAmount").val(); - data.orderBy = $("#slctOrderBy").val(); - data.order = $("#slctOrder").val(); - - data.postVisibility = $('#cboPostVisibility').val();//array - data.postVisibility = JSON.stringify(data.postVisibility); - data.postStatus = $("#cboPostStatus").val();//MODIFIED //array - if (data.postStatus === null) - { - data.postStatus = new Array('any'); - } - data.postStatus = JSON.stringify(data.postStatus); - - data.userPerm = $("#slctUserPerm").val();//ADDED //string - data.ignoreSticky = $("#chkIgnoreSticky").is(':checked');//ADDED //boolean - data.excludeCurrent = $("#chkExcldCurrent").is(':checked'); //boolean - data.excludeDuplicates = $("#chkExcldDuplicates").is(':checked');//ADDED //boolean - - data.excludePosts = $("#txtExcldPosts").val();//ADDED //string - needs to be changed to an array and json string - if (data.excludePosts === "") - { - data.excludePosts = new Array(); - } - else - { - data.excludePosts = data.excludePosts.split(","); - } - data.excludePosts = JSON.stringify(data.excludePosts); - - data.authorOperator = $("#slctAuthorOperator").val();//ADDED //string - - data.authorIDs = $("#cboAuthorIDs").val();//ADDED //array - if (data.authorIDs === null) - { - data.authorIDs = new Array(); - } - data.authorIDs = JSON.stringify(data.authorIDs); - - data.exit = $("#txtExitMsg").val(); - data.before = $("#txtBeforeList").val(); - data.content = $("#txtContent").val(); - data.after = $("#txtAfterList").val(); - - - setPHPOutput(data.presetName); - - - - //since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - jQuery.post(ajaxurl, data, function(response) - { - //console.log( response ); - //alert(response); - - var startPosition = response.indexOf("{"); - if (startPosition > 10) - { - apl_alert(response, 'Error'); - } - - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - - //alert(responseObjString); - - var newFileData = JSON.parse(responseObjString); - - presetObj = newFileData.preset_arr; - buildPresetTable(); - $('#btnSavePreset').html("Save Preset"); - - if($("#chkShowPreview").is(':checked')) - { - $('#divPreview').html(newFileData.previewOutput); - } - else - { - $('#divPreview').html(""); - } - - - }); - } - - function get_postTax() - { - var rtnObject = new Object(); - var tmp_post_types = new Object(); - for (var post_type_name in postTax) - { - var tmp_taxonomies = new Object(); - var post_type_used = false; - for (var taxonomy_name in postTax[post_type_name].taxonomies) - { - var tmp_terms = new Array(); - var i = 0; - var terms = taxTerms[taxonomy_name].terms; - if ($("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + 0).is(':checked')) - { - tmp_terms[i] = 0; - i++; - } - else - { - for (var term in terms) - { - if ($("#chkTerm-" + post_type_name + "-" + taxonomy_name + '-' + terms[term]).is(':checked')) - { - tmp_terms[i] = terms[term]; - i++; - } - } - } - - if (i > 0 || $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).is(':checked')) - { - tmp_taxonomies[taxonomy_name] = new Object(); - tmp_taxonomies[taxonomy_name].require_taxonomy = $("#chkReqTaxonomy-" + post_type_name + "-" + taxonomy_name).is(':checked'); - tmp_taxonomies[taxonomy_name].require_terms = $("#chkReqTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - tmp_taxonomies[taxonomy_name].include_terms = $("#chkIncldTerms-" + post_type_name + "-" + taxonomy_name).is(':checked'); - tmp_taxonomies[taxonomy_name].terms = tmp_terms; - - post_type_used = true; - } - } - if (post_type_used) - { - tmp_post_types[post_type_name] = new Object(); - - tmp_post_types[post_type_name].taxonomies = tmp_taxonomies; - - } - - } - rtnObject = tmp_post_types; - return rtnObject; - } - function get_parent() - { - //Custom unique array function to remove any duplicates, especially - // the current page setting. - var unique = function(origArr) - { - var newArr = [], - origLen = origArr.length, - found, - x, y; - - for ( x = 0; x < origLen; x++ ) - { - found = undefined; - for ( y = 0; y < newArr.length; y++ ) - { - if ( origArr[x] === newArr[y] ) - { - found = true; - break; - } - } - if ( !found) newArr.push( origArr[x] ); - } - return newArr; - }; - - var parentIDs = new Array(); - var rtnArray = new Array(); - - var i = 0; - for (var post_type_name in postTax) - { - parentIDs = $("#slctParentSelector-" + post_type_name).val(); - - if (parentIDs !== null) - { - for (var j = 0; j < parentIDs.length; j++, i++) - { - rtnArray[i] = parentIDs[j]; - } - } - } - rtnArray = unique(rtnArray); - return rtnArray; - } - - - function optionsHeader(output) - { - $('#optionsHeader').html('' + output + ''); - $('#optionsHeader').fadeOut(5000, function(){ - $('#optionsHeader').show(); - $('#optionsHeader').html('

General Settings

'); - }); - - } - - - $('#btnSaveSettings').click(function(){ - - save_settings(); - - }); - - function save_settings() - { - var data = { - action : 'APL_handler_save_settings', - _ajax_nonce : saveSettingsNonce - } - - var deleteDb = false; - if ($("#rdoDeleteDbTRUE").is(':checked')) - { - deleteDb = true; - } - else if ($("#rdoDeleteDbFALSE").is(':checked')) - { - deleteDb = false; - } - data.deleteDb = deleteDb; - - data.theme = $('#slctUITheme').val(); - - var defaultExit = false; - if ($("#rdoDefaultExitMsgTRUE").is(':checked')) - { - defaultExit = true; - } - else if ($("#rdoDefaultExitMsgFALSE").is(':checked')) - { - defaultExit = false; - } - data.defaultExit = defaultExit; - data.defaultExitMsg = $("#txtDefaultExitMsg").val(); - - - jQuery.post(ajaxurl, data, function(response) - { - var startPosition = response.indexOf("{"); - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - var newFileData = JSON.parse(responseObjString); - - - optionsHeader('Options Saved'); - loadjscssfile('http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.21/themes/' + newFileData.theme + '/jquery-ui.css', 'css'); - }); - - } - function loadjscssfile(filename, filetype) - { - var fileref; - //if filename is a external JavaScript file - if (filetype === "js") - { - fileref=document.createElement('script'); - fileref.setAttribute("type","text/javascript"); - fileref.setAttribute("src", filename); - } - //if filename is an external CSS file - else if (filetype === "css") - { - fileref = document.createElement("link"); - fileref.setAttribute("rel", "stylesheet"); - fileref.setAttribute("type", "text/css"); - fileref.setAttribute("href", filename); - } - if (typeof fileref !== "undefined") - { - document.getElementsByTagName("head")[0].appendChild(fileref); - } - - } - function check_string_for_errors(input_string) - { - var iChars = "<>:\"/\\|,?*"; - - for (var i = 0; i < input_string.value.length; i++) - { - if (iChars.indexOf(input_string.value.charAt(i)) != -1) - { - apl_alert("

Cannot use (< > : \" / \\ | , ? *).
Please rename your filename.

", "Illegal Characters"); - return true; - } - - } - return false; - } - $('#txtExportFileName').change(function() - { - check_string_for_errors(document.frmExport.txtExportFileName); - }); - - function apl_alert(output_msg, title_msg) - { - if (!title_msg) - title_msg = 'Alert'; - - if (!output_msg) - output_msg = 'No Message to Display.'; - - $("
").html(output_msg).dialog({ - title: title_msg, - resizable: true, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - - } - } - }); - } - - function convert_JSON_data(json_string) - { - //CONVERT RETURN/RESPONSE DATA (dataRtn) - //SYNTAX .substr(start, length) - //SYNTAX .substring(start, end) - var tmpData = $.trim(json_string); - - - //CHECKS DATA FOR ADDITIONAL CONTENT, FOR EX. PHP ERRORS - //TODO ADD SUPPORT OF MULTI LANGUAGES WITH MULTILINGUAL - var cData = tmpData.split("{\"_msg\""); - if (cData[0].indexOf("
\n") != -1 && cData[0].indexOf("") != -1 && cData.length != 1) - { - cData[0] = $.trim(cData[0]); - var eData = cData[0].split("
\n"); - - //DISPLAY EACH PHP ERROR INDIVIDUALLY - //STARTED INDEX AT 1 SINCE eData[0] IS AN EMPTY STRING CREATED BY .split() - for (i = 1; i < eData.length; i++) - { - $("
").html("
" + eData[i]).dialog({ - title: 'PHP Error', - resizable: true, - minWidth: 576, - modal: true, - buttons: { - "Ok": function() - { - $( this ).dialog( "close" ); - } - } - }); - } - return false; - } - - var rtnData = JSON.parse(tmpData.substring(tmpData.indexOf("{\"_msg\""), tmpData.lastIndexOf("}") + 1)); - - return rtnData; - } - - - //////////////////////////////////////////////////////////////////////////// - //// EXPORT //////////////////////////////////////////////////////////////// - $('#frmExport').submit(function(){ - //CHECK USER SIDE - if (apl_export_errors()) - { - return false; - } - apl_db_export(); - return false; - }); - - function apl_export_errors() - { - var var_filename = document.frmExport.txtExportFileName.value; - if (check_string_for_errors(document.frmExport.txtExportFileName)) - { - return true; - } - if (document.frmExport.txtExportFileName.value == "") - { - apl_alert("A filename doesn't exist.\nPlease enter a filename before exporting.", "Filename Required"); - return true; - } - return false; - } - - function apl_db_export() - { - var formData = new FormData(); - formData.append('action', 'APL_handler_export'); - formData.append('_ajax_nonce', exportNonce); - formData.append('export_type', 'database'); - formData.append('filename', $.trim($('#txtExportFileName').val())); - - //TESTING MODE SWITCH - //formData.append('alpha_mode', 'true'); - jQuery.ajax({ - url: ajaxurl, - type: 'POST', - cache: false, - contentType: false, - processData: false, - - data: formData, - - beforeSend: function(jqXHR, settings){ - var a1 = jqXHR; - var a2 = settings; - var element = document.getElementById("APL_exportIF"); - if (element != null) - { - element.parentNode.removeChild(element); - } - }, - dataFilter: function(data, type){ - var dataRtn = convert_JSON_data(data); - return dataRtn; - }, - success: function(data, textStatus, jqXHR){ - if (data._status != 'success') - { - apl_alert(data._error, (data._status.charAt(0).toUpperCase() + data._status.slice(1))); - } - else - { - var paramStr = ''; - paramStr += '?_ajax_nonce=' + data._ajax_nonce; - paramStr += '&action=' + data.action; - paramStr += '&filename=' + data.filename; - - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_exportIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - - optionsHeader('Exporting Data Successful'); - } - }, - error: function(jqXHR, textStatus, errorThrown){ - alert(errorThrown.stack); - }, - complete: function(jqXHR, textStatus){ - var a1 = jqXHR; - var a2 = textStatus; - // - } - }); - } - - //////////////////////////////////////////////////////////////////////////// - //// IMPORT //////////////////////////////////////////////////////////////// - $('#frmImport').submit(function(e) - { - e.preventDefault(); - //CHECK USER SIDE - if (apl_import_errors()) - { - return false; - } - apl_import_db(); - return false; - }); - - function apl_import_errors() - { - for (var i = 0; i < document.frmImport.importType.length; i++) - { - if (document.frmImport.importType[i].checked) - { - var importType = document.frmImport.importType[i].value; - } - } - - - if ($('#fileImportData').val() == '' && importType == 'file') - { - alert('No file(s) selected. Please choose a JSON file to upload.'); - return true; - } - if ($('#fileImportData').val() != '') - { - var ext = $('#fileImportData').val().split('.').pop().toLowerCase(); - if($.inArray(ext, ['json']) == -1) - { - alert('Invalid file type. Please choose a JSON file to upload.'); - return true; - } - } - - return false; - } - function apl_import_db() - { - - var formData = new FormData(); - jQuery.each($('#fileImportData')[0].files, function(i, file) { - formData.append('uploadFile-'+i, file); - }); - formData.append('action', 'APL_handler_import'); - formData.append('_ajax_nonce', importNonce); - - var rdoImport = document.frmImport.importType; - for (var i = 0; i < rdoImport.length; i++) - { - if (rdoImport[i].checked) - { - formData.append('import_type', rdoImport[i].value); - } - } - - //TESTING MODE SWITCH - //formData.append('alpha_mode', 'true'); - jQuery.ajax({ - url: ajaxurl, - type: 'POST', - cache: false, - contentType: false, - processData: false, - - data: formData, - - - beforeSend: function(jqXHR, settings){ - var a1 = jqXHR; - var a2 = settings; - var element = document.getElementById("APL_exportIF"); - if (element != null) - { - element.parentNode.removeChild(element); - } - }, - dataFilter: function(data, type){ - var dataRtn = convert_JSON_data(data); - return dataRtn; - }, - success: function(data, textStatus, jqXHR){ - if (data._msg != 'success') - { - apl_alert(data._error, (data._msg.charAt(0).toUpperCase() + data._msg.slice(1))); - } - if ($.isEmptyObject( data.overwrite_preset_db )) - { - presetObj = data._preset_db; - buildPresetTable(); - - var paramStr = ''; - paramStr += '?_ajax_nonce=' + data._ajax_nonce; - paramStr += '&action=' + data.action; - paramStr += '&overwrite=' + ''; - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_importIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - - optionsHeader('Importing Data Successful'); - } - else - { - - var overwrite_output = ''; - overwrite_output += '

(All / None) Presets

'; - - overwrite_output += '
'; - for (var preset_key in data.overwrite_preset_db) - { - overwrite_output += ''; - overwrite_output += ''; - overwrite_output += '
'; - } - overwrite_output += '
'; - $('
').html(overwrite_output).dialog({ - stack: false, - title: 'Overwrite Presets', - resizable: true, - height: 256, - minWidth: 352, - maxWidth: 512, - maxHeight: 448, - modal: true, - buttons: { - Next: function() - { - presetObj = data._preset_db; - apl_import_overwrite(data.overwrite_preset_db, data._ajax_nonce, data.action); - buildPresetTable(); - - optionsHeader('Importing Data Successful'); - - $( this ).dialog( "close" ); - var element = document.getElementById("apl_confirm_overwrite"); - element.parentNode.removeChild(element); - }, - Cancel: function() - { - $( this ).dialog( "close" ); - var element = document.getElementById("apl_confirm_overwrite"); - element.parentNode.removeChild(element); - } - }, - open: function(){ - $('#overwrite_select_group_all').click(function(e){ - for (var preset_key in data.overwrite_preset_db) - { - $('#chkGroup_overwrite_preset_' + preset_key).attr('checked', true); - } - }); - $('#overwrite_select_group_none').click(function(e){ - for (var preset_key in data.overwrite_preset_db) - { - $('#chkGroup_overwrite_preset_' + preset_key).attr('checked', false); - } - }); - } - }); - } - }, - error: function(jqXHR, textStatus, errorThrown){ - alert(errorThrown.stack); - }, - complete: function(jqXHR, textStatus){ - var a1 = jqXHR; - var a2 = textStatus; - } - }); - } - - function apl_import_overwrite(overwrite_preset_db, ajax_nonce, action) - { - var overwrite_list = '';//array of preset names parsed by comma - - for (var preset_key in overwrite_preset_db) - { - if ($('#chkGroup_overwrite_preset_' + preset_key).is(':checked')) - { - overwrite_list += preset_key + ','; - presetObj[preset_key] = overwrite_preset_db[preset_key]; - } - } - overwrite_list = overwrite_list.substring(0, overwrite_list.length - 1); - - var paramStr = ''; - paramStr += '?_ajax_nonce=' + ajax_nonce; - paramStr += '&action=' + action; - paramStr += '&overwrite=' + overwrite_list; - - var elemIF = document.createElement("iframe"); - elemIF.id = 'APL_importIF' - elemIF.style.display = "none"; - elemIF.src = ajaxurl + paramStr; - - document.body.appendChild(elemIF); - elemIF.parentNode.removeChild(elemIF); - - } - - //////////////////////////////////////////////////////////////////////////// - //// RESTORE /////////////////////////////////////////////////////////////// - $('#btnRestorePreset').click(function() - { - //alert(data.post_type); - var data = { - action: 'APL_handler_restore_preset', - _ajax_nonce : restorePresetNonce - } - - if(confirm("Are you sure you want to restore all default presets? This will remove any changes you've made to the default presets, but will not delete your custom presets.")) - { - - //$('#createStatus').html("Restoring presets..."); - $('#divPreview').html(""); - - // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php - jQuery.post(ajaxurl, data, function(response) - { - - var startPosition = response.indexOf("{"); - var responseObjString = response.substr(startPosition, response.lastIndexOf("}") - startPosition + 1); - - //alert(responseObjString); - var newFileData = JSON.parse(responseObjString); - - presetObj = newFileData;//.preset_arr; - buildPresetTable(); - //$('#createStatus').html("Preset successfully added."); - optionsHeader('Restoring Default Presets Successful'); - - }); - } - }); - - - $('#postTypeHeader01').click(function(){ - $('#postTypeContent01').slideToggle('slow') - }); - - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////////////// - $('#cboPost_type').change(function() - { - setNoneHide(); - }); - - function setNoneHide(){ - - var postTypeVal = $("#cboPost_type").val() ; - - if(postTypeVal == "none") - { - $('.noneHide').hide(); - $('.noneShow').show(); - $('#createStatus').html("In 'None' mode, the content field will be displayed only once and all shortcodes will refer to the current page."); - } - else - { - $('.noneHide').show(); - $('.noneShow').hide(); - $('#createStatus').html(" "); - } - - if(postTypeVal != "none" && postTypeVal != "post" && postTypeVal != "attachment") - {//if it's a page or custom type, show parent selector - $('#parentSelector').show(); - } - else - { - $('#parentSelector').hide(); - } - } - - buildPresetTable(); - - //$('#outputSpan').hide(); - $('#parentSelector').hide(); - - -}); - - - - +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ diff --git a/admin/js/jquery.multiselect.filter.min.js b/admin/js/jquery.multiselect.filter.min.js index b1d6520..fa93068 100644 --- a/admin/js/jquery.multiselect.filter.min.js +++ b/admin/js/jquery.multiselect.filter.min.js @@ -1,6 +1,6 @@ /* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */ /* - * jQuery MultiSelect UI Widget Filtering Plugin 1.6pre + * jQuery MultiSelect UI Widget Filtering Plugin 2.0.0 * Copyright (c) 2012 Eric Hynds * * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ @@ -13,4 +13,4 @@ * http://www.gnu.org/licenses/gpl.html * */ -(function($){var rEscape=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){func.apply(context,args)}};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow){func.apply(context,args)}}}$.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:false,debounceMS:250},_create:function(){var opts=this.options;var elem=$(this.element);var instance=this.instance=elem.data("echMultiselect")||elem.data("multiselect")||elem.data("ech-multiselect");var header=this.header=instance.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");var wrapper=this.wrapper=$('
'+(opts.label.length?opts.label:"")+'
").prependTo(this.header);this.inputs=instance.menu.find('input[type="checkbox"], input[type="radio"]');this.input=wrapper.find("input").bind({keydown:function(e){if(e.which===13){e.preventDefault()}},input:$.proxy(debounce(this._handler,opts.debounceMS),this),search:$.proxy(this._handler,this)});this.updateCache();instance._toggleChecked=function(flag,group){var $inputs=group&&group.length?group:this.labels.find("input");var _self=this;var selector=_self._isOpen?":disabled, :hidden":":disabled";$inputs=$inputs.not(selector).each(this._toggleState("checked",flag));this.update();var values={};$inputs.each(function(){values[this.value]=true});this.element.find("option").filter(function(){if(!this.disabled&&values[this.value]){_self._toggleState("selected",flag).call(this)}});if($inputs.length){this.element.trigger("change")}};var doc=$(document).bind("multiselectrefresh."+instance._namespaceID,$.proxy(function(){this.updateCache();this._handler()},this));if(this.options.autoReset){doc.bind("multiselectclose."+instance._namespaceID,$.proxy(this._reset,this))}},_handler:function(e){var term=$.trim(this.input[0].value.toLowerCase()),rows=this.rows,inputs=this.inputs,cache=this.cache;if(!term){rows.show()}else{rows.hide();var regex=new RegExp(term.replace(rEscape,"\\$&"),"gi");this._trigger("filter",e,$.map(cache,function(v,i){if(v.search(regex)!==-1){rows.eq(i).show();return inputs.get(i)}return null}))}this.instance.menu.find(".ui-multiselect-optgroup-label").each(function(){var $this=$(this);var isVisible=$this.nextUntil(".ui-multiselect-optgroup-label").filter(function(){return $.css(this,"display")!=="none"}).length;$this[isVisible?"show":"hide"]()})},_reset:function(){this.input.val("").trigger("keyup")},updateCache:function(){this.rows=this.instance.menu.find(".ui-multiselect-checkboxes li:not(.ui-multiselect-optgroup-label)");this.cache=this.element.children().map(function(){var elem=$(this);if(this.tagName.toLowerCase()==="optgroup"){elem=elem.children()}return elem.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){$.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery); +(function($){var rEscape=/[\-\[\]{}()*+?.,\\\^$|#\s]/g;function debounce(func,wait,immediate){var timeout;return function(){var context=this,args=arguments;var later=function(){timeout=null;if(!immediate){func.apply(context,args)}};var callNow=immediate&&!timeout;clearTimeout(timeout);timeout=setTimeout(later,wait);if(callNow){func.apply(context,args)}}}$.widget("ech.multiselectfilter",{options:{label:"Filter:",width:null,placeholder:"Enter keywords",autoReset:false,debounceMS:250},_create:function(){var opts=this.options;var elem=$(this.element);this.instance=elem.multiselect("instance");this.header=this.instance.menu.find(".ui-multiselect-header").addClass("ui-multiselect-hasfilter");this.input=$("").attr({placeholder:opts.placeholder,type:"search"}).css({width:/\d/.test(opts.width)?opts.width+"px":null}).bind({keydown:function(e){if(e.which===13){e.preventDefault()}else if(e.which===27){elem.multiselect("close");e.preventDefault()}else if(e.which===9&&e.shiftKey){elem.multiselect("close");e.preventDefault()}else if(e.altKey){switch(e.which){case 82:e.preventDefault();$(this).val("").trigger("input","");break;case 65:elem.multiselect("checkAll");break;case 85:elem.multiselect("uncheckAll");break;case 76:elem.multiselect("instance").labels.first().trigger("mouseenter");break}}},input:$.proxy(debounce(this._handler,opts.debounceMS),this),search:$.proxy(this._handler,this)});if(this.options.autoReset){elem.bind("multiselectclose",$.proxy(this._reset,this))}elem.bind("multiselectrefresh",$.proxy(function(){this.updateCache();this._handler()},this));this.wrapper=$("
").addClass("ui-multiselect-filter").text(opts.label).append(this.input).prependTo(this.header);this.inputs=this.instance.menu.find('input[type="checkbox"], input[type="radio"]');this.updateCache();this.instance._toggleChecked=function(flag,group){var $inputs=group&&group.length?group:this.labels.find("input");var _self=this;var selector=_self._isOpen?":disabled, :hidden":":disabled";$inputs=$inputs.not(selector).each(this._toggleState("checked",flag));this.update();var values={};$inputs.each(function(){values[this.value]=true});this.element.find("option").filter(function(){if(!this.disabled&&values[this.value]){_self._toggleState("selected",flag).call(this)}});if($inputs.length){this.element.trigger("change")}}},_handler:function(e){var term=$.trim(this.input[0].value.toLowerCase()),rows=this.rows,inputs=this.inputs,cache=this.cache;var $groups=this.instance.menu.find(".ui-multiselect-optgroup");$groups.show();if(!term){rows.show()}else{rows.hide();var regex=new RegExp(term.replace(rEscape,"\\$&"),"gi");this._trigger("filter",e,$.map(cache,function(v,i){if(v.search(regex)!==-1){rows.eq(i).show();return inputs.get(i)}return null}))}$groups.each(function(){var $this=$(this);if(!$this.children("li:visible").length){$this.hide()}});this.instance._setMenuHeight()},_reset:function(){this.input.val("").trigger("input","")},updateCache:function(){this.rows=this.instance.labels.parent();this.cache=this.element.children().map(function(){var elem=$(this);if(this.tagName.toLowerCase()==="optgroup"){elem=elem.children()}return elem.map(function(){return this.innerHTML.toLowerCase()}).get()}).get()},widget:function(){return this.wrapper},destroy:function(){$.Widget.prototype.destroy.call(this);this.input.val("").trigger("keyup");this.wrapper.remove()}})})(jQuery); diff --git a/admin/js/jquery.multiselect.min.js b/admin/js/jquery.multiselect.min.js index 03646f5..6f62fdd 100644 --- a/admin/js/jquery.multiselect.min.js +++ b/admin/js/jquery.multiselect.min.js @@ -1,13 +1,13 @@ /* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */ /* - * jQuery MultiSelect UI Widget 1.17pre + * jQuery MultiSelect UI Widget 2.0.1 * Copyright (c) 2012 Eric Hynds * * http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/ * * Depends: * - jQuery 1.4.2+ - * - jQuery UI 1.8 widget factory + * - jQuery UI 1.11 widget factory * * Optional: * - jQuery UI effects @@ -18,4 +18,4 @@ * http://www.gnu.org/licenses/gpl.html * */ -(function($,undefined){var multiselectID=0;var $doc=$(document);$.widget("ech.multiselect",{options:{header:true,height:175,minWidth:225,classes:"",checkAllText:"Check all",uncheckAllText:"Uncheck all",noneSelectedText:"Select options",selectedText:"# selected",selectedList:0,closeIcon:"ui-icon-circle-close",show:null,hide:null,autoOpen:false,multiple:true,position:{},appendTo:"body",menuWidth:null,selectedListSeparator:", "},_create:function(){var el=this.element;var o=this.options;this.speed=$.fx.speeds._default;this._isOpen=false;this._namespaceID=this.eventNamespace||"multiselect"+multiselectID;var button=(this.button=$('')).addClass("ui-multiselect ui-widget ui-state-default ui-corner-all").addClass(o.classes).attr({title:el.attr("title"),tabIndex:el.attr("tabIndex"),id:el.attr("id")?el.attr("id")+"_ms":null}).prop("aria-haspopup",true).insertAfter(el),buttonlabel=(this.buttonlabel=$("")).html(o.noneSelectedText).appendTo(button),menu=(this.menu=$("
")).addClass("ui-multiselect-menu ui-widget ui-widget-content ui-corner-all").addClass(o.classes).appendTo($(o.appendTo)),header=(this.header=$("
")).addClass("ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix").appendTo(menu),headerLinkContainer=(this.headerLinkContainer=$("