PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 1.0.3
Adminify – White Label, Admin Menu Editor, Login Customizer v1.0.3
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 1.0.3, at inc/Modules/LoginCustomizer/assets/js/adminify-customizer.js

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