Модераторы: Sardar, Aliance
  

Поиск:

Ответ в темуСоздание новой темы Создание опроса
> помоги найти ошибку в коде 
:(
    Опции темы
Starikan
Дата 30.9.2016, 01:18 (ссылка) | (нет голосов) Загрузка ... Загрузка ... Быстрая цитата Цитата


Шустрый
*


Профиль
Группа: Участник
Сообщений: 87
Регистрация: 25.10.2007

Репутация: -2
Всего: -15



блин ребята помогите плиз ошибку найти в коде старине

Код

/* global _wpCustomizeHeader, _wpCustomizeBackground, _wpMediaViewsL10n, MediaElementPlayer */
(function( exports, $ ){
    var Container, focus, api = wp.customize;


    /**
     * Stable sort for Panels, Sections, and Controls.
     *
     * If a.priority() === b.priority(), then sort by their respective params.instanceNumber.
     *
     * @since 4.1.0
     *
     * @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} a
     * @param {(wp.customize.Panel|wp.customize.Section|wp.customize.Control)} b
     * @returns {Number}
     */
    api.utils.prioritySort = function ( a, b ) {
        if ( a.priority() === b.priority() && typeof a.params.instanceNumber === 'number' && typeof b.params.instanceNumber === 'number' ) {
            return a.params.instanceNumber - b.params.instanceNumber;
        } else {
            return a.priority() - b.priority();
        }
    };

    /**
     * Return whether the supplied Event object is for a keydown event but not the Enter key.
     *
     * @since 4.1.0
     *
     * @param {jQuery.Event} event
     * @returns {boolean}
     */
    api.utils.isKeydownButNotEnterEvent = function ( event ) {
        return ( 'keydown' === event.type && 13 !== event.which );
    };

    /**
     * Return whether the two lists of elements are the same and are in the same order.
     *
     * @since 4.1.0
     *
     * @param {Array|jQuery} listA
     * @param {Array|jQuery} listB
     * @returns {boolean}
     */
    api.utils.areElementListsEqual = function ( listA, listB ) {
        var equal = (
            listA.length === listB.length && // if lists are different lengths, then naturally they are not equal
            -1 === _.indexOf( _.map( // are there any false values in the list returned by map?
                _.zip( listA, listB ), // pair up each element between the two lists
                function ( pair ) {
                    return $( pair[0] ).is( pair[1] ); // compare to see if each pair are equal
                }
            ), false ) // check for presence of false in map's return value
        );
        return equal;
    };

    /**
     * Base class for Panel and Section.
     *
     * @since 4.1.0
     *
     * @class
     * @augments wp.customize.Class
     */
    Container = api.Class.extend({
        defaultActiveArguments: { duration: 'fast', completeCallback: $.noop },
        defaultExpandedArguments: { duration: 'fast', completeCallback: $.noop },
        containerType: 'container',
        defaults: {
            title: '',
            description: '',
            priority: 100,
            type: 'default',
            content: null,
            active: true,
            instanceNumber: null
        },

        /**
         * @since 4.1.0
         *
         * @param {string}         id - The ID for the container.
         * @param {object}         options - Object containing one property: params.
         * @param {object}         options.params - Object containing the following properties.
         * @param {string}         options.params.title - Title shown when panel is collapsed and expanded.
         * @param {string=}        [options.params.description] - Description shown at the top of the panel.
         * @param {number=100}     [options.params.priority] - The sort priority for the panel.
         * @param {string=default} [options.params.type] - The type of the panel. See wp.customize.panelConstructor.
         * @param {string=}        [options.params.content] - The markup to be used for the panel container. If empty, a JS template is used.
         * @param {boolean=true}   [options.params.active] - Whether the panel is active or not.
         */
        initialize: function ( id, options ) {
            var container = this;
            container.id = id;
            options = options || {};

            options.params = _.defaults(
                options.params || {},
                container.defaults
            );

            $.extend( container, options );
            container.templateSelector = 'customize-' + container.containerType + '-' + container.params.type;
            container.container = $( container.params.content );
            if ( 0 === container.container.length ) {
                container.container = $( container.getContainer() );
            }

            container.deferred = {
                embedded: new $.Deferred()
            };
            container.priority = new api.Value();
            container.active = new api.Value();
            container.activeArgumentsQueue = [];
            container.expanded = new api.Value();
            container.expandedArgumentsQueue = [];

            container.active.bind( function ( active ) {
                var args = container.activeArgumentsQueue.shift();
                args = $.extend( {}, container.defaultActiveArguments, args );
                active = ( active && container.isContextuallyActive() );
                container.onChangeActive( active, args );
            });
            container.expanded.bind( function ( expanded ) {
                var args = container.expandedArgumentsQueue.shift();
                args = $.extend( {}, container.defaultExpandedArguments, args );
                container.onChangeExpanded( expanded, args );
            });

            container.deferred.embedded.done( function () {
                container.attachEvents();
            });

            api.utils.bubbleChildValueChanges( container, [ 'priority', 'active' ] );

            container.priority.set( container.params.priority );
            container.active.set( container.params.active );
            container.expanded.set( false );
        },

        /**
         * @since 4.1.0
         *
         * @abstract
         */
        ready: function() {},

        /**
         * Get the child models associated with this parent, sorting them by their priority Value.
         *
         * @since 4.1.0
         *
         * @param {String} parentType
         * @param {String} childType
         * @returns {Array}
         */
        _children: function ( parentType, childType ) {
            var parent = this,
                children = [];
            api[ childType ].each( function ( child ) {
                if ( child[ parentType ].get() === parent.id ) {
                    children.push( child );
                }
            } );
            children.sort( api.utils.prioritySort );
            return children;
        },

        /**
         * To override by subclass, to return whether the container has active children.
         *
         * @since 4.1.0
         *
         * @abstract
         */
        isContextuallyActive: function () {
            throw new Error( 'Container.isContextuallyActive() must be overridden in a subclass.' );
        },

        

        // Create Settings
        $.each( api.settings.settings, function( id, data ) {
            api.create( id, id, data.value, {
                transport: data.transport,
                previewer: api.previewer,
                dirty: !! data.dirty
            } );
        });

        // Create Panels
        $.each( api.settings.panels, function ( id, data ) {
            var constructor = api.panelConstructor[ data.type ] || api.Panel,
                panel;

            panel = new constructor( id, {
                params: data
            } );
            api.panel.add( id, panel );
        });

        // Create Sections
        $.each( api.settings.sections, function ( id, data ) {
            var constructor = api.sectionConstructor[ data.type ] || api.Section,
                section;

            section = new constructor( id, {
                params: data
            } );
            api.section.add( id, section );
        });

        // Create Controls
        $.each( api.settings.controls, function( id, data ) {
            var constructor = api.controlConstructor[ data.type ] || api.Control,
                control;

            control = new constructor( id, {
                params: data,
                previewer: api.previewer
            } );
            api.control.add( id, control );
        });

        // Focus the autofocused element
        _.each( [ 'panel', 'section', 'control' ], function( type ) {
            var id = api.settings.autofocus[ type ];
            if ( ! id ) {
                return;
            }

            /*
             * Defer focus until:
             * 1. The panel, section, or control exists (especially for dynamically-created ones).
             * 2. The instance is embedded in the document (and so is focusable).
             * 3. The preview has finished loading so that the active states have been set.
             */
            api[ type ]( id, function( instance ) {
                instance.deferred.embedded.done( function() {
                    api.previewer.deferred.active.done( function() {
                        instance.focus();
                    });
                });
            });
        });
ugh to the parent.
        $.each( [ 'saved', 'change' ], function ( i, event ) {
            api.bind( event, function() {
                parent.send( event );
            });
        } );

        /*
         * When activated, let the loader handle redirecting the page.
         * If no loader exists, redirect the page ourselves (if a url exists).
         */
        api.bind( 'activated', function() {
            if ( parent.targetWindow() )
                parent.send( 'activated', api.settings.url.activated );
            else if ( api.settings.url.activated )
                window.location = api.settings.url.activated;
        });

        // Pass titles to the parent
        api.bind( 'title', function( newTitle ) {
            parent.send( 'title', newTitle );
        });

        // Initialize the connection with the parent frame.
        parent.send( 'ready' );

        // Control visibility for default controls
        $.each({
            'background_image': {
                controls: [ 'background_repeat', 'background_position_x', 'background_attachment' ],
                callback: function( to ) { return !! to; }
            },
            'show_on_front': {
                controls: [ 'page_on_front', 'page_for_posts' ],
                callback: function( to ) { return 'page' === to; }
            },
            'header_textcolor': {
                controls: [ 'header_textcolor' ],
                callback: function( to ) { return 'blank' !== to; }
            }
        }, function( settingId, o ) {
            api( settingId, function( setting ) {
                $.each( o.controls, function( i, controlId ) {
                    api.control( controlId, function( control ) {
                        var visibility = function( to ) {
                            control.container.toggle( o.callback( to ) );
                        };

                        visibility( setting.get() );
                        setting.bind( visibility );
                    });
                });
            });
        });

        // Juggle the two controls that use header_textcolor
        api.control( 'display_header_text', function( control ) {
            var last = '';

            control.elements[0].unsync( api( 'header_textcolor' ) );

            control.element = new api.Element( control.container.find('input') );
            control.element.set( 'blank' !== control.setting() );

            control.element.bind( function( to ) {
                if ( ! to )
                    last = api( 'header_textcolor' ).get();

                control.setting.set( to ? last : 'blank' );
            });

            control.setting.bind( function( to ) {
                control.element.set( 'blank' !== to );
            });
        });

        // Change previewed URL to the homepage when changing the page_on_front.
        api( 'show_on_front', 'page_on_front', function( showOnFront, pageOnFront ) {
            var updatePreviewUrl = function() {
                if ( showOnFront() === 'page' && parseInt( pageOnFront(), 10 ) > 0 ) {
                    api.previewer.previewUrl.set( api.settings.url.home );
                }
            };
            showOnFront.bind( updatePreviewUrl );
            pageOnFront.bind( updatePreviewUrl );
        });

        // Change the previewed URL to the selected page when changing the page_for_posts.
        api( 'page_for_posts', function( setting ) {
            setting.bind(function( pageId ) {
                pageId = parseInt( pageId, 10 );
                if ( pageId > 0 ) {
                    api.previewer.previewUrl.set( api.settings.url.home + '?page_id=' + pageId );
                }
            });
        });

        // Focus on the control that is associated with the given setting.
        api.previewer.bind( 'focus-control-for-setting', function( settingId ) {
            var matchedControl;
            api.control.each( function( control ) {
                var settingIds = _.pluck( control.settings, 'id' );
                if ( -1 !== _.indexOf( settingIds, settingId ) ) {
                    matchedControl = control;
                }
            } );

            if ( matchedControl ) {
                matchedControl.focus();
            }
        } );

        // Refresh the preview when it requests.
        api.previewer.bind( 'refresh', function() {
            api.previewer.refresh();
        });

        api.trigger( 'ready' );

        // Make sure left column gets focus
        topFocus = closeBtn;
        topFocus.focus();
        setTimeout(function () {
            topFocus.focus();
        }, 200);

    });

})( wp, jQuery );


PM MAIL   Вверх
  
Ответ в темуСоздание новой темы Создание опроса
Форум для вопросов, которые имеются в справочниках, но их поиск вызвал затруднения, или для разработчика требуется совет или просьба отыскать ошибку. Напоминаем: 1) чётко формулируйте вопрос, 2) приведите пример того, что уже сделано, 3) укажите явно, нужен работающий пример или подсказка о том, где найти информацию.
 
1 Пользователей читают эту тему (1 Гостей и 0 Скрытых Пользователей)
0 Пользователей:
« Предыдущая тема | JavaScript: Общие вопросы | Следующая тема »


 




[ Время генерации скрипта: 0.1280 ]   [ Использовано запросов: 21 ]   [ GZIP включён ]


Реклама на сайте     Информационное спонсорство

 
По вопросам размещения рекламы пишите на vladimir(sobaka)vingrad.ru
Отказ от ответственности     Powered by Invision Power Board(R) 1.3 © 2003  IPS, Inc.