레이블이 JQuery인 게시물을 표시합니다. 모든 게시물 표시
레이블이 JQuery인 게시물을 표시합니다. 모든 게시물 표시

2018년 7월 23일 월요일

Wordpress tips

Child theme's Javascript file is loaded earlier than parent theme's.

For example, global-child.js is loaded right after jquery-min.js loaded and global.js of the parent theme is located at the bottom of <body> tag in the code.


In child theme, JQuery variables without $ should be declared and defined in the $(document).ready().

Weirdly some variables were found 'undefined' in the debugger, if they are defined before/out of $(document).ready()  just like twenty seventeen theme's global.js.


Firing a code after a jquery animation:

    code it in the callback function of animation().

Firing a code after a CSS transition, for instance, 'transition: 0.6s ease' which is triggered by something like addClass( 'fade-in' ) call:

    $("#selector").one("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd", function(){ ... });

.one() means running the callback only once.

Source: https://stackoverflow.com/questions/9255279/callback-when-css3-transition-finishes


Loading a page/post-specific Javascript:
    function load_scripts() {
    global $post;
    if ( is_page() || is_single() ) {
        switch( $post->post_name ) {
            case 'home':
                wp_enqueue_script( 'home', get_template_directory_uri().'/js/home.js', array( 'jquery' ), '', false);
            case 'about-page':
                wp_enqueue_script( 'about', get_template_directory_uri().'/js/about-page.js', array( 'jquery' ), '', false);
        }
    }
    add_action( 'wp_enqueue_scripts', 'load_scripts' );

Source: https://wordpress.stackexchange.com/questions/67802/most-efficient-way-to-add-javascript-file-to-specific-post-and-or-pages



Xubuntu: Installing a Printer (Canon G3060 PIXMA)

$ sudo apt install system-config-printer Download the proper driver for linux from Canon website. Turn on the printer and set up its WiFi. C...