Plugin Directory

Changeset 2500440


Ignore:
Timestamp:
03/21/2021 03:06:39 PM (5 years ago)
Author:
xsvet
Message:

Dark mode feature

Location:
mobiloud-mobile-app-plugin/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • mobiloud-mobile-app-plugin/trunk/assets/js/mobiloud-forms.js

    r2291775 r2500440  
    225225            })
    226226        }
     227
     228        // current page can have only 1 item of this type.
     229        if ( jQuery('.upload-logo-block').length) { // Dark mode block.
     230            jQuery('.upload-logo-block').each(function( i, block ) {
     231            ( function( $ ) {
     232                var $block = $(block);
     233                var $button = $block.find('.upload-logo-button');
     234                var $input = $block.find('.upload-logo-input');
     235                var $clean = $block.find('.upload-logo-clean');
     236                var $view = $block.find('.upload-logo-view');
     237                var _orig_send_attachment = wp.media.editor.send.attachment;
     238                var timer = null;
     239
     240                var icon_preview = function( url ) {
     241                    if ( timer ) {
     242                        clearTimeout( timer );
     243                    }
     244                    timer = setTimeout( function() {
     245                        $view.attr( 'src', url );
     246                        if ( '' !== url ) {
     247                            $view.parent().parent().show();
     248                        } else {
     249                            $view.parent().parent().hide();
     250                        }
     251                        }, 200 );
     252                }
     253                var icon_clear = function() {
     254                    $view.attr( 'src', '' );
     255                    $view.parent().parent().hide();
     256                }
     257
     258                $input.on('keyup change paste', function() {
     259                    icon_preview( $input.val() );
     260                })
     261                $clean.click(
     262                    function(e) {
     263                        $input.val('');
     264                        icon_clear();
     265                        return false;
     266                    }
     267                );
     268
     269                $button.on('click',
     270                    function(e) {
     271                        var send_attachment_bkp         = wp.media.editor.send.attachment;
     272                        _custom_media                   = true;
     273                        wp.media.editor.send.attachment = function(props, attachment) {
     274                            wp.media.editor.send.attachment = send_attachment_bkp;
     275                            if (_custom_media) {
     276                                var url = attachment.url;
     277                                $input.val( url ).trigger('change');
     278                                icon_preview( url );
     279                                _custom_media = false;
     280                            } else {
     281                                return _orig_send_attachment.apply( this, [props, attachment] );
     282                            }
     283                        };
     284                        wp.media.editor.open( $button );
     285                        return false;
     286                    }
     287                )
     288            } )( jQuery);
     289            })
     290        }
    227291    }
    228292);
  • mobiloud-mobile-app-plugin/trunk/class.mobiloud-admin.php

    r2462796 r2500440  
    10111011
    10121012            case 'settings':
     1013                self::enqueue_codemirror( [ 'text/css' ] );
    10131014                wp_register_script( 'mobiloud-settings', MOBILOUD_PLUGIN_URL . '/assets/js/mobiloud-settings.js', array( 'jquery' ) );
    10141015                wp_enqueue_script( 'mobiloud-settings' );
     
    11491150                        Mobiloud::set_option( 'ml_ignore_shortcodes', [] );
    11501151                    }
     1152
     1153                    Mobiloud::set_option( 'ml_dark_mode_enabled', isset( $_POST['ml_dark_mode_enabled'] ) );
     1154                    Mobiloud::set_option( 'ml_dark_mode_logo', sanitize_text_field( $_POST['ml_dark_mode_logo'] ) );
     1155                    Mobiloud::set_option( 'ml_dark_mode_header_color', sanitize_hex_color( $_POST['ml_dark_mode_header_color'] ) );
     1156                    Mobiloud::set_option( 'ml_dark_mode_tabbed_navigation_color', sanitize_hex_color( $_POST['ml_dark_mode_tabbed_navigation_color'] ) );
     1157                    Mobiloud::set_option( 'ml_dark_mode_tabbed_navigation_icons_color', sanitize_hex_color( $_POST['ml_dark_mode_tabbed_navigation_icons_color'] ) );
     1158                    Mobiloud::set_option( 'ml_dark_mode_tabbed_navigation_active_icon_color', sanitize_hex_color( $_POST['ml_dark_mode_tabbed_navigation_active_icon_color'] ) );
     1159                    Mobiloud::set_option( 'ml_dark_mode_notification_switch_main_color', sanitize_hex_color( $_POST['ml_dark_mode_notification_switch_main_color'] ) );
     1160                    Mobiloud::set_option( 'ml_dark_mode_notification_switch_background_color', sanitize_hex_color( $_POST['ml_dark_mode_notification_switch_background_color'] ) );
     1161                    Mobiloud::set_option( 'ml_dark_mode_hamburger_menu_background_color', sanitize_hex_color( $_POST['ml_dark_mode_hamburger_menu_background_color'] ) );
     1162                    Mobiloud::set_option( 'ml_dark_mode_hamburger_menu_text_color', sanitize_hex_color( $_POST['ml_dark_mode_hamburger_menu_text_color'] ) );
     1163                    Mobiloud::set_option( 'ml_dark_mode_custom_css', wp_unslash( $_POST['ml_dark_mode_custom_css'] ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
     1164
    11511165                    Mobiloud::set_option( 'ml_related_posts', isset( $_POST['ml_related_posts'] ) );
    11521166                    if ( isset( $_POST['ml_related_header'] ) ) {
  • mobiloud-mobile-app-plugin/trunk/config.php

    r2385192 r2500440  
    359359$return_config['cache_busting_interval'] = get_option( 'ml_cache_busting_interval', '15' );
    360360
     361$return_config['dark_mode_enabled']                              = (string) get_option( 'ml_dark_mode_enabled', false );
     362$return_config['dark_mode_logo']                                 = (string) get_option( 'ml_dark_mode_logo', '' );
     363$return_config['dark_mode_header_color']                         = (string) get_option( 'ml_dark_mode_header_color', '' );
     364$return_config['dark_mode_tabbed_navigation_color']              = (string) get_option( 'ml_dark_mode_tabbed_navigation_color', '' );
     365$return_config['dark_mode_tabbed_navigation_icons_color']        = (string) get_option( 'ml_dark_mode_tabbed_navigation_icons_color', '' );
     366$return_config['dark_mode_tabbed_navigation_active_icon_color']  = (string) get_option( 'ml_dark_mode_tabbed_navigation_active_icon_color', '' );
     367$return_config['dark_mode_notification_switch_main_color']       = (string) get_option( 'ml_dark_mode_notification_switch_main_color', '' );
     368$return_config['dark_mode_notification_switch_background_color'] = (string) get_option( 'ml_dark_mode_notification_switch_background_color', '' );
     369$return_config['dark_mode_hamburger_menu_background_color']      = (string) get_option( 'ml_dark_mode_hamburger_menu_background_color', '' );
     370$return_config['dark_mode_hamburger_menu_text_color']            = (string) get_option( 'ml_dark_mode_hamburger_menu_text_color', '' );
     371
     372
     373$return_config['dark_mode_custom_css'] = (string) get_option( 'ml_dark_mode_custom_css', '' );
     374
     375
    361376if ( ! empty( $return_config ) ) {
    362377    foreach ( $return_config as $key => $val ) {
  • mobiloud-mobile-app-plugin/trunk/views/settings_settings.php

    r2459969 r2500440  
    479479
    480480<div class="ml2-block">
     481    <div class="ml2-header"><h2>Dark mode</h2></div>
     482    <div class="ml2-body upload-logo-block">
     483
     484        <div class='ml-col-row'>
     485            <p>This setting determines if the dark mode option should be displayed in the app's settings screen or not. If disabled, dark mode should not be applied to the app at all, even if the user previously enabled it.</p>
     486            <div class="ml-form-row ml-checkbox-wrap">
     487                <input type="checkbox" id="ml_dark_mode_enabled" name="ml_dark_mode_enabled"
     488                    value="true" <?php checked( Mobiloud::get_option( 'ml_dark_mode_enabled' ) ); ?>/>
     489                <label for="ml_dark_mode_enabled">Enable Dark mode</label>
     490            </div>
     491        </div>
     492
     493        <h4>Dark mode logo</h4>
     494        <div class="ml-col-row">
     495            <div class="ml-col-half">
     496                <p>Custom version of the logo used in the app's header when dark mode is enabled on the user device.</p>
     497            </div>
     498            <div class="ml-col-half">
     499                <?php $logo = Mobiloud::get_option( 'ml_dark_mode_logo', '' ); ?>
     500
     501                <input type="text" size="36" name="ml_dark_mode_logo" class="upload-logo-input"
     502                    value="<?php echo esc_url( $logo ); ?>"/>
     503                <input type="button" value="Upload Image" class="browser button upload-logo-button"/>
     504                <div class="clearfix"></div>
     505                <div class="ml-col-half ml-preview-upload-image-row" <?php echo ( strlen( $logo ) === 0 ) ? 'style="display:none;"' : ''; ?>>
     506                    <div class="ml-preview-image-holder">
     507                        <img src="<?php echo esc_url( $logo ); ?>" class="upload-logo-view"/>
     508                    </div>
     509                    <a href="#" class="ml-preview-image-remove-btn upload-logo-clean">Remove logo</a>
     510                </div>
     511            </div>
     512        </div>
     513
     514        <h4>Header color</h4>
     515        <div class="ml-col-row ml-color">
     516            <div class="ml-col-half">
     517                <p>Custom color for the header background when dark mode is enabled.</p>
     518            </div>
     519            <div class="ml-col-half">
     520                <input  class="color-picker" name="ml_dark_mode_header_color" type="text"
     521                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_header_color' ) ); ?>"/>
     522            </div>
     523        </div>
     524
     525        <h4>Tabbed navigation color</h4>
     526        <div class="ml-col-row ml-color">
     527            <div class="ml-col-half">
     528                <p>Custom color for the tabbed navigation background when dark mode is enabled.</p>
     529            </div>
     530            <div class="ml-col-half">
     531                <input  class="color-picker" name="ml_dark_mode_tabbed_navigation_color" type="text"
     532                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_tabbed_navigation_color' ) ); ?>"/>
     533            </div>
     534        </div>
     535
     536        <h4>Tabbed navigation icons color</h4>
     537        <div class="ml-col-row ml-color">
     538            <div class="ml-col-half">
     539                <p>Custom color for the icons displayed in the tabbed navigation when dark mode is enabled</p>
     540            </div>
     541            <div class="ml-col-half">
     542                <input  class="color-picker" name="ml_dark_mode_tabbed_navigation_icons_color" type="text"
     543                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_tabbed_navigation_icons_color' ) ); ?>"/>
     544            </div>
     545        </div>
     546
     547        <h4>Tabbed navigation active icon color</h4>
     548        <div class="ml-col-row ml-color">
     549            <div class="ml-col-half">
     550                <p>Custom color for the tabbed navigation active icon color when dark mode is enabled</p>
     551            </div>
     552            <div class="ml-col-half">
     553                <input  class="color-picker" name="ml_dark_mode_tabbed_navigation_active_icon_color" type="text"
     554                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_tabbed_navigation_active_icon_color' ) ); ?>"/>
     555            </div>
     556        </div>
     557
     558        <h4>Notification switch main color</h4>
     559        <div class="ml-col-row ml-color">
     560            <div class="ml-col-half">
     561                <p>Custom color for the notification switch main color when dark mode is enabled</p>
     562            </div>
     563            <div class="ml-col-half">
     564                <input  class="color-picker" name="ml_dark_mode_notification_switch_main_color" type="text"
     565                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_notification_switch_main_color' ) ); ?>"/>
     566            </div>
     567        </div>
     568
     569        <h4>Notification switch background color</h4>
     570        <div class="ml-col-row ml-color">
     571            <div class="ml-col-half">
     572                <p>Custom color for the notification switch background color when dark mode is enabled</p>
     573            </div>
     574            <div class="ml-col-half">
     575                <input  class="color-picker" name="ml_dark_mode_notification_switch_background_color" type="text"
     576                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_notification_switch_background_color' ) ); ?>"/>
     577            </div>
     578        </div>
     579
     580        <h4>Hamburger menu background color</h4>
     581        <div class="ml-col-row ml-color">
     582            <div class="ml-col-half">
     583                <p>Custom color for the hamburger menu background color when dark mode is enabled</p>
     584            </div>
     585            <div class="ml-col-half">
     586                <input  class="color-picker" name="ml_dark_mode_hamburger_menu_background_color" type="text"
     587                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_hamburger_menu_background_color' ) ); ?>"/>
     588            </div>
     589        </div>
     590
     591        <h4>Hamburger menu text color</h4>
     592        <div class="ml-col-row ml-color">
     593            <div class="ml-col-half">
     594                <p>Custom color for the hamburger menu text color when dark mode is enabled</p>
     595            </div>
     596            <div class="ml-col-half">
     597                <input  class="color-picker" name="ml_dark_mode_hamburger_menu_text_color" type="text"
     598                    value="<?php echo esc_attr( get_option( 'ml_dark_mode_hamburger_menu_text_color' ) ); ?>"/>
     599            </div>
     600        </div>
     601
     602        <h4>Custom CSS</h4>
     603        <div class="ml-col-row">
     604            <label>Custom CSS to be injected in the app's content when dark mode is enabled, allowing us to customize the appearance of the content in dark mode specifically.</label>
     605            <textarea class="ml-editor-area ml-editor-area-css ml-show" name="ml_dark_mode_custom_css"><?php echo esc_html( Mobiloud::get_option( 'ml_dark_mode_custom_css', '' ) ); ?></textarea>
     606        </div>
     607    </div>
     608</div>
     609
     610<div class="ml2-block">
    481611    <div class="ml2-header"><h2>Related Posts</h2></div>
    482612    <div class="ml2-body">
Note: See TracChangeset for help on using the changeset viewer.