detectmobilebrowser.js
7 years ago
iris-script.js
6 years ago
mystickymenu-admin.js
6 years ago
mystickymenu.js
7 years ago
mystickymenu.min.js
7 years ago
mystickymenu-admin.js
243 lines
| 1 | (function( $ ) { |
| 2 | "use strict"; |
| 3 | |
| 4 | jQuery(document).ready(function($){ |
| 5 | |
| 6 | var handle = $( "#custom-handle" ); |
| 7 | $( "#slider" ).slider({ |
| 8 | create: function() { |
| 9 | handle.text( $( this ).slider( "value" ) ); |
| 10 | handle.text( $('#myfixed_opacity').val() ); |
| 11 | handle.css('left', $('#myfixed_opacity').val() + '%') |
| 12 | }, |
| 13 | slide: function( event, ui ) { |
| 14 | $('#myfixed_opacity').val(ui.value); |
| 15 | handle.text( ui.value ); |
| 16 | } |
| 17 | }); |
| 18 | jQuery( |
| 19 | '<div class="pt_number"><div class="pt_numberbutton pt_numberup">+</div><div class="pt_numberbutton pt_numberdown">-</div></div>' |
| 20 | ).insertAfter("input.mysticky-number1"); |
| 21 | |
| 22 | jQuery(".mystickynumber1").each(function() { |
| 23 | |
| 24 | var spinner = jQuery(this), |
| 25 | input = spinner.find('input[type="number"]'), |
| 26 | btnUp = spinner.find(".pt_numberup"), |
| 27 | btnDown = spinner.find(".pt_numberdown"), |
| 28 | min = input.attr("min"), |
| 29 | max = input.attr("max"), |
| 30 | valOfAmout = input.val(), |
| 31 | newVal = 0; |
| 32 | |
| 33 | btnUp.on("click", function() { |
| 34 | |
| 35 | var oldValue = parseFloat(input.val()); |
| 36 | |
| 37 | if (oldValue >= max) { |
| 38 | var newVal = oldValue; |
| 39 | } else { |
| 40 | var newVal = oldValue + 1; |
| 41 | } |
| 42 | spinner.find("input").val(newVal); |
| 43 | spinner.find("input").trigger("change"); |
| 44 | console.log(newVal); |
| 45 | }); |
| 46 | btnDown.on("click", function() { |
| 47 | var oldValue = parseFloat(input.val()); |
| 48 | if (oldValue <= min) { |
| 49 | var newVal = oldValue; |
| 50 | } else { |
| 51 | var newVal = oldValue - 1; |
| 52 | } |
| 53 | spinner.find("input").val(newVal); |
| 54 | spinner.find("input").trigger("change"); |
| 55 | }); |
| 56 | }); |
| 57 | |
| 58 | |
| 59 | $(".confirm").on( 'click', function() { |
| 60 | return window.confirm("Reset to default settings?"); |
| 61 | }); |
| 62 | |
| 63 | var flag = 0; |
| 64 | $( "#mystickymenu-select option" ).each(function( i ) { |
| 65 | |
| 66 | if ($('select#mystickymenu-select option:selected').val() !== '' ) { |
| 67 | flag = 1; |
| 68 | } |
| 69 | if( $('select#mystickymenu-select option:selected').val() == $(this).val() ){ |
| 70 | $('#mysticky_class_selector').show(); |
| 71 | }else { |
| 72 | $('#mysticky_class_selector').hide(); |
| 73 | } |
| 74 | }); |
| 75 | if ( flag === 0 ) { |
| 76 | $('#mysticky_class_selector').show(); |
| 77 | $("select#mystickymenu-select option[value=custom]").attr('selected', 'selected'); |
| 78 | } |
| 79 | |
| 80 | $("#mystickymenu-select").on( 'change', function() { |
| 81 | if ($(this).val() == 'custom' ) { |
| 82 | $('#mysticky_class_selector').show(); |
| 83 | }else { |
| 84 | $('#mysticky_class_selector').hide(); |
| 85 | } |
| 86 | |
| 87 | }); |
| 88 | /*02-08-2019 welcom bar js*/ |
| 89 | $( '.mysticky-welcomebar-action' ).on( 'change', function(){ |
| 90 | var mysticky_welcomebar_action = $( this ).val(); |
| 91 | if ( mysticky_welcomebar_action == 'close_bar' ) { |
| 92 | $( '.mysticky-welcomebar-redirect' ).hide(); |
| 93 | } else { |
| 94 | $( '.mysticky-welcomebar-redirect' ).show(); |
| 95 | } |
| 96 | } ); |
| 97 | //$( '#mysticky_welcomebar_expirydate' ).datepicker( ); |
| 98 | //$( "#mysticky_welcomebar_expirydate" ).datepicker( "option", "dateFormat", 'mm/dd/yy' ); |
| 99 | |
| 100 | var page_option_content = ""; |
| 101 | page_option_content = $( '.mysticky-welcomebar-page-options-html' ).html(); |
| 102 | $( '.mysticky-welcomebar-page-options-html' ).remove(); |
| 103 | |
| 104 | $( '#create-rule' ).on( 'click', function(){ |
| 105 | var append_html = page_option_content.replace(/__count__/g, '1', page_option_content); |
| 106 | $( '.mysticky-welcomebar-page-options' ).append( append_html ); |
| 107 | $( this ).remove(); |
| 108 | }); |
| 109 | $( '.sticky-header-menu ul li a' ).on( 'click', function(){ |
| 110 | if ( $( "#sticky-header-welcome-bar" ).is( ":visible" ) ) { |
| 111 | check_for_preview_pos(); |
| 112 | } |
| 113 | } ); |
| 114 | jQuery(window).scroll(function(){ |
| 115 | if ( $( "#sticky-header-welcome-bar" ).is( ":visible" ) ) { |
| 116 | check_for_preview_pos(); |
| 117 | } |
| 118 | }); |
| 119 | /* welcome bar live preview */ |
| 120 | /* Apply Wp Color Picker */ |
| 121 | var myOptions = { |
| 122 | change: function(event, ui){ |
| 123 | var color_id = $(this).attr('id'); |
| 124 | var slug = $(this).data('slug'); |
| 125 | |
| 126 | var color_code = ui.color.toString(); |
| 127 | if ( color_id === 'mysticky_welcomebar_bgcolor'){ |
| 128 | $('.mysticky-welcomebar-fixed').css('background-color', color_code ); |
| 129 | } |
| 130 | if ( color_id === 'mysticky_welcomebar_bgtxtcolor'){ |
| 131 | $('.mysticky-welcomebar-fixed .mysticky-welcomebar-content p').css('color', color_code ); |
| 132 | } |
| 133 | if ( color_id === 'mysticky_welcomebar_btncolor'){ |
| 134 | $('.mysticky-welcomebar-btn a').css('background-color', color_code ); |
| 135 | } |
| 136 | if ( color_id === 'mysticky_welcomebar_btntxtcolor'){ |
| 137 | $('.mysticky-welcomebar-btn a').css('color', color_code ); |
| 138 | } |
| 139 | } |
| 140 | }; |
| 141 | $('.mysticky-welcomebar-setting-wrap .my-color-field').wpColorPicker(myOptions); |
| 142 | |
| 143 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_x_desktop]"]' ).on( 'change', function(){ |
| 144 | if( $( this ).prop( "checked" ) == true ) { |
| 145 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-showx-desktop' ); |
| 146 | } else { |
| 147 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-showx-desktop' ); |
| 148 | } |
| 149 | } ); |
| 150 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_x_mobile]"]' ).on( 'change', function(){ |
| 151 | if( $( this ).prop( "checked" ) == true ) { |
| 152 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-showx-mobile' ); |
| 153 | } else { |
| 154 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-showx-mobile' ); |
| 155 | } |
| 156 | } ); |
| 157 | |
| 158 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_desktop]"]' ).on( 'change', function(){ |
| 159 | if( $( this ).prop( "checked" ) == true ) { |
| 160 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-btn-desktop' ); |
| 161 | } else { |
| 162 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-btn-desktop' ); |
| 163 | } |
| 164 | } ); |
| 165 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_mobile]"]' ).on( 'change', function(){ |
| 166 | if( $( this ).prop( "checked" ) == true ) { |
| 167 | $( '.mysticky-welcomebar-fixed' ).addClass( 'mysticky-welcomebar-btn-mobile' ); |
| 168 | } else { |
| 169 | $( '.mysticky-welcomebar-fixed' ).removeClass( 'mysticky-welcomebar-btn-mobile' ); |
| 170 | } |
| 171 | } ); |
| 172 | |
| 173 | $( 'select[name="mysticky_option_welcomebar[mysticky_welcomebar_font]"]' ).on( 'change', function(){ |
| 174 | var myfixed_font_val = $( this ).val(); |
| 175 | $( '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">' ); |
| 176 | $( '.mysticky-welcomebar-fixed' ).css( 'font-family', myfixed_font_val ); |
| 177 | } ); |
| 178 | |
| 179 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_fontsize]"]' ).on( 'keyup click', function(){ |
| 180 | var mysticky_welcomebar_fontsize_val = $( this ).val(); |
| 181 | $( '.mysticky-welcomebar-fixed p' ).css( 'font-size', mysticky_welcomebar_fontsize_val + 'px' ); |
| 182 | $( '.mysticky-welcomebar-btn a' ).css( 'font-size', mysticky_welcomebar_fontsize_val + 'px' ); |
| 183 | } ); |
| 184 | |
| 185 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_bar_text]"]' ).on( 'keyup', function(){ |
| 186 | var mysticky_bar_text_val = $( this ).val(); |
| 187 | $( '.mysticky-welcomebar-content p' ).text( mysticky_bar_text_val ); |
| 188 | } ); |
| 189 | |
| 190 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_btn_text]"]' ).on( 'keyup', function(){ |
| 191 | var mysticky_btn_text_val = $( this ).val(); |
| 192 | $( '.mysticky-welcomebar-btn a' ).text( mysticky_btn_text_val ); |
| 193 | } ); |
| 194 | |
| 195 | $( '.mysticky-welcomebar-submit input#submit' ).on( 'click', function(e){ |
| 196 | if ( $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked' ) == false && $( 'input#save_welcome_bar' ).val() == '' ) { |
| 197 | e.preventDefault(); |
| 198 | $( "#mysticky-welcomebar-save-confirm" ).dialog({ |
| 199 | resizable: false, |
| 200 | modal: true, |
| 201 | draggable: false, |
| 202 | height: 'auto', |
| 203 | width: 600, |
| 204 | buttons: { |
| 205 | "Yes, show it on my site": { |
| 206 | click:function () { |
| 207 | $( 'input[name="mysticky_option_welcomebar[mysticky_welcomebar_enable]"]' ).prop( 'checked', true ); |
| 208 | $( '.mysticky-welcomebar-submit input#submit' ).trigger('click'); |
| 209 | $( this ).dialog('close'); |
| 210 | }, |
| 211 | text: 'Yes, show it on my site', |
| 212 | class: 'green-btn' |
| 213 | }, |
| 214 | "Just save and keep it off": function () { |
| 215 | $( 'input#save_welcome_bar' ).val('1'); |
| 216 | $( '.mysticky-welcomebar-submit input#submit' ).trigger('click'); |
| 217 | $( this ).dialog( 'close' ); |
| 218 | } |
| 219 | } |
| 220 | }); |
| 221 | } |
| 222 | //return false; |
| 223 | } ); |
| 224 | |
| 225 | }); |
| 226 | $( window ).load( function(){ |
| 227 | $( '.mysticky-welcomebar-url-options' ).each( function(){ |
| 228 | $( this ).trigger( 'change' ); |
| 229 | }); |
| 230 | }); |
| 231 | function check_for_preview_pos() { |
| 232 | if($(".show-on-apper").length && $(".mysticky-welcomebar-setting-right").length) { |
| 233 | var topPos = $(".show-on-apper").offset().top - $(window).scrollTop() - 650; |
| 234 | if (topPos < 0) { |
| 235 | topPos = Math.abs(topPos); |
| 236 | jQuery(".mysticky-welcomebar-setting-right").css("margin-top", ((-1)*topPos)+"px"); |
| 237 | } else { |
| 238 | jQuery(".mysticky-welcomebar-setting-right").css("margin-top", "0"); |
| 239 | } |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | })(jQuery); |