codemirror
9 years ago
javascript-md5
7 years ago
how-to.js
8 years ago
how-to.min.js
6 years ago
jquery.colorbox.js
8 years ago
jquery.colorbox.min.js
6 years ago
metabox.js
5 years ago
metabox.min.js
5 years ago
multisite-updater.js
6 years ago
multisite-updater.min.js
6 years ago
wp-pages.js
6 years ago
wp-pages.min.js
6 years ago
yit-cpt-unlimited.js
6 years ago
yit-cpt-unlimited.min.js
6 years ago
yit-plugin-panel.js
5 years ago
yit-plugin-panel.min.js
5 years ago
yit-wp-pointer.js
5 years ago
yit-wp-pointer.min.js
5 years ago
yith-colorpicker.min.js
5 years ago
yith-dashboard.js
7 years ago
yith-dashboard.min.js
6 years ago
yith-enhanced-select-wc-2.6.js
5 years ago
yith-enhanced-select-wc-2.6.min.js
5 years ago
yith-enhanced-select.js
5 years ago
yith-enhanced-select.min.js
5 years ago
yith-fields.js
5 years ago
yith-fields.min.js
5 years ago
yith-gutenberg.js
5 years ago
yith-gutenberg.min.js
5 years ago
yith-promo.js
7 years ago
yith-promo.min.js
6 years ago
yith-system-info.js
5 years ago
yith-system-info.min.js
5 years ago
yith-update-plugins.js
7 years ago
yith-update-plugins.min.js
6 years ago
yit-plugin-panel.js
227 lines
| 1 | /** |
| 2 | * This file belongs to the YIT Plugin Framework. |
| 3 | * |
| 4 | * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0) |
| 5 | * that is bundled with this package in the file LICENSE.txt. |
| 6 | * It is also available through the world-wide-web at this URL: |
| 7 | * http://www.gnu.org/licenses/gpl-3.0.txt |
| 8 | */ |
| 9 | |
| 10 | jQuery( function ( $ ) { |
| 11 | // Handle dependencies. |
| 12 | function dependencies_handler( id, deps, values, type ) { |
| 13 | var result = true; |
| 14 | //Single dependency |
| 15 | if ( typeof ( deps ) == 'string' ) { |
| 16 | // ?? |
| 17 | if ( deps.substr( 0, 6 ) == ':radio' ) { |
| 18 | deps = deps + ':checked'; |
| 19 | } |
| 20 | |
| 21 | var input_type = $( deps ).data( 'type' ), |
| 22 | val = $( deps ).val(); |
| 23 | |
| 24 | if ( 'checkbox' === input_type ) { |
| 25 | val = $( deps ).is( ':checked' ) ? 'yes' : 'no'; |
| 26 | } |
| 27 | else if ( 'radio' === input_type ) { |
| 28 | val = $( deps ).find('input[type="radio"]').filter(':checked').val(); |
| 29 | } |
| 30 | |
| 31 | if( $( deps + '-wrapper' ).data( 'type' ) === 'select-images' ){ |
| 32 | val = $( deps + '-wrapper' ).find( 'select' ).first().val(); |
| 33 | } |
| 34 | |
| 35 | values = values.split( ',' ); |
| 36 | |
| 37 | for ( var i = 0; i < values.length; i++ ) { |
| 38 | if ( val != values[ i ] ) { |
| 39 | result = false; |
| 40 | } else { |
| 41 | result = true; |
| 42 | break; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | var $current_field = $( id ), |
| 48 | $current_container = $( id + '-container' ).closest( 'tr' ); // container for YIT Plugin Panel |
| 49 | |
| 50 | if ( $current_container.length < 1 ) { |
| 51 | // container for YIT Plugin Panel WooCommerce |
| 52 | $current_container = $current_field.closest( '.yith-plugin-fw-panel-wc-row, .yith-toggle-content-row' ); |
| 53 | } |
| 54 | |
| 55 | var types = type.split( '-' ), j; |
| 56 | for ( j in types ) { |
| 57 | var current_type = types[ j ]; |
| 58 | |
| 59 | if ( !result ) { |
| 60 | switch ( current_type ) { |
| 61 | case 'disable': |
| 62 | $current_container.addClass( 'yith-disabled' ); |
| 63 | $current_field.attr( 'disabled', true ); |
| 64 | break; |
| 65 | case 'hideNow': |
| 66 | $current_container.hide(); |
| 67 | break; |
| 68 | case 'hideme': |
| 69 | $current_field.hide(); |
| 70 | break; |
| 71 | case 'fadeInOut': |
| 72 | case 'fadeOut': |
| 73 | $current_container.hide( 500 ); |
| 74 | break; |
| 75 | case 'fadeIn': |
| 76 | $current_container.hide(); |
| 77 | break; |
| 78 | default: |
| 79 | if ( ! $current_container.hasClass( 'fade-in' ) ) { |
| 80 | $current_container.hide(); |
| 81 | $current_container.css( { 'opacity': '0' } ); |
| 82 | } else { |
| 83 | $current_container.fadeTo( "slow", 0, function () { |
| 84 | $( this ).hide().removeClass( 'fade-in' ); |
| 85 | } ); |
| 86 | } |
| 87 | |
| 88 | } |
| 89 | |
| 90 | } else { |
| 91 | switch ( current_type ) { |
| 92 | case 'disable': |
| 93 | $current_container.removeClass( 'yith-disabled' ); |
| 94 | $current_field.attr( 'disabled', false ); |
| 95 | break; |
| 96 | case 'hideNow': |
| 97 | $current_container.hide(); |
| 98 | break; |
| 99 | case 'hideme': |
| 100 | $current_field.show(); |
| 101 | break; |
| 102 | case 'fadeInOut': |
| 103 | case 'fadeIn': |
| 104 | $current_container.show( 500 ); |
| 105 | break; |
| 106 | case 'fadeOut': |
| 107 | $current_container.show(); |
| 108 | break; |
| 109 | default: |
| 110 | $current_container.show(); |
| 111 | $current_container.fadeTo( "slow", 1 ).addClass( 'fade-in' ); |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | } |
| 116 | function init_dependencies() { |
| 117 | $( '[data-dep-target]:not( .deps-initialized )' ).each( function () { |
| 118 | var t = $( this ); |
| 119 | |
| 120 | // init field deps |
| 121 | t.addClass( 'deps-initialized' ); |
| 122 | |
| 123 | var field = '#' + t.data( 'dep-target' ), |
| 124 | dep = '#' + t.data( 'dep-id' ), |
| 125 | value = t.data( 'dep-value' ), |
| 126 | type = t.data( 'dep-type' ), |
| 127 | event = 'change', |
| 128 | wrapper = $( dep + '-wrapper' ), |
| 129 | field_type = wrapper.data( 'type' ); |
| 130 | |
| 131 | if( field_type === 'select-images' ){ |
| 132 | event = 'yith_select_images_value_changed'; |
| 133 | } |
| 134 | |
| 135 | $( dep ).on( event, function () { |
| 136 | dependencies_handler( field, dep, value.toString(), type ); |
| 137 | } ).trigger( event ); |
| 138 | } ); |
| 139 | } |
| 140 | |
| 141 | init_dependencies(); |
| 142 | // re-init deps after an add toggle action |
| 143 | $( document ).on( 'yith-add-box-button-toggle', init_dependencies ); |
| 144 | |
| 145 | //connected list |
| 146 | $( '.rm_connectedlist' ).each( function () { |
| 147 | var ul = $( this ).find( 'ul' ); |
| 148 | var input = $( this ).find( ':hidden' ); |
| 149 | var sortable = ul.sortable( { |
| 150 | connectWith: ul, |
| 151 | update : function ( event, ui ) { |
| 152 | var value = {}; |
| 153 | |
| 154 | ul.each( function () { |
| 155 | var options = {}; |
| 156 | |
| 157 | $( this ).children().each( function () { |
| 158 | options[ $( this ).data( 'option' ) ] = $( this ).text(); |
| 159 | } ); |
| 160 | |
| 161 | value[ $( this ).data( 'list' ) ] = options; |
| 162 | } ); |
| 163 | |
| 164 | input.val( ( JSON.stringify( value ) ).replace( /[\\"']/g, '\\$&' ).replace( /\u0000/g, '\\0' ) ); |
| 165 | } |
| 166 | } ).disableSelection(); |
| 167 | } ); |
| 168 | |
| 169 | //google analytics generation |
| 170 | $( function () { |
| 171 | $( '.google-analytic-generate' ).click( function () { |
| 172 | var editor = $( '#' + $( this ).data( 'textarea' ) ).data( 'codemirrorInstance' ); |
| 173 | var gatc = $( '#' + $( this ).data( 'input' ) ).val(); |
| 174 | var basename = $( this ).data( 'basename' ); |
| 175 | |
| 176 | var text = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n"; |
| 177 | text += "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\n"; |
| 178 | text += "m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n"; |
| 179 | text += "})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n"; |
| 180 | text += "ga('create', '" + gatc + "', '" + basename + "');\n"; |
| 181 | text += "ga('send', 'pageview');\n"; |
| 182 | editor.replaceRange( |
| 183 | text, |
| 184 | editor.getCursor( 'start' ), |
| 185 | editor.getCursor( 'end' ) |
| 186 | ); |
| 187 | } ); |
| 188 | } ); |
| 189 | |
| 190 | |
| 191 | // prevents the WC message for changes when leaving the panel page |
| 192 | $( '.yith-plugin-fw-panel .woo-nav-tab-wrapper' ).removeClass( 'woo-nav-tab-wrapper' ).addClass( 'yith-nav-tab-wrapper' ); |
| 193 | |
| 194 | var wrap = $( '.wrap.yith-plugin-ui' ).first(), |
| 195 | notices = $( 'div.updated, div.error, div.notice' ); |
| 196 | |
| 197 | // prevent moving notices into the wrapper |
| 198 | notices.addClass( 'inline' ); |
| 199 | if ( wrap.length ) { |
| 200 | wrap.prepend( notices ); |
| 201 | } |
| 202 | |
| 203 | |
| 204 | // TAB MENU AND SUB TABS |
| 205 | var active_subnav = $(document).find( '.yith-nav-sub-tab.nav-tab-active' ); |
| 206 | |
| 207 | if( active_subnav.length ){ |
| 208 | // WP page |
| 209 | var mainWrapper = $(document).find( '.yith-plugin-fw-wp-page-wrapper' ); |
| 210 | if( ! mainWrapper.length ){ |
| 211 | mainWrapper = $(document).find( '#wpbody-content > .yith-plugin-ui' ); |
| 212 | } |
| 213 | |
| 214 | if( mainWrapper ){ |
| 215 | // serach first for deafult wrap |
| 216 | var wrap = mainWrapper.find( '.yit-admin-panel-content-wrap' ); |
| 217 | if( wrap.length ) { |
| 218 | wrap.addClass( 'has-subnav' ); |
| 219 | } |
| 220 | else { |
| 221 | // try to wrap a generic wrap div in main wrapper |
| 222 | mainWrapper.find('.wrap').wrap('<div class="wrap subnav-wrap"></div>'); |
| 223 | } |
| 224 | } |
| 225 | } |
| 226 | } ); |
| 227 |