detectmobilebrowser.js
5 years ago
iris-script.js
4 years ago
mystickymenu-admin.js
4 years ago
mystickymenu.js
5 years ago
mystickymenu.min.js
5 years ago
select2.min.js
5 years ago
mystickymenu-admin.js
725 lines
| 1 | (function( $ ) { |
| 2 | "use strict"; |
| 3 | |
| 4 | jQuery(document).ready(function($){ |
| 5 | |
| 6 | $(document).on("click", ".updates-form button", function(){ |
| 7 | var updateStatus = 0; |
| 8 | if($(this).hasClass("yes")) { |
| 9 | updateStatus = 1; |
| 10 | } |
| 11 | $(".updates-form button").attr("disabled", true); |
| 12 | $.ajax({ |
| 13 | url: ajaxurl, |
| 14 | data: "action=sticky_menu_update_status&status="+updateStatus+"&nonce="+$("#myStickymenu_update_nonce").val()+"&email="+$("#myStickymenu_update_email").val(), |
| 15 | type: 'post', |
| 16 | cache: false, |
| 17 | success: function(){ |
| 18 | window.location.reload(); |
| 19 | } |
| 20 | }) |
| 21 | }); |
| 22 | |
| 23 | $(document).on("click", ".skip-dolatter", function(){ |
| 24 | var updateStatus = 0; |
| 25 | $(".updates-form button").attr("disabled", true); |
| 26 | $.ajax({ |
| 27 | url: ajaxurl, |
| 28 | data: "action=sticky_menu_update_status&status="+updateStatus+"&nonce="+$("#myStickymenu_update_nonce").val()+"&email="+$("#myStickymenu_update_email").val(), |
| 29 | type: 'post', |
| 30 | cache: false, |
| 31 | success: function(){ |
| 32 | window.location.reload(); |
| 33 | } |
| 34 | }) |
| 35 | }); |
| 36 | |
| 37 | var handle = $( "#custom-handle" ); |
| 38 | $( "#slider" ).slider({ |
| 39 | create: function() { |
| 40 | handle.text( $( this ).slider( "value" ) ); |
| 41 | handle.text( $('#myfixed_opacity').val() ); |
| 42 | handle.css('left', $('#myfixed_opacity').val() + '%') |
| 43 | }, |
| 44 | slide: function( event, ui ) { |
| 45 | $('#myfixed_opacity').val(ui.value); |
| 46 | handle.text( ui.value ); |
| 47 | } |
| 48 | }); |
| 49 | jQuery( |
| 50 | '<div class="pt_number"><div class="pt_numberbutton pt_numberup">+</div><div class="pt_numberbutton pt_numberdown">-</div></div>' |
| 51 | ).insertAfter("input.mysticky-number1"); |
| 52 | |
| 53 | jQuery(".mystickynumber1").each(function() { |
| 54 | |
| 55 | var spinner = jQuery(this), |
| 56 | input = spinner.find('input[type="number"]'), |
| 57 | btnUp = spinner.find(".pt_numberup"), |
| 58 | btnDown = spinner.find(".pt_numberdown"), |
| 59 | min = input.attr("min"), |
| 60 | max = input.attr("max"), |
| 61 | valOfAmout = input.val(), |
| 62 | newVal = 0; |
| 63 | |
| 64 | btnUp.on("click", function() { |
| 65 | |
| 66 | var oldValue = parseFloat(input.val()); |
| 67 | |
| 68 | if (oldValue >= max) { |
| 69 | var newVal = oldValue; |
| 70 | } else { |
| 71 | var newVal = oldValue + 1; |
| 72 | } |
| 73 | spinner.find("input").val(newVal); |
| 74 | spinner.find("input").trigger("change"); |
| 75 | console.log(newVal); |
| 76 | }); |
| 77 | btnDown.on("click", function() { |
| 78 | var oldValue = parseFloat(input.val()); |
| 79 | if (oldValue <= min) { |
| 80 | var newVal = oldValue; |
| 81 | } else { |
| 82 | var newVal = oldValue - 1; |
| 83 | } |
| 84 | spinner.find("input").val(newVal); |
| 85 | spinner.find("input").trigger("change"); |
| 86 | }); |
| 87 | }); |
| 88 | |
| 89 | |
| 90 | $(".confirm").on( 'click', function() { |
| 91 | return window.confirm("Reset to default settings?"); |
| 92 | }); |
| 93 | |
| 94 | var flag = 0; |
| 95 | $( "#mystickymenu-select option" ).each(function( i ) { |
| 96 | |
| 97 | if ($('select#mystickymenu-select option:selected').val() !== '' ) { |
| 98 | flag = 1; |
| 99 | } |
| 100 | if( $('select#mystickymenu-select option:selected').val() == $(this).val() ){ |
| 101 | $('#mysticky_class_selector').show(); |
| 102 | }else { |
| 103 | $('#mysticky_class_selector').hide(); |
| 104 | } |
| 105 | }); |
| 106 | if ( flag === 0 ) { |
| 107 | $('#mysticky_class_selector').show(); |
| 108 | $("select#mystickymenu-select option[value=custom]").attr('selected', 'selected'); |
| 109 | } |
| 110 | |
| 111 | $("#mystickymenu-select").on( 'change', function() { |
| 112 | if ($(this).val() == 'custom' ) { |
| 113 | $('#mysticky_class_selector').show(); |
| 114 | }else { |
| 115 | $('#mysticky_class_selector').hide(); |
| 116 | } |
| 117 | |
| 118 | }); |
| 119 | /*02-08-2019 welcom bar js*/ |
| 120 | $( '.mysticky-welcomebar-action' ).on( 'change', function(){ |
| 121 | var mysticky_welcomebar_action = $( this ).val(); |
| 122 | if ( mysticky_welcomebar_action == 'redirect_to_url' ) { |
| 123 | $( '.mysticky-welcomebar-redirect' ).show(); |
| 124 | $( '.mysticky-welcomebar-redirect-container' ).show(); |
| 125 | } else { |
| 126 | $( '.mysticky-welcomebar-redirect' ).hide(); |
| 127 | $( '.mysticky-welcomebar-redirect-container' ).hide(); |
| 128 | } |
| 129 | if ( mysticky_welcomebar_action == 'poptin_popup' ) { |
| 130 | $( '.mysticky-welcomebar-poptin-popup' ).show(); |
| 131 | } else { |
| 132 | $( '.mysticky-welcomebar-poptin-popup' ).hide(); |
| 133 | } |
| 134 | if ( $('.mysticky-welcomebar-action option:selected').attr('data-href') !== '' && mysticky_welcomebar_action == 'thankyou_screen' ) { |
| 135 | window.open( $( '.mysticky-welcomebar-action option:selected' ).attr('data-href') , '_blank'); |
| 136 | } |
| 137 | } ); |
| 138 | //$( '#mysticky_welcomebar_expirydate' ).datepicker( ); |
| 139 | //$( "#mysticky_welcomebar_expirydate" ).datepicker( "option", "dateFormat", 'mm/dd/yy' ); |
| 140 | |
| 141 | var page_option_content = ""; |
| 142 | page_option_content = $( '.mysticky-welcomebar-page-options-html' ).html(); |
| 143 | $( '.mysticky-welcomebar-page-options-html' ).remove(); |
| 144 | |
| 145 | $( '#create-rule' ).on( 'click', function(){ |
| 146 | var append_html = page_option_content.replace(/__count__/g, '1', page_option_content); |
| 147 | $( '.mysticky-welcomebar-page-options' ).append( append_html ); |
| 148 | $( '.mysticky-welcomebar-page-options' ).show(); |
| 149 | $( this ).parent().remove(); |
| 150 | }); |
| 151 | $( '.sticky-header-menu ul li a' ).on( 'click', function(){ |
| 152 | if ( $( "#sticky-header-welcome-bar" ).is( ":visible" ) ) { |
| 153 | check_for_preview_pos(); |
| 154 | } |
| 155 | } ); |
| 156 | jQuery(window).on('scroll', function(){ |
| 157 | if ( $( "#sticky-header-welcome-bar" ).is( ":visible" ) ) { |
| 158 | check_for_preview_pos(); |
| 159 | } |
| 160 | }); |
| 161 | /*Mysticky page target*/ |
| 162 | var mysticky_total_page_option = 0; |
| 163 | var mysticky_page_option_content = ""; |
| 164 | mysticky_total_page_option = $( '.mysticky-page-option' ).length; |
| 165 | mysticky_page_option_content = $( '.mysticky-page-options-html' ).html(); |
| 166 | $( '.mysticky-page-options-html' ).remove(); |
| 167 | |
| 168 | $( '#mysticky_create-rule' ).on( 'click', function(){ |
| 169 | |
| 170 | var append_html = mysticky_page_option_content.replace(/__count__/g, mysticky_total_page_option, mysticky_page_option_content); |
| 171 | mysticky_total_page_option++; |
| 172 | $( '.mysticky-page-options' ).append( append_html ); |
| 173 | $( '.mysticky-page-options .mysticky-page-option' ).removeClass( 'last' ); |
| 174 | $( '.mysticky-page-options .mysticky-page-option:last' ).addClass( 'last' ); |
| 175 | |
| 176 | if( $( '.mysticky-page-option .myStickymenu-upgrade' ).length > 0 ) { |
| 177 | $( this ).remove(); |
| 178 | } |
| 179 | }); |
| 180 | $( document ).on( 'click', '.mysticky-remove-rule', function() { |
| 181 | $( this ).closest( '.mysticky-page-option' ).remove(); |
| 182 | $( '.mysticky-page-options .mysticky-page-option' ).removeClass( 'last' ); |
| 183 | $( '.mysticky-page-options .mysticky-page-option:last' ).addClass( 'last' ); |
| 184 | }); |
| 185 | $( document ).on( 'change', '.mysticky-url-options', function() { |
| 186 | var current_val = jQuery( this ).val(); |
| 187 | var mysticky_welcomebar_siteURL = jQuery( '#mysticky_welcomebar_site_url' ).val(); |
| 188 | var mysticky_welcomebar_newURL = mysticky_welcomebar_siteURL; |
| 189 | if( current_val == 'page_has_url' ) { |
| 190 | mysticky_welcomebar_newURL = mysticky_welcomebar_siteURL; |
| 191 | } else if( current_val == 'page_contains' ) { |
| 192 | mysticky_welcomebar_newURL = mysticky_welcomebar_siteURL + '%s%'; |
| 193 | } else if( current_val == 'page_start_with' ) { |
| 194 | mysticky_welcomebar_newURL = mysticky_welcomebar_siteURL + 's%'; |
| 195 | } else if( current_val == 'page_end_with' ) { |
| 196 | mysticky_welcomebar_newURL = mysticky_welcomebar_siteURL + '%s'; |
| 197 | } |
| 198 | $( this ).closest( '.url-content' ).find( '.mysticky-welcomebar-url' ).text( mysticky_welcomebar_newURL ); |
| 199 | }); |
| 200 | /* welcome bar live preview */ |
| 201 | /* Apply Wp Color Picker */ |
| 202 | var myOptions = { |
| 203 | change: function(event, ui){ |
| 204 | var color_id = $(this).attr('id'); |
| 205 | var slug = $(this).data('slug'); |
| 206 | |
| 207 | var color_code = ui.color.toString(); |
| 208 | if ( color_id === 'mysticky_welcomebar_bgcolor'){ |
| 209 | $('.mysticky-welcomebar-fixed').css('background-color', color_code ); |
| 210 | } |
| 211 | if ( color_id === 'mysticky_welcomebar_bgtxtcolor'){ |
| 212 | $('.mysticky-welcomebar-fixed .mysticky-welcomebar-content p').css('color', color_code ); |
| 213 | } |
| 214 | if ( color_id === 'mysticky_welcomebar_btncolor'){ |
| 215 | $('.mysticky-welcomebar-btn a').css('background-color', color_code ); |
| 216 | } |
| 217 | if ( color_id === 'mysticky_welcomebar_btntxtcolor'){ |
| 218 | $('.mysticky-welcomebar-btn a').css('color', color_code ); |
| 219 | } |
| 220 | } |
| 221 | }; |
| 222 | $('.mysticky-welcomebar-setting-wrap .my-color-field').wpColorPicker(myOptions); |
| 223 | |
| 224 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_x_desktop]"]' ).on( 'change', function(){ |
| 225 | if( $( this ).prop( "checked" ) == true ) { |
| 226 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-showx-desktop' ); |
| 227 | } else { |
| 228 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-showx-desktop' ); |
| 229 | } |
| 230 | } ); |
| 231 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_x_mobile]"]' ).on( 'change', function(){ |
| 232 | if( $( this ).prop( "checked" ) == true ) { |
| 233 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-showx-mobile' ); |
| 234 | } else { |
| 235 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-showx-mobile' ); |
| 236 | } |
| 237 | } ); |
| 238 | |
| 239 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_desktop]"]' ).on( 'change', function(){ |
| 240 | if( $( this ).prop( "checked" ) == true ) { |
| 241 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-btn-desktop' ); |
| 242 | } else { |
| 243 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-btn-desktop' ); |
| 244 | } |
| 245 | |
| 246 | if( $( this ).prop( "checked" ) == false && $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_mobile]"]' ).prop( "checked" ) == false ) { |
| 247 | $( ".mysticky_welcomebar_disable, .mysticky_welcomebar_btn_color button.wp-color-result" ).css({ |
| 248 | 'pointer-events': 'none', |
| 249 | 'opacity': '0.5' |
| 250 | }); |
| 251 | } else { |
| 252 | $( ".mysticky_welcomebar_disable, .mysticky_welcomebar_btn_color button.wp-color-result" ).css({ |
| 253 | 'pointer-events': '', |
| 254 | 'opacity': '' |
| 255 | }); |
| 256 | } |
| 257 | } ); |
| 258 | |
| 259 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_mobile]"]' ).on( 'change', function(){ |
| 260 | if( $( this ).prop( "checked" ) == true ) { |
| 261 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-btn-mobile' ); |
| 262 | } else { |
| 263 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-btn-mobile' ); |
| 264 | } |
| 265 | |
| 266 | if( $( this ).prop( "checked" ) == false && $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_desktop]"]' ).prop( "checked" ) == false ) { |
| 267 | $( ".mysticky_welcomebar_disable, .mysticky_welcomebar_btn_color button.wp-color-result" ).css({ |
| 268 | 'pointer-events': 'none', |
| 269 | 'opacity': '0.5' |
| 270 | }); |
| 271 | } else { |
| 272 | $( ".mysticky_welcomebar_disable, .mysticky_welcomebar_btn_color button.wp-color-result" ).css({ |
| 273 | 'pointer-events': '', |
| 274 | 'opacity': '' |
| 275 | }); |
| 276 | } |
| 277 | } ); |
| 278 | if( $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_desktop]"]' ).prop( "checked" ) == false && $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_mobile]"]' ).prop( "checked" ) == false ) { |
| 279 | $( ".mysticky_welcomebar_disable, .mysticky_welcomebar_btn_color button.wp-color-result" ).css({ |
| 280 | 'pointer-events': 'none', |
| 281 | 'opacity': '0.5' |
| 282 | }); |
| 283 | } else { |
| 284 | $( ".mysticky_welcomebar_disable, .mysticky_welcomebar_btn_color button.wp-color-result" ).css({ |
| 285 | 'pointer-events': '', |
| 286 | 'opacity': '' |
| 287 | }); |
| 288 | } |
| 289 | |
| 290 | $( 'select[name="mysticky_option_welcomebar[mysticky_welcomebar_font]"]' ).on( 'change', function(){ |
| 291 | var myfixed_font_val = $( this ).val(); |
| 292 | if( myfixed_font_val == 'System Stack'){ |
| 293 | myfixed_font_val = '-apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'; |
| 294 | } |
| 295 | $( 'head' ).append( '<link href="https://fonts.googleapis.com/css?family='+ myfixed_font_val +':400,600,700" rel="stylesheet" type="text/css" class="sfba-google-font">' ); |
| 296 | $( '.mysticky-welcomebar-fixed' ).css( 'font-family', myfixed_font_val ); |
| 297 | } ); |
| 298 | |
| 299 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_fontsize]"]' ).on( 'keyup click', function(){ |
| 300 | var mysticky_welcomebar_fontsize_val = $( this ).val(); |
| 301 | $( '.mysticky-welcomebar-fixed p' ).css( 'font-size', mysticky_welcomebar_fontsize_val + 'px' ); |
| 302 | $( '.mysticky-welcomebar-btn a' ).css( 'font-size', mysticky_welcomebar_fontsize_val + 'px' ); |
| 303 | } ); |
| 304 | |
| 305 | $( '#wp-mysticky_bar_text-wrap .wp-editor-tabs button' ).on( 'click', function(){ |
| 306 | if ( $("#wp-mysticky_bar_text-wrap").hasClass("tmce-active") ){ |
| 307 | |
| 308 | } |
| 309 | } ); |
| 310 | |
| 311 | $( document ).on( 'click', '#qt_mysticky_bar_text_toolbar .ed_button', function(){ |
| 312 | $( 'textarea[name="mysticky_option_welcomebar[mysticky_welcomebar_bar_text]"]' ).trigger( 'change keyup click' ); |
| 313 | } ); |
| 314 | |
| 315 | $( 'textarea[name="mysticky_option_welcomebar[mysticky_welcomebar_bar_text]"]' ).on( 'change keyup click', function(e){ |
| 316 | var mysticky_bar_text_val = $( this ).val().replace(/(?:\r\n|\r|\n)/g, '<br />'); |
| 317 | $( '.mysticky-welcomebar-content' ).html( "<p>" + mysticky_bar_text_val + "</p>"); |
| 318 | } ); |
| 319 | |
| 320 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_text]"]' ).on( 'keyup', function(){ |
| 321 | var mysticky_btn_text_val = $( this ).val(); |
| 322 | |
| 323 | $( '.mysticky-welcomebar-btn a' ).text( mysticky_btn_text_val ); |
| 324 | } ); |
| 325 | |
| 326 | /* DATE: 11-12-2019 start */ |
| 327 | $( 'select[name="mysticky_option_welcomebar[mysticky_welcomebar_attentionselect]"]' ).on( 'change', function(){ |
| 328 | $(".mysticky-welcomebar-fixed").removeClass (function (index, className) { |
| 329 | return (className.match (/(^|\s)mysticky-welcomebar-attention-\S+/g) || []).join(' '); |
| 330 | }); |
| 331 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-attention-' + $(this).val() ); |
| 332 | |
| 333 | } ); |
| 334 | /* DATE: 11-12-2019 End */ |
| 335 | $("#myStickymenu-entry-effect").on( 'change', function() { |
| 336 | $(".mysticky-welcomebar-preview-screen .mysticky-welcomebar-fixed").removeClass('entry-effect'); |
| 337 | $(".mysticky-welcomebar-fixed").removeClass (function (index, className) { |
| 338 | return (className.match (/(^|\s)mysticky-welcomebar-entry-effect-\S+/g) || []).join(' '); |
| 339 | }); |
| 340 | $( '.mysticky-welcomebar-preview-screen .mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-entry-effect-' + $(this).val() ); |
| 341 | setTimeout( function(){ |
| 342 | $(".mysticky-welcomebar-preview-screen .mysticky-welcomebar-fixed").addClass('entry-effect'); |
| 343 | }, 1000 ); |
| 344 | |
| 345 | }); |
| 346 | $( '.mysticky-welcomebar-fixed' ).addClass( 'entry-effect' ); |
| 347 | |
| 348 | /*$( '.mysticky-welcomebar-submit input#submit' ).on( 'click', function(e){ |
| 349 | var welcomebar_action = $('.mysticky-welcomebar-action').find(":selected").val(); |
| 350 | var poptin_popup_link = $('#mysticky_welcomebar_poptin_popup_link').val().toLowerCase(); |
| 351 | var welcome_save_anyway = $('#welcome_save_anyway').val(); |
| 352 | console.log(poptin_popup_link); |
| 353 | if ( welcomebar_action == 'poptin_popup' && welcome_save_anyway == '' && (poptin_popup_link == '' || poptin_popup_link.indexOf('popt.in') == '-1' ) ) { |
| 354 | e.preventDefault(); |
| 355 | $( "#mysticky-welcomebar-poptin-popup-confirm" ).dialog({ |
| 356 | resizable: false, |
| 357 | modal: true, |
| 358 | draggable: false, |
| 359 | height: 'auto', |
| 360 | width: 500, |
| 361 | buttons: { |
| 362 | "Keep editing": { |
| 363 | click:function () { |
| 364 | $( this ).dialog('close'); |
| 365 | $("body,html").animate({ |
| 366 | scrollTop: $("#mysticky_welcomebar_poptin_popup_link").offset().top - 200 |
| 367 | }, 500) |
| 368 | $('#mysticky_welcomebar_poptin_popup_link').focus(); |
| 369 | $('#mysticky_welcomebar_poptin_popup_link').css( 'border', '1px solid #FF0000' ); |
| 370 | }, |
| 371 | text: 'Keep editing', |
| 372 | class: 'green-btn' |
| 373 | }, |
| 374 | "Save anyway": function () { |
| 375 | $( 'input#welcome_save_anyway' ).val('1'); |
| 376 | $( '.mysticky-welcomebar-submit input#submit' ).trigger('click'); |
| 377 | $( this ).dialog( 'close' ); |
| 378 | } |
| 379 | } |
| 380 | }); |
| 381 | return false; |
| 382 | } |
| 383 | |
| 384 | if ( $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked' ) == false && $( 'input#save_welcome_bar' ).val() == '' ) { |
| 385 | e.preventDefault(); |
| 386 | $( "#mysticky-welcomebar-save-confirm" ).dialog({ |
| 387 | resizable: false, |
| 388 | modal: true, |
| 389 | draggable: false, |
| 390 | height: 'auto', |
| 391 | width: 600, |
| 392 | buttons: { |
| 393 | "Yes, show it on my site": { |
| 394 | click:function () { |
| 395 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked', true ); |
| 396 | $( '.mysticky-welcomebar-submit input#submit' ).trigger('click'); |
| 397 | $( this ).dialog('close'); |
| 398 | }, |
| 399 | text: 'Yes, show it on my site', |
| 400 | class: 'green-btn' |
| 401 | }, |
| 402 | "Just save and keep it off": function () { |
| 403 | $( 'input#save_welcome_bar' ).val('1'); |
| 404 | $( '.mysticky-welcomebar-submit input#submit' ).trigger('click'); |
| 405 | $( this ).dialog( 'close' ); |
| 406 | } |
| 407 | } |
| 408 | }); |
| 409 | } |
| 410 | //return false; |
| 411 | } );*/ |
| 412 | |
| 413 | }); |
| 414 | $( window ).on('load', function(){ |
| 415 | $( '.mysticky-welcomebar-url-options' ).each( function(){ |
| 416 | $( this ).trigger( 'change' ); |
| 417 | }); |
| 418 | }); |
| 419 | function check_for_preview_pos() { |
| 420 | var mysticky_welcomebar_form_pos = $( '#sticky-header-welcome-bar' ).offset().top; |
| 421 | if($(".show-on-apper").length && $(".mysticky-welcomebar-setting-right").length) { |
| 422 | var topPos = $(".show-on-apper").offset().top - $(window).scrollTop() - 700; |
| 423 | if (topPos < 0) { |
| 424 | topPos = Math.abs(topPos); |
| 425 | jQuery(".mysticky-welcomebar-setting-right").css("margin-top", ((-1)*topPos)+"px"); |
| 426 | } else { |
| 427 | jQuery(".mysticky-welcomebar-setting-right").css("margin-top", "0"); |
| 428 | } |
| 429 | } |
| 430 | var position_screen = (isRtl == 1 ) ? 'left' : 'right'; |
| 431 | if ( ( mysticky_welcomebar_form_pos + 32 ) < $(window).scrollTop() ) { |
| 432 | $( '.mysticky-welcomebar-setting-right' ).css( 'position', 'fixed' ); |
| 433 | $( '.mysticky-welcomebar-setting-right' ).css( position_screen, '70px' ); |
| 434 | } else { |
| 435 | $( '.mysticky-welcomebar-setting-right' ).css( 'position', 'absolute' ); |
| 436 | $( '.mysticky-welcomebar-setting-right' ).css( position_screen, '50px' ); |
| 437 | } |
| 438 | } |
| 439 | |
| 440 | jQuery(document).on("click",".mystickymenu-delete-widget",function(e){ |
| 441 | e.preventDefault(); |
| 442 | |
| 443 | var widget_id = jQuery(this).data("widget-id"); |
| 444 | jQuery("#widget-delete-dialog-"+widget_id).show(); |
| 445 | jQuery("#mystickymenu-delete-popup-overlay-"+widget_id).show(); |
| 446 | }); |
| 447 | |
| 448 | jQuery(document).on("click",".btn-delete",function(e){ |
| 449 | e.preventDefault(); |
| 450 | var delWidId = jQuery(this).data("id"); |
| 451 | jQuery.ajax({ |
| 452 | url: ajaxurl, |
| 453 | type:'post', |
| 454 | data: 'action=stickymenu_widget_delete&widget_id=' + delWidId + '&widget_delete=1&wpnonce=' + mystickymenu.ajax_nonce, |
| 455 | success: function( data ){ |
| 456 | $( '#stickymenu-widget-' + delWidId ).remove(); |
| 457 | setTimeout('location.reload()', 500); |
| 458 | }, |
| 459 | }); |
| 460 | }); |
| 461 | |
| 462 | |
| 463 | jQuery(document).on("click",".btn-delete-cancel",function(e){ |
| 464 | e.preventDefault(); |
| 465 | var id = jQuery(this).data("id"); |
| 466 | jQuery("#widget-delete-dialog-"+id).hide(); |
| 467 | jQuery("#mystickymenu-delete-popup-overlay-"+id).hide(); |
| 468 | }); |
| 469 | |
| 470 | |
| 471 | |
| 472 | jQuery(document).on("click",".mystickymenu-widget-enabled",function(){ |
| 473 | var widget_id = $(this).data('id'); |
| 474 | if(jQuery(this).prop("checked") != true){ |
| 475 | jQuery('#widget-status-dialog-' + widget_id).show(); |
| 476 | jQuery('#mystickymenu-status-popup-overlay-' + widget_id).show(); |
| 477 | }else{ |
| 478 | var widget_status = 1; |
| 479 | set_widget_status( widget_id, widget_status ); |
| 480 | } |
| 481 | }); |
| 482 | |
| 483 | jQuery(document).on("click",".btn-turnoff-status",function(e){ |
| 484 | e.preventDefault(); |
| 485 | var widget_id = $(this).data('id'); |
| 486 | var widget_status = 0; |
| 487 | set_widget_status( widget_id, widget_status ); |
| 488 | }); |
| 489 | |
| 490 | |
| 491 | jQuery(document).on("click",".btn-nevermind-status",function(e){ |
| 492 | e.preventDefault(); |
| 493 | var widget_id = $(this).data('id'); |
| 494 | var widget_status = 1; |
| 495 | set_widget_status( widget_id, widget_status ); |
| 496 | jQuery("#mystickymenu-widget-enabled-"+widget_id).prop('checked', true) |
| 497 | |
| 498 | }); |
| 499 | |
| 500 | |
| 501 | jQuery(document).on("click",".mystickymenupopup-overlay",function(e){ |
| 502 | e.preventDefault(); |
| 503 | |
| 504 | if(jQuery(this).data("fromoverlay") == 'welcombar_delete'){ |
| 505 | jQuery(this).hide(); |
| 506 | console.log("#mystickymenu-delete-popup-overlay-"+jQuery(this).data('id')); |
| 507 | var delId = jQuery(this).data('id'); |
| 508 | jQuery('#widget-delete-dialog-'+delId).hide(); |
| 509 | |
| 510 | }else{ |
| 511 | var widget_id = $(this).data('id'); |
| 512 | var widget_status = 1; |
| 513 | set_widget_status( widget_id, widget_status ); |
| 514 | jQuery("#mystickymenu-widget-enabled-"+widget_id).prop('checked', true); |
| 515 | } |
| 516 | |
| 517 | }); |
| 518 | |
| 519 | |
| 520 | |
| 521 | |
| 522 | function set_widget_status( widget_id, widget_status ) { |
| 523 | jQuery.ajax({ |
| 524 | url: ajaxurl, |
| 525 | type:'post', |
| 526 | data: 'action=mystickymenu_widget_status&widget_id='+widget_id+'&widget_status=' + widget_status +'&wpnonce=' + mystickymenu.ajax_nonce, |
| 527 | success: function( data ){ |
| 528 | $('#widget-status-dialog-' + widget_id).hide(); |
| 529 | $('#mystickymenu-status-popup-overlay-' + widget_id).hide(); |
| 530 | }, |
| 531 | }); |
| 532 | } |
| 533 | |
| 534 | jQuery(document).on("click","#close-first-popup",function(){ |
| 535 | jQuery('.first-widget-popup').hide(); |
| 536 | jQuery('.mystickymenupopup-overlay').hide(); |
| 537 | }); |
| 538 | |
| 539 | jQuery(document).on("click","#first_widget_overlay",function(){ |
| 540 | jQuery('.first-widget-popup').hide(); |
| 541 | jQuery(this).hide(); |
| 542 | }); |
| 543 | |
| 544 | |
| 545 | |
| 546 | jQuery(document).on("click","#btn-config-disable",function(e){ |
| 547 | e.preventDefault(); |
| 548 | jQuery("#stickymenu_status_popupbox").show(); |
| 549 | jQuery("#stickymenuconfig-overlay-popup").show(); |
| 550 | }); |
| 551 | |
| 552 | jQuery(document).on("click","#stickymenuconfig-overlay-popup",function(){ |
| 553 | jQuery("#stickymenu_status_popupbox").hide(); |
| 554 | jQuery(this).hide(); |
| 555 | }); |
| 556 | |
| 557 | jQuery(document).on("click","#stickymenu_status_turnoff",function(e){ |
| 558 | e.preventDefault(); |
| 559 | var stickymenu_status = 0; |
| 560 | set_stickymenu_status( stickymenu_status ); |
| 561 | }); |
| 562 | |
| 563 | jQuery(document).on("click","#stickymenu_status_nevermind",function(e){ |
| 564 | e.preventDefault(); |
| 565 | jQuery("#stickymenu_status_popupbox").hide(); |
| 566 | jQuery("#stickymenuconfig-overlay-popup").hide(); |
| 567 | }); |
| 568 | |
| 569 | function set_stickymenu_status( stickymenu_status ){ |
| 570 | jQuery.ajax({ |
| 571 | url: ajaxurl, |
| 572 | type:'post', |
| 573 | data: 'action=stickymenu_status_update&stickymenu_status=' + stickymenu_status +'&wpnonce=' + mystickymenu.ajax_nonce, |
| 574 | success: function( data ){ |
| 575 | location.reload(); |
| 576 | }, |
| 577 | }); |
| 578 | } |
| 579 | |
| 580 | jQuery(document).on("click",".close-button",function(){ |
| 581 | if(jQuery(this).data("from") == 'welcome-bar-status'){ |
| 582 | var id = jQuery(this).data("id"); |
| 583 | jQuery("#widget-status-dialog-"+id).hide(); |
| 584 | jQuery("#mystickymenu-status-popup-overlay-"+id).hide(); |
| 585 | var widget_status = 1; |
| 586 | set_widget_status( id, widget_status ); |
| 587 | jQuery("#mystickymenu-widget-enabled-"+id).prop('checked', true) |
| 588 | |
| 589 | }else if( jQuery(this).data("from") == "stickymenu-status"){ |
| 590 | jQuery("#stickymenu_status_popupbox").hide(); |
| 591 | jQuery("#stickymenuconfig-overlay-popup").hide(); |
| 592 | |
| 593 | }else if( jQuery(this).data("from") == "stickymenu-confirm" ){ |
| 594 | jQuery("#mysticky-sticky-save-confirm").hide(); |
| 595 | jQuery("#stickymenu-option-overlay-popup").hide(); |
| 596 | }else if( jQuery(this).data("from") == "welcombar-confirm" ){ |
| 597 | jQuery("#welcomebar-save-confirm").hide(); |
| 598 | jQuery("#welcombar-sbmtvalidation-overlay-popup").hide(); |
| 599 | }else{ |
| 600 | var id = jQuery(this).data("id"); |
| 601 | jQuery("#widget-delete-dialog-"+id).hide(); |
| 602 | jQuery("#mystickymenu-delete-popup-overlay-"+id).hide(); |
| 603 | } |
| 604 | }); |
| 605 | |
| 606 | |
| 607 | jQuery(document).on("click","#stickymenu-option-overlay-popup",function(){ |
| 608 | $("#mysticky-sticky-save-confirm").hide(); |
| 609 | $(this).hide(); |
| 610 | }); |
| 611 | |
| 612 | |
| 613 | jQuery(document).on("click","#welcombar-sbmtvalidation-overlay-popup",function(){ |
| 614 | $("#welcomebar-save-confirm").hide(); |
| 615 | $(this).hide(); |
| 616 | }); |
| 617 | |
| 618 | |
| 619 | jQuery(document).on("change","#mysticky-welcomebar-countdown-enabled",function(){ |
| 620 | var url = jQuery(this).data("url"); |
| 621 | jQuery(this).prop('checked',false); |
| 622 | window.open(url, '_blank'); |
| 623 | }); |
| 624 | |
| 625 | jQuery(document).on("click",".btn-save-stickymenu" , function(event){ |
| 626 | if ( $( '#mysticky-stickymenu-form-enabled' ).prop( 'checked' ) == false && $('#save_stickymenu').val() == "" ) { |
| 627 | event.preventDefault(); |
| 628 | $("#mysticky-sticky-save-confirm").show(); |
| 629 | $("#stickymenu-option-overlay-popup").show(); |
| 630 | |
| 631 | $('#stickymenu_status_ok').attr('data-clickfrom', 'save'); |
| 632 | $('#stickymenu_status_dolater').attr('data-clickfrom', 'save'); |
| 633 | } |
| 634 | }); |
| 635 | |
| 636 | jQuery(document).on("click",".save_view_dashboard" , function(event){ |
| 637 | if ( $( '#mysticky-stickymenu-form-enabled' ).prop( 'checked' ) == false && $('#save_stickymenu').val() == "" ) { |
| 638 | event.preventDefault(); |
| 639 | $("#mysticky-sticky-save-confirm").show(); |
| 640 | $("#stickymenu-option-overlay-popup").show(); |
| 641 | |
| 642 | $('#stickymenu_status_ok').attr('data-clickfrom', 'dashboard'); |
| 643 | $('#stickymenu_status_dolater').attr('data-clickfrom', 'dashboard'); |
| 644 | } |
| 645 | }); |
| 646 | |
| 647 | jQuery(document).on("click","#stickymenu_status_ok",function(){ |
| 648 | //jQuery("html, body").animate({ scrollTop: "20" }); |
| 649 | var clickFrom = $(this).data("clickfrom"); |
| 650 | $('#save_stickymenu').val("1"); |
| 651 | $( '#mysticky-stickymenu-form-enabled' ).prop( 'checked' , true ) |
| 652 | $("#mysticky-sticky-save-confirm").hide(); |
| 653 | $("#stickymenu-option-overlay-popup").hide(); |
| 654 | if(clickFrom == 'dashboard'){ |
| 655 | $('.save_view_dashboard').trigger("click"); |
| 656 | }else{ |
| 657 | $('.btn-save-stickymenu').trigger("click"); |
| 658 | } |
| 659 | }); |
| 660 | |
| 661 | jQuery(document).on("click","#stickymenu_status_dolater",function(){ |
| 662 | var clickFrom = $(this).data("clickfrom"); |
| 663 | $('#save_stickymenu').val("1"); |
| 664 | if(clickFrom == 'dashboard'){ |
| 665 | $('.save_view_dashboard').trigger("click"); |
| 666 | }else{ |
| 667 | $('.btn-save-stickymenu').trigger("click"); |
| 668 | } |
| 669 | }); |
| 670 | |
| 671 | jQuery(document).on( 'click','.welcombar_save', function(e){ |
| 672 | |
| 673 | if ( $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked' ) == false && $( 'input#save_welcome_bar' ).val() == '' ) { |
| 674 | e.preventDefault(); |
| 675 | $("#welcomebar-save-confirm").show(); |
| 676 | $("#welcombar-sbmtvalidation-overlay-popup").show(); |
| 677 | $("#welcombar_sbmtbtn_off").attr("data-clickfrom",'save_button'); |
| 678 | $("#welcomebar_yes_sbmtbtn").attr("data-clickfrom",'save_button'); |
| 679 | } |
| 680 | }); |
| 681 | |
| 682 | |
| 683 | jQuery(document).on( 'click','.save_view_dashboard', function(e){ |
| 684 | |
| 685 | if ( $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked' ) == false && $( 'input#save_welcome_bar' ).val() == '' ) { |
| 686 | e.preventDefault(); |
| 687 | $("#welcomebar-save-confirm").show(); |
| 688 | $("#welcombar-sbmtvalidation-overlay-popup").show(); |
| 689 | $("#welcombar_sbmtbtn_off").attr("data-clickfrom",'save_dashboard_button'); |
| 690 | $("#welcomebar_yes_sbmtbtn").attr("data-clickfrom",'save_dashboard_button'); |
| 691 | } |
| 692 | }); |
| 693 | |
| 694 | jQuery(document).on("click","#welcomebar_yes_sbmtbtn",function(){ |
| 695 | |
| 696 | var clickFrom = $(this).data("clickfrom"); |
| 697 | |
| 698 | $("#welcomebar-save-confirm").hide(); |
| 699 | $("#welcombar-sbmtvalidation-overlay-popup").hide(); |
| 700 | $( 'input#welcome_save_anyway' ).val('1'); |
| 701 | $( 'input#save_welcome_bar' ).val('1'); |
| 702 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked',true ); |
| 703 | if(clickFrom == 'save_dashboard_button'){ |
| 704 | $( '.mysticky-welcomebar-submit input.save_view_dashboard' ).trigger('click'); |
| 705 | }else{ |
| 706 | $( '.mysticky-welcomebar-submit input.welcombar_save' ).trigger('click'); |
| 707 | } |
| 708 | }); |
| 709 | |
| 710 | jQuery(document).on("click","#welcombar_sbmtbtn_off",function(){ |
| 711 | var clickFrom = $(this).data("clickfrom"); |
| 712 | |
| 713 | $("#welcomebar-save-confirm").hide(); |
| 714 | $("#welcombar-sbmtvalidation-overlay-popup").hide(); |
| 715 | $( 'input#welcome_save_anyway' ).val('1'); |
| 716 | $( 'input#save_welcome_bar' ).val('1'); |
| 717 | |
| 718 | if(clickFrom == 'save_dashboard_button'){ |
| 719 | $( '.mysticky-welcomebar-submit input.save_view_dashboard' ).trigger('click'); |
| 720 | }else{ |
| 721 | $( '.mysticky-welcomebar-submit input.welcombar_save' ).trigger('click'); |
| 722 | } |
| 723 | }); |
| 724 | |
| 725 | })(jQuery); |