first commit
This commit is contained in:
+463
@@ -0,0 +1,463 @@
|
||||
<?php
|
||||
/**
|
||||
* The admin-specific functionality of the module.
|
||||
*
|
||||
* @link https://codesupply.co
|
||||
* @since 1.0.0
|
||||
*
|
||||
* @package Powerkit
|
||||
* @subpackage Modules/Admin
|
||||
*/
|
||||
|
||||
/**
|
||||
* The admin-specific functionality of the module.
|
||||
*/
|
||||
class Powerkit_Basic_Elements_Admin extends Powerkit_Module_Admin {
|
||||
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
public function initialize() {
|
||||
add_action( 'wp_ajax_powerkit_basic_shortcodes_sections', array( $this, 'powerkit_basic_shortcodes_ajax_panel' ) );
|
||||
add_filter( 'mce_buttons', array( $this, 'powerkit_basic_shortcodes_register_buttons' ) );
|
||||
add_filter( 'mce_external_plugins', array( $this, 'powerkit_basic_shortcodes_register_plugin' ) );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Register shorcodes button for TinyMCE buttons (Visual tab).
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $buttons First-row list of buttons.
|
||||
* @return array Buttons.
|
||||
*/
|
||||
public function powerkit_basic_shortcodes_register_buttons( $buttons ) {
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
array_push( $buttons, 'powerkit_basic_shortcodes_button' );
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register shortcodes plugin
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $plugins An array of external TinyMCE plugins.
|
||||
* @return array Plugins.
|
||||
*/
|
||||
public function powerkit_basic_shortcodes_register_plugin( $plugins ) {
|
||||
if ( current_user_can( 'edit_posts' ) ) {
|
||||
$plugins['powerkit_basic_shortcodes'] = trailingslashit( plugin_dir_url( __FILE__ ) ) . 'js/admin-powerkit-basic-elements.js';
|
||||
}
|
||||
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate Section Fileds
|
||||
*
|
||||
* @since 1.0.0
|
||||
* @param array $section Sections Fields.
|
||||
* @param array $counter Unique field identifier.
|
||||
*/
|
||||
public function generate_section_fields( $section, $counter = 0 ) {
|
||||
if ( isset( $section['fields'] ) && is_array( $section['fields'] ) ) {
|
||||
|
||||
// Default Field Settings.
|
||||
$default_field = array(
|
||||
'type' => 'input',
|
||||
'name' => '',
|
||||
'label' => '',
|
||||
'desc' => '',
|
||||
'default' => '',
|
||||
'attrs' => array(),
|
||||
'style' => 'vertical', // For radio.
|
||||
'suffix' => '', // For inputs.
|
||||
'options' => array(), // For select, radio.
|
||||
'fields' => array(), // For repeater.
|
||||
);
|
||||
|
||||
foreach ( $section['fields'] as $field ) {
|
||||
|
||||
$counter++;
|
||||
|
||||
// Merge Settings.
|
||||
$field = array_merge( $default_field, $field );
|
||||
|
||||
// Attrs.
|
||||
$attrs = null;
|
||||
|
||||
if ( ! empty( $field['attrs'] ) ) {
|
||||
foreach ( $field['attrs'] as $key => $value ) {
|
||||
$attrs[] = sprintf( '%s="%s"', $key, $value );
|
||||
}
|
||||
$attrs = implode( ' ', $attrs );
|
||||
}
|
||||
|
||||
// Output by type.
|
||||
switch ( $field['type'] ) {
|
||||
case 'section':
|
||||
?>
|
||||
<tr>
|
||||
<th><h3><?php echo wp_kses_post( $field['label'] ); ?></h3></th><td> </td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
case 'input':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<input name="<?php echo esc_attr( $field['name'] ); ?>" type="text" value="<?php echo esc_attr( $field['default'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>><?php echo esc_attr( $field['suffix'] ); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
case 'textarea':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<textarea name="<?php echo esc_attr( $field['name'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>><?php echo wp_kses_post( $field['default'] ); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
case 'select':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<select name="<?php echo esc_attr( $field['name'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>>
|
||||
<?php if ( isset( $field['options'] ) && $field['options'] ) : ?>
|
||||
<?php foreach ( $field['options'] as $key => $option ) : ?>
|
||||
<option value="<?php echo esc_attr( $key ); ?>" <?php selected( $field['default'], esc_attr( $key ) ); ?>><?php echo esc_attr( $option ); ?></option>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<input name="<?php echo esc_attr( $field['name'] ); ?>" type="checkbox" value="true" <?php checked( (bool) $field['default'], true ); ?> <?php echo wp_kses_data( $attrs ); ?>>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'radio':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<?php if ( isset( $field['options'] ) && $field['options'] ) : ?>
|
||||
<?php foreach ( $field['options'] as $key => $option ) : $counter++; ?>
|
||||
<?php $id = sprintf( 'field-%s-%s-%s', $section['name'], $field['name'], $counter ); ?>
|
||||
<input id="<?php echo esc_attr( $id ); ?>" name="<?php echo esc_attr( $field['name'] ); ?>" type="radio" value="<?php echo esc_attr( $key ); ?>" <?php checked( $field['default'], $key ); ?> <?php echo wp_kses_data( $attrs ); ?>>
|
||||
<label for="<?php echo esc_attr( $id ); ?>"><?php echo esc_attr( $option ); ?></label>
|
||||
<?php if ( 'vertical' === $field['style'] ) : ?>
|
||||
<br>
|
||||
<?php else : ?>
|
||||
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'content':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:<small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td>
|
||||
<textarea name="<?php echo esc_attr( $field['name'] ); ?>" <?php echo wp_kses_data( $attrs ); ?>><?php echo wp_kses_post( $field['default'] ); ?></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'repeater':
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo wp_kses_post( $field['label'] ); ?>:</label><small><?php echo wp_kses_post( $field['desc'] ); ?></small></th>
|
||||
<td class="basic-shortcodes-repeater-field">
|
||||
<div data-repeater-list="<?php echo esc_attr( $field['base'] ); ?>" >
|
||||
<table class="form-table" data-repeater-item>
|
||||
<tbody>
|
||||
<?php $this->generate_section_fields( $field, $counter ); ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th></th>
|
||||
<td>
|
||||
<span class="button-secondary" data-repeater-delete><?php esc_html_e( 'Delete Item', 'powerkit' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
</div>
|
||||
<span data-repeater-create class="button-primary"><?php esc_html_e( 'Add Item', 'powerkit' ); ?></span>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ajax Load Admin Shortcodes Panel
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function powerkit_basic_shortcodes_ajax_panel() {
|
||||
|
||||
// Allow themes and plugins to enable/disable specific shortcodes UI panel.
|
||||
$sections = apply_filters( 'powerkit_basic_shortcodes_ui_args', array() );
|
||||
|
||||
// Sort elements.
|
||||
usort( $sections, function ( $a, $b ) {
|
||||
return $a['priority'] - $b['priority'];
|
||||
} );
|
||||
?>
|
||||
<div class="wrap powerkit_basic_shortcodes_wrap">
|
||||
|
||||
<div class="powerkit_basic_shortcodes_tabs">
|
||||
|
||||
<ul>
|
||||
<?php foreach ( $sections as $section ) : ?>
|
||||
<li><a data-nav="<?php echo esc_attr( $section['name'] ); ?>" href="#"><?php echo esc_html( $section['title'] ); ?></a></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="powerkit_basic_shortcodes_tabs_sections">
|
||||
|
||||
<?php foreach ( $sections as $section ) : ?>
|
||||
<div class="hidable wrap tabs-<?php echo esc_attr( $section['name'] ); ?>" style="display: none;">
|
||||
|
||||
<form class="powerkit_basic_shortcodes_tab" enctype="multipart/form-data">
|
||||
<table class="form-table">
|
||||
<tbody>
|
||||
<?php $this->generate_section_fields( $section ); ?>
|
||||
|
||||
<tr>
|
||||
<th><input type="submit" class="button-primary" value="<?php esc_html_e( 'Insert', 'powerkit' ); ?>"></th>
|
||||
<td> </td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
(function($) {
|
||||
|
||||
// Insert Shortcode.
|
||||
$('.tabs-<?php echo esc_attr( $section['name'] ); ?> form').submit( function( e ) {
|
||||
e.preventDefault();
|
||||
|
||||
// Hide Popup.
|
||||
tb_remove();
|
||||
|
||||
// Get input values from form.
|
||||
var fieldsObj = $( this ).serializeObject();
|
||||
|
||||
// Vars.
|
||||
var shortcodeContent = '',
|
||||
shortcodeAttrs = [];
|
||||
|
||||
<?php foreach ( (array) $section['fields'] as $field ) : ?>
|
||||
|
||||
var fieldName = '<?php echo esc_attr( isset( $field['name'] ) ? $field['name'] : '' ); ?>';
|
||||
<?php
|
||||
switch ( $field['type'] ) {
|
||||
case 'section':
|
||||
break;
|
||||
case 'repeater':
|
||||
?>
|
||||
var subContentVars = [],
|
||||
subCheckboxVars = [],
|
||||
shortcodeBase = '<?php echo esc_attr( $field['base'] ); ?>';
|
||||
|
||||
<?php foreach ( (array) $field['fields'] as $sub_field ) : ?>
|
||||
|
||||
<?php if ( 'content' === $sub_field['type'] ) : ?>
|
||||
subContentVars.push( '<?php echo esc_attr( $sub_field['name'] ); ?>' );
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( 'checkbox' === $sub_field['type'] ) : ?>
|
||||
subCheckboxVars.push( '<?php echo esc_attr( $sub_field['name'] ); ?>' );
|
||||
<?php endif; ?>
|
||||
|
||||
<?php endforeach; ?>
|
||||
|
||||
if( typeof fieldsObj[ shortcodeBase ] !== 'undefined' ) {
|
||||
|
||||
$.each( fieldsObj[ shortcodeBase ], function( key, obj ) {
|
||||
|
||||
var subShortcodeContent = '',
|
||||
subShortcodeAttrs = [];
|
||||
|
||||
$.each( obj, function( s_key, s_obj ) {
|
||||
if( typeof s_obj !== 'undefined' ) {
|
||||
|
||||
// Field "Content" fix.
|
||||
if( ! $.inArray( s_key, subContentVars ) ) {
|
||||
subShortcodeContent += s_obj;
|
||||
} else {
|
||||
|
||||
// Other fields.
|
||||
subShortcodeAttrs.push( s_key + '="' + s_obj + '"' );
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
// Add Inner Shortcode.
|
||||
if( subShortcodeContent ) {
|
||||
shortcodeContent += '[' + shortcodeBase + ' ' + subShortcodeAttrs.join( ' ' ) + ']<br>' + subShortcodeContent + '<br>[/' + shortcodeBase + ']<br>';
|
||||
} else {
|
||||
shortcodeContent += '[' + shortcodeBase + ' ' + subShortcodeAttrs.join( ' ' ) + ']<br>';
|
||||
}
|
||||
|
||||
} );
|
||||
}
|
||||
<?php
|
||||
break;
|
||||
case 'content':
|
||||
?>
|
||||
if( typeof fieldsObj[ fieldName ] !== 'undefined' ) {
|
||||
shortcodeContent += fieldsObj[ fieldName ];
|
||||
}
|
||||
<?php
|
||||
break;
|
||||
case 'checkbox':
|
||||
?>
|
||||
if( typeof fieldsObj[ fieldName ] !== 'undefined' ) {
|
||||
var fieldAttr = fieldName + '="' + fieldsObj[ fieldName ] + '"';
|
||||
} else {
|
||||
var fieldAttr = fieldName + '="false"';
|
||||
}
|
||||
|
||||
shortcodeAttrs.push( fieldAttr );
|
||||
<?php
|
||||
break;
|
||||
default:
|
||||
?>
|
||||
if( typeof fieldsObj[ fieldName ] !== 'undefined' ) {
|
||||
var fieldAttr = fieldName + '="' + fieldsObj[ fieldName ] + '"';
|
||||
} else {
|
||||
var fieldAttr = fieldName + '=""';
|
||||
}
|
||||
|
||||
shortcodeAttrs.push( fieldAttr );
|
||||
<?php
|
||||
break;
|
||||
}
|
||||
?>
|
||||
<?php endforeach; ?>
|
||||
|
||||
// Add Shortcode.
|
||||
var shortcodeName = '<?php echo esc_attr( $section['base'] ); ?>';
|
||||
|
||||
if( shortcodeContent ) {
|
||||
|
||||
// Trim Line Breaks.
|
||||
shortcodeContent = shortcodeContent.replace( /^<br>|<br>$/gm, '' );
|
||||
|
||||
var content = '[' + shortcodeName + ' ' + shortcodeAttrs.join( ' ' ) + ']<br>' + shortcodeContent + '<br>[/' + shortcodeName + ']';
|
||||
} else {
|
||||
var content = '[' + shortcodeName + ' ' + shortcodeAttrs.join( ' ' ) + ']';
|
||||
}
|
||||
|
||||
// Remove odd space.
|
||||
content = content.replace(/\s\]/g, ']');
|
||||
|
||||
// Convert br.
|
||||
content = content.replace(/([^>])\n/g, '$1<br/>');
|
||||
|
||||
powerkit_basic_shortcodes.setContent( content );
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
/* ]]> */
|
||||
</script>
|
||||
<?php endforeach; ?>
|
||||
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
/* <![CDATA[ */
|
||||
( function( $ ) {
|
||||
|
||||
// Tabs Navigation.
|
||||
$( '.powerkit_basic_shortcodes_tabs a' ).click( function( e ) {
|
||||
e.preventDefault();
|
||||
powerkit_basic_shortcodes_tabs_switch( $( this ) );
|
||||
} );
|
||||
|
||||
powerkit_basic_shortcodes_tabs_switch( $( '.powerkit_basic_shortcodes_tabs a' ).first() );
|
||||
|
||||
function powerkit_basic_shortcodes_tabs_switch( obj ) {
|
||||
$( '.powerkit_basic_shortcodes_tabs_sections .hidable' ).hide();
|
||||
$( '.powerkit_basic_shortcodes_tabs_sections .tabs-' + obj.attr( 'data-nav' ) ).show();
|
||||
$( '.powerkit_basic_shortcodes_tabs li' ).removeClass( 'current' );
|
||||
obj.parent().addClass( 'current' );
|
||||
}
|
||||
|
||||
// Init Repeater.
|
||||
$( document ).ready( function() {
|
||||
$( '.basic-shortcodes-repeater-field' ).each( function() {
|
||||
$( this ).repeater( {
|
||||
show: function() {
|
||||
$( this ).slideDown();
|
||||
},
|
||||
hide: function( deleteElement ) {
|
||||
$( this ).fadeOut( 400 );
|
||||
},
|
||||
isFirstItemUndeletable: true,
|
||||
} );
|
||||
} );
|
||||
} );
|
||||
|
||||
} )( jQuery );
|
||||
/* ]]> */
|
||||
</script>
|
||||
</div>
|
||||
<?php
|
||||
die();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the stylesheets and JavaScript for the admin area.
|
||||
*
|
||||
* @param string $page Current page.
|
||||
*/
|
||||
public function admin_enqueue_scripts( $page ) {
|
||||
|
||||
add_thickbox();
|
||||
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
// Styles.
|
||||
wp_enqueue_style( 'powerkit-basic-elements', powerkit_style( plugin_dir_url( __FILE__ ) . 'css/admin-powerkit-basic-elements.css' ), array(), powerkit_get_setting( 'version' ), 'all' );
|
||||
|
||||
wp_enqueue_script( 'wp-color-picker' );
|
||||
// Scripts.
|
||||
wp_enqueue_script( 'powerkit-jquery-serialize', plugin_dir_url( __FILE__ ) . 'js/jquery.serialize-to-json.min.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false );
|
||||
wp_enqueue_script( 'powerkit-jquery-repeater', plugin_dir_url( __FILE__ ) . 'js/jquery.repeater.min.js', array( 'jquery' ), powerkit_get_setting( 'version' ), false );
|
||||
}
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
.powerkit_basic_shortcodes_wrap {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
height: 97.5%;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_wrap .form-table td,
|
||||
.powerkit_basic_shortcodes_wrap .form-table th {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs {
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
background: #f9f9f9;
|
||||
border-left: 1px solid #EEE;
|
||||
float: right;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
font-family: Helvetica, Arial;
|
||||
color: #333;
|
||||
font-size: 12px;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li {
|
||||
width: 201px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current {
|
||||
display: block;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current a {
|
||||
background: #FFF;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li a {
|
||||
display: block;
|
||||
padding: 14px 20px;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li:last-child a {
|
||||
box-shadow: 0 -1px 0 #eee, 0 1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
padding: 0 20px 0 0;
|
||||
margin: 0;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections table tr th small {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: #777777;
|
||||
}
|
||||
|
||||
/* Repeater */
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table th,
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field th,
|
||||
.basic-shortcodes-repeater-field td {
|
||||
display: block;
|
||||
padding: 0 0 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* TB_window */
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent {
|
||||
padding: 0 0 30px 0;
|
||||
width: 100% !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li:before {
|
||||
display: none;
|
||||
}
|
||||
+116
@@ -0,0 +1,116 @@
|
||||
.powerkit_basic_shortcodes_wrap {
|
||||
position: relative;
|
||||
margin: 0;
|
||||
height: 97.5%;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_wrap .form-table td,
|
||||
.powerkit_basic_shortcodes_wrap .form-table th {
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs {
|
||||
width: 200px;
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
background: #f9f9f9;
|
||||
border-right: 1px solid #EEE;
|
||||
float: left;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
font-family: Helvetica, Arial;
|
||||
color: #333;
|
||||
font-size: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li {
|
||||
width: 201px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current {
|
||||
display: block;
|
||||
margin: 0px;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs li.current a {
|
||||
background: #FFF;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li a {
|
||||
display: block;
|
||||
padding: 14px 20px;
|
||||
font-size: 12px;
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
box-shadow: 0 -1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs ul li:last-child a {
|
||||
box-shadow: 0 -1px 0 #eee, 0 1px 0 #eee;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections {
|
||||
overflow: auto;
|
||||
height: 100%;
|
||||
position: relative;
|
||||
padding: 0 0 0 20px;
|
||||
margin: 0;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
.powerkit_basic_shortcodes_tabs_sections table tr th small {
|
||||
display: block;
|
||||
margin-top: 5px;
|
||||
color: #777777;
|
||||
}
|
||||
|
||||
/* Repeater */
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table th,
|
||||
.powerkit_basic_shortcodes_wrap .basic-shortcodes-repeater-field .form-table td {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field th,
|
||||
.basic-shortcodes-repeater-field td {
|
||||
display: block;
|
||||
padding: 0 0 10px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot {
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.basic-shortcodes-repeater-field tfoot th {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* TB_window */
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent {
|
||||
padding: 0 0 30px 0;
|
||||
width: 100% !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent ul {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#TB_window.powerkit_basic_shortcodes_window #TB_ajaxContent li:before {
|
||||
display: none;
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
+49
@@ -0,0 +1,49 @@
|
||||
"use strict";
|
||||
|
||||
var powerkit_basic_shortcodes;
|
||||
var powerkit_basic_shortcodes_content;
|
||||
|
||||
( function() {
|
||||
tinymce.create( 'tinymce.plugins.powerkit_basic_shortcodes', {
|
||||
init: function( ed, url ) {
|
||||
ed.addButton( 'powerkit_basic_shortcodes_button', {
|
||||
title: 'Basic Shortcodes',
|
||||
image: url.substring( 0, url.length - 3 ) + '/images/icon.png',
|
||||
onclick: function() {
|
||||
|
||||
powerkit_basic_shortcodes = ed.selection;
|
||||
powerkit_basic_shortcodes_content = ed.selection.getContent();
|
||||
|
||||
var width = jQuery( window ).width(),
|
||||
H = jQuery( window ).height(),
|
||||
W = ( 720 < width ) ? 720 : width;
|
||||
W = W - 80;
|
||||
H = H - 84;
|
||||
|
||||
|
||||
var shortcodes_loaded = jQuery( '#powerkit_basic_shortcodes_holder' ).length;
|
||||
|
||||
if ( shortcodes_loaded ) {
|
||||
|
||||
tb_show( 'Basic Shortcodes', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=powerkit_basic_shortcodes' );
|
||||
jQuery( '#TB_window' ).addClass( 'powerkit_basic_shortcodes_window' );
|
||||
|
||||
} else {
|
||||
|
||||
jQuery( "body" ).append( '<div id="powerkit_basic_shortcodes_holder" style="display: none;"><div id="powerkit_basic_shortcodes"></div></div>' );
|
||||
|
||||
jQuery.get( 'admin-ajax.php?action=powerkit_basic_shortcodes_sections', function( data ) {
|
||||
jQuery( '#powerkit_basic_shortcodes' ).html( data );
|
||||
tb_show( 'Basic Shortcodes', '#TB_inline?width=' + W + '&height=' + H + '&inlineId=powerkit_basic_shortcodes' );
|
||||
jQuery( '#TB_window' ).addClass( 'powerkit_basic_shortcodes_window' );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
},
|
||||
createControl: function( n, cm ) {
|
||||
return null;
|
||||
},
|
||||
} );
|
||||
tinymce.PluginManager.add( 'powerkit_basic_shortcodes', tinymce.plugins.powerkit_basic_shortcodes );
|
||||
} )();
|
||||
+5
File diff suppressed because one or more lines are too long
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* jQuery serializeObject
|
||||
* @copyright 2014, macek <paulmacek@gmail.com>
|
||||
* @link https://github.com/macek/jquery-serialize-object
|
||||
* @license BSD
|
||||
* @version 2.5.0
|
||||
*/
|
||||
!function(e,i){if("function"==typeof define&&define.amd)define(["exports","jquery"],function(e,r){return i(e,r)});else if("undefined"!=typeof exports){var r=require("jquery");i(exports,r)}else i(e,e.jQuery||e.Zepto||e.ender||e.$)}(this,function(e,i){function r(e,r){function n(e,i,r){return e[i]=r,e}function a(e,i){for(var r,a=e.match(t.key);void 0!==(r=a.pop());)if(t.push.test(r)){var u=s(e.replace(/\[\]$/,""));i=n([],u,i)}else t.fixed.test(r)?i=n([],r,i):t.named.test(r)&&(i=n({},r,i));return i}function s(e){return void 0===h[e]&&(h[e]=0),h[e]++}function u(e){switch(i('[name="'+e.name+'"]',r).attr("type")){case"checkbox":return"on"===e.value?!0:e.value;default:return e.value}}function f(i){if(!t.validate.test(i.name))return this;var r=a(i.name,u(i));return l=e.extend(!0,l,r),this}function d(i){if(!e.isArray(i))throw new Error("formSerializer.addPairs expects an Array");for(var r=0,t=i.length;t>r;r++)this.addPair(i[r]);return this}function o(){return l}function c(){return JSON.stringify(o())}var l={},h={};this.addPair=f,this.addPairs=d,this.serialize=o,this.serializeJSON=c}var t={validate:/^[a-z_][a-z0-9_]*(?:\[(?:\d*|[a-z0-9_]+)\])*$/i,key:/[a-z0-9_]+|(?=\[\])/gi,push:/^$/,fixed:/^\d+$/,named:/^[a-z0-9_]+$/i};return r.patterns=t,r.serializeObject=function(){return new r(i,this).addPairs(this.serializeArray()).serialize()},r.serializeJSON=function(){return new r(i,this).addPairs(this.serializeArray()).serializeJSON()},"undefined"!=typeof i.fn&&(i.fn.serializeObject=r.serializeObject,i.fn.serializeJSON=r.serializeJSON),e.FormSerializer=r,r});
|
||||
Reference in New Issue
Block a user