PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 3.0.5
Adminify – White Label, Admin Menu Editor, Login Customizer v3.0.5
4.3.2 4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 All 165 releases
adminify / Inc / Modules / LoginCustomizer / assets / js / adminify-customizer.js

adminify-customizer.js in Adminify – White Label, Admin Menu Editor, Login Customizer 3.0.5, at Inc/Modules/LoginCustomizer/assets/js/adminify-customizer.js

213 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * String.prototype.includes polyfill.
3 *
4 * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes
5 */
6 if ( ! String.prototype.includes) {
7 String.prototype.includes = function (search, start) {
8 'use strict';
9
10 if (search instanceof RegExp) {
11 throw TypeError( 'first argument must not be a RegExp' );
12 }
13 if (start === undefined) {
14 start = 0; }
15 return this.indexOf( search, start ) !== -1;
16 };
17 }
18
19 /**
20 * Scripts within customizer control panel.
21 *
22 * Used global objects:
23 * - jQuery
24 * - wp
25 * - WPAdminifyLoginCustomizer
26 */
27 (function ($) {
28 'use strict';
29
30 var events = {};
31
32 wp.customize.bind(
33 'ready',
34 function () {
35 wpAdminifyListen();
36 $( 'body' ).addClass( 'wp-adminify' );
37 if ( ! WPAdminifyLoginCustomizer.isProActive) {
38 adminifyUpgradeProLink();
39 }
40 }
41 );
42
43 function wpAdminifyListen() {
44 events.switchLoginPreview();
45 events.switchFormPreview();
46 events.focusSection();
47 events.focusSection();
48 if ( ! WPAdminifyLoginCustomizer.isProActive) {
49 events.templateFieldsChange();
50 }
51 }
52
53 events.focusSection = function(){
54 wp.customize.previewer.bind(
55 'wp-adminify-focus-section',
56 function ( sectionName ) {
57 var section = wp.customize.section( sectionName );
58
59 if ( undefined !== section ) {
60 section.focus();
61 }
62 }
63 );
64 }
65
66 events.switchFormPreview = function(){
67
68 wp.customize.section(
69 'wp_adminify_register-form',
70 function ( section ) {
71 section.expanded.bind(
72 function ( isExpanding ) {
73 // Value of isExpanding will = true if you're entering the section, false if you're leaving it.
74 if ( isExpanding ) {
75 wp.customize.previewer.send( 'change-form', 'register' );
76 } else {
77 wp.customize.previewer.send( 'change-form', 'login' );
78 }
79 }
80 );
81 }
82 );
83
84 wp.customize.section(
85 'wp_adminify_lostpassword-form',
86 function ( section ) {
87 section.expanded.bind(
88 function ( isExpanding ) {
89 // Value of isExpanding will = true if you're entering the section, false if you're leaving it.
90 if ( isExpanding ) {
91 wp.customize.previewer.send( 'change-form', 'lostpassword' );
92 } else {
93 wp.customize.previewer.send( 'change-form', 'login' );
94 }
95 }
96 );
97 }
98 );
99
100 }
101 /**
102 * Change the page when the "WP Adminify Login Customizer" panel is expanded (or collapsed).
103 */
104 events.switchLoginPreview = function () {
105 wp.customize.panel(
106 'jltwp_adminify_panel',
107 function ( section ) {
108 section.expanded.bind(
109 function ( isExpanding ) {
110 var loginURL = WPAdminifyLoginCustomizer.siteurl + '?wp-adminify-login-customizer=true';
111 // Value of isExpanding will = true if you're entering the section, false if you're leaving it.
112 if ( isExpanding ) {
113 wp.customize.previewer.previewUrl.set( loginURL );
114 } else {
115 wp.customize.previewer.previewUrl.set( WPAdminifyLoginCustomizer.siteurl );
116 }
117 }
118 );
119 }
120 );
121 }
122
123 events.templateFieldsChange = function () {
124 wp.customize.section(
125 'jltwp_adminify_customizer_template_section',
126 function (section) {
127 section.expanded.bind(
128 function (isExpanded) {
129 if (isExpanded) {
130 var figur_input = $( '#customize-control-jltwp_adminify_login-templates .adminify--image-group .adminify--image figure input' );
131
132 for (let index = 0; index < figur_input.length; index++) {
133 var element = figur_input[index];
134 var val = element.value;
135 // console.log('element', element.value);
136 var hasDivAlready = element.parentNode.querySelector( '.wp-adminify-templates-pro' );
137
138 if (val === 'template-01' || val === 'template-02' || val === 'template-03' || val === 'template-04') {
139 continue;
140 }
141
142 if (hasDivAlready !== null) {
143 continue;
144 }
145
146 var _div = document.createElement( 'div' );
147 var _a = document.createElement( 'a' );
148 _div.classList = 'wp-adminify-templates-pro';
149 _a.setAttribute( 'href', 'https://wpadminify.com/login-customizer/?utm_source=plugin&utm_medium=login_customizer_link&utm_campaign=wp_adminify' )
150 _a.setAttribute( 'target', '_blank' );
151 _a.innerHTML = 'Upgrade to Pro';
152
153 _div.appendChild( _a );
154 element.parentNode.appendChild( _div );
155
156 }
157 // figur_input.forEach(element => {
158 // console.log('figur_input_val', element.val());
159 // });
160
161 // var value = wp.customize('jltwp_adminify_login[templates]').get();
162 // console.log('value', value);
163 // if (value !== 'template-01' ) {
164 // $('<div class="wp-adminify-templates-pro"><a href="https://wpadminify.com/login-customizer/?utm_source=plugin&utm_medium=login_customizer_link&utm_campaign=wp_adminify" target="_blank">Upgrade to Pro</a></div>').appendTo('#customize-control-jltwp_adminify_login-templates .adminify--image-group .adminify--image figure');
165 // }
166 // $("#customize-control-jltwp_adminify_login-templates .adminify--image-group .adminify--image").insertAt(0, "<li>as fasd fads fsd</li>");
167 // $('<li>fgdf</li>').appendToWithIndex($("#customize-control-jltwp_adminify_login-templates .adminify--image-group .adminify--image > figure"),0)
168 }
169 }
170 )
171 }
172 );
173 }
174
175 $.fn.appendToWithIndex = function(to,index){
176 // console.log('firesd');
177 // var lastIndex = this.children().size();
178 // if (index < 0) {
179 // index = Math.max(0, lastIndex + 1 + index);
180 // }
181 // this.append(element);
182 // if (index < lastIndex) {
183 // this.children().eq(index).before(this.children().last());
184 // }
185 // return this;
186 if ( ! to instanceof jQuery) {
187 to = $( to );
188 };
189 if (index === 0) {
190 $( this ).prependTo( to )
191 } else {
192 $( this ).insertAfter( to.children().eq( index - 1 ) );
193 }
194 }
195
196 function adminifyUpgradeProLink() {
197
198 var proLink = '\
199 <li class="accordion-section control-section wp-adminify-pro-control-section">\
200 <a \
201 href="https://wpadminify.com/login-customizer/?utm_source=plugin&utm_medium=login_customizer_link&utm_campaign=wp_adminify" \
202 style="display: block; font-weight: 600; color: #fff !important; font-size: 16px; text-decoration: none; border-left-color: #0347FF; background: #0347FF;"\
203 class="accordion-section-title" target="_blank" tabindex="0">\
204 Upgrade to Pro ›\
205 </a>\
206 </li>\
207 ';
208
209 $( proLink ).insertBefore( '#accordion-section-jltwp_adminify_customizer_template_section' );
210 }
211
212 })( jQuery, wp.customize );
213