admin.1778685035.js
3 weeks ago
admin.ajaxWatcher.1778685035.js
3 weeks ago
chart.umd.1778685035.js
3 weeks ago
jquery.qrcode.min.1778685035.js
3 weeks ago
vue.esm-browser.prod.1778685035.js
3 weeks ago
wfdashboard.1778685035.js
3 weeks ago
wfdropdown.1778685035.js
3 weeks ago
wfglobal.1778685035.js
3 weeks ago
wfi18n.1778685035.js
3 weeks ago
wfonboarding.1778685035.js
3 weeks ago
wfpopover.1778685035.js
3 weeks ago
wordfence.1778685035.js
3 weeks ago
admin.1778685035.js
538 lines
| 1 | (function($) { |
| 2 | var sprintf, |
| 3 | __; |
| 4 | |
| 5 | if (!window['wordfenceAdmin']) { //To compile for checking: java -jar /usr/local/bin/closure.jar --js=admin.js --js_output_file=test.js |
| 6 | window['wordfenceAdmin'] = { |
| 7 | isSmallScreen: false, |
| 8 | loadingCount: 0, |
| 9 | mode: '', |
| 10 | nonce: false, |
| 11 | debugOn: false, |
| 12 | _windowHasFocus: true, |
| 13 | basePageName: '', |
| 14 | siteCleaningIssueTypes: ['file', 'checkGSB', 'checkSpamIP', 'commentBadURL', 'knownfile', 'optionBadURL', 'postBadTitle', 'postBadURL', 'spamvertizeCheck', 'suspiciousAdminUsers'], |
| 15 | |
| 16 | //Screen sizes |
| 17 | SCREEN_XS: 'xs', |
| 18 | SCREEN_SM: 'sm', |
| 19 | SCREEN_MD: 'md', |
| 20 | SCREEN_LG: 'lg', |
| 21 | |
| 22 | init: function() { |
| 23 | this.isSmallScreen = window.matchMedia("only screen and (max-width: 500px)").matches; |
| 24 | |
| 25 | this.nonce = WordfenceAdminVars.firstNonce; |
| 26 | this.debugOn = WordfenceAdminVars.debugOn == '1' ? true : false; |
| 27 | this.basePageName = document.title; |
| 28 | var self = this; |
| 29 | |
| 30 | $(window).on('blur', function() { |
| 31 | self._windowHasFocus = false; |
| 32 | }).on('focus', function() { |
| 33 | self._windowHasFocus = true; |
| 34 | }).focus(); |
| 35 | |
| 36 | $('.do-show').click(function() { |
| 37 | var $this = $(this); |
| 38 | $this.hide(); |
| 39 | $($this.data('selector')).show(); |
| 40 | return false; |
| 41 | }); |
| 42 | |
| 43 | $('.downloadLogFile').each(function() { |
| 44 | $(this).attr('href', WordfenceAdminVars.ajaxURL + '?action=wordfence_downloadLogFile&nonce=' + WFAD.ajaxNonce('downloadLogFile') + '&logfile=' + encodeURIComponent($(this).data('logfile'))); |
| 45 | }); |
| 46 | |
| 47 | var tabs = jQuery('.wf-page-tabs').find('.wf-tab a'); |
| 48 | if (tabs.length > 0) { |
| 49 | tabs.click(function() { |
| 50 | jQuery('.wf-page-tabs').find('.wf-tab').removeClass('wf-active').find('a').attr('aria-selected', 'false'); |
| 51 | jQuery('.wf-tab-content').removeClass('wf-active'); |
| 52 | |
| 53 | var tab = jQuery(this).closest('.wf-tab'); |
| 54 | tab.addClass('wf-active'); |
| 55 | tab.find('a').attr('aria-selected', 'true'); |
| 56 | var content = jQuery('#' + tab.data('target')); |
| 57 | content.addClass('wf-active'); |
| 58 | document.title = tab.data('pageTitle') + " \u2039 " + self.basePageName; |
| 59 | self.sectionInit(); |
| 60 | $(window).trigger('wfTabChange', [tab.data('target')]); |
| 61 | }); |
| 62 | if (window.location.hash) { |
| 63 | var hashes = WFAD.parseHashes(); |
| 64 | var hash = hashes[hashes.length - 1]; |
| 65 | for (var i = 0; i < tabs.length; i++) { |
| 66 | if (hash == jQuery(tabs[i]).closest('.wf-tab').data('target')) { |
| 67 | jQuery(tabs[i]).trigger('click'); |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | else { |
| 72 | jQuery(tabs[0]).trigger('click'); |
| 73 | } |
| 74 | jQuery(window).on('hashchange', function () { |
| 75 | var hashes = WFAD.parseHashes(); |
| 76 | var hash = hashes[hashes.length - 1]; |
| 77 | for (var i = 0; i < tabs.length; i++) { |
| 78 | if (hash == jQuery(tabs[i]).closest('.wf-tab').data('target')) { |
| 79 | jQuery(tabs[i]).trigger('click'); |
| 80 | } |
| 81 | } |
| 82 | }); |
| 83 | } |
| 84 | else { |
| 85 | this.sectionInit(); |
| 86 | } |
| 87 | |
| 88 | if ($('.wf-options-controls-spacer').length) { //The WP code doesn't move update nags and we need to |
| 89 | $('.update-nag, #update-nag').insertAfter($('.wf-options-controls-spacer')); |
| 90 | } |
| 91 | |
| 92 | $(document).focus(); |
| 93 | |
| 94 | // (docs|support).wordfence.com GA links |
| 95 | $(document).on('click', 'a', function() { |
| 96 | if (this.href && this.href.indexOf('utm_source') > -1) { |
| 97 | return; |
| 98 | } |
| 99 | var utm = ''; |
| 100 | if ((this.host == 'www.wordfence.com' || this.host == 'wordfence.com') && /^\/help(?:$|\/)/.test(this.pathname)) { |
| 101 | utm = 'utm_source=plugin&utm_medium=pluginUI&utm_campaign=docsIcon'; |
| 102 | } |
| 103 | if (utm) { |
| 104 | utm = (this.search ? '&' : '?') + utm; |
| 105 | this.href = this.protocol + '//' + this.host + this.pathname + this.search + utm + this.hash; |
| 106 | } |
| 107 | |
| 108 | if (this.href == 'http://support.wordfence.com/') { |
| 109 | this.href = 'https://support.wordfence.com/support/home?utm_source=plugin&utm_medium=pluginUI&utm_campaign=supportLink'; |
| 110 | } |
| 111 | }); |
| 112 | |
| 113 | $('.wf-block-header-action-disclosure.wf-legacy').each(function() { |
| 114 | $(this).on('keydown', function(e) { |
| 115 | if (e.keyCode == 32) { |
| 116 | e.preventDefault(); |
| 117 | e.stopPropagation(); |
| 118 | |
| 119 | $(this).closest('.wf-block-header').trigger('click'); |
| 120 | } |
| 121 | }); |
| 122 | |
| 123 | $(this).closest('.wf-block-header').css('cursor', 'pointer'); |
| 124 | $(this).closest('.wf-block-header').on('click', function(e) { |
| 125 | // Let links in the header work. |
| 126 | if (e.target && e.target.nodeName === 'A' && e.target.href) { |
| 127 | return; |
| 128 | } |
| 129 | e.preventDefault(); |
| 130 | e.stopPropagation(); |
| 131 | |
| 132 | if ($(this).closest('.wf-block').hasClass('wf-disabled')) { |
| 133 | return; |
| 134 | } |
| 135 | |
| 136 | var isActive = $(this).closest('.wf-block').hasClass('wf-active'); |
| 137 | if (isActive) { |
| 138 | $(this).closest('.wf-block').find('.wf-block-content').slideUp({ |
| 139 | always: function() { |
| 140 | $(this).closest('.wf-block').removeClass('wf-active'); |
| 141 | $(this).closest('.wf-block').find('.wf-block-header-action-disclosure').attr('aria-checked', 'false'); |
| 142 | } |
| 143 | }); |
| 144 | } |
| 145 | else { |
| 146 | $(this).closest('.wf-block').find('.wf-block-content').slideDown({ |
| 147 | always: function() { |
| 148 | $(this).closest('.wf-block').addClass('wf-active'); |
| 149 | $(this).closest('.wf-block').find('.wf-block-header-action-disclosure').attr('aria-checked', 'true'); |
| 150 | } |
| 151 | }); |
| 152 | } |
| 153 | |
| 154 | WFAD.ajax('wordfence_saveDisclosureState', {name: $(this).closest('.wf-block').data('persistenceKey'), state: !isActive}, function() {}, function() {}, true); |
| 155 | }); |
| 156 | }); |
| 157 | }, |
| 158 | sectionInit: function() { |
| 159 | var self = this; |
| 160 | this.mode = false; |
| 161 | if (jQuery('#wordfenceMode_dashboard:visible').length > 0) { |
| 162 | this.mode = 'dashboard'; |
| 163 | } else if (jQuery('#wordfenceMode_scan:visible').length > 0) { |
| 164 | this.mode = 'scan'; |
| 165 | } else if (jQuery('#wordfenceMode_waf:visible').length > 0) { |
| 166 | this.mode = 'waf'; |
| 167 | } else if (jQuery('#wordfenceMode_twoFactor:visible').length > 0) { |
| 168 | this.mode = 'twoFactor'; |
| 169 | } else if (jQuery('#wordfenceMode_scanScheduling:visible').length > 0) { |
| 170 | this.mode = 'scanScheduling'; |
| 171 | this.sched_modeChange(); |
| 172 | } |
| 173 | }, |
| 174 | wordfenceSatisfactionChoice: function(choice) { |
| 175 | if (choice == 'yes') { |
| 176 | $('#wordfenceSatisfactionPrompt-yes').slideDown(400, function() { |
| 177 | $('#wordfenceSatisfactionPrompt-initial .wf-btn').addClass('wf-disabled').css('opacity', 0.3); |
| 178 | $('#wordfenceSatisfactionPrompt-initial .wf-btn:first-of-type').css('opacity', 0.8); |
| 179 | }); |
| 180 | WFAD.ajax('wordfence_wordfenceSatisfactionChoice', {choice: choice}); |
| 181 | } |
| 182 | else if (choice == 'no') { |
| 183 | $('#wordfenceSatisfactionPrompt-no').slideDown(400, function() { |
| 184 | $('#wordfenceSatisfactionPrompt-initial .wf-btn').addClass('wf-disabled').css('opacity', 0.3); |
| 185 | $('#wordfenceSatisfactionPrompt-initial .wf-btn:last-of-type').css('opacity', 0.8); |
| 186 | }); |
| 187 | WFAD.ajax('wordfence_wordfenceSatisfactionChoice', {choice: choice}); |
| 188 | } |
| 189 | else if (choice == 'feedback') { |
| 190 | WFAD.ajax('wordfence_wordfenceSatisfactionChoice', { |
| 191 | choice: choice, |
| 192 | feedback: $('#wordfenceSatisfactionPrompt-feedback').val(), |
| 193 | }, |
| 194 | function(res) { $('#wordfenceSatisfactionPrompt-no').fadeOut(); $('#wordfenceSatisfactionPrompt-complete').fadeIn(); }, |
| 195 | function() { $('#wordfenceSatisfactionPrompt-no').fadeOut(); $('#wordfenceSatisfactionPrompt-complete').fadeIn(); } |
| 196 | ); |
| 197 | } |
| 198 | else if (choice == 'dismiss') { |
| 199 | $('#wordfenceSatisfactionPrompt').fadeOut(); |
| 200 | WFAD.ajax('wordfence_wordfenceSatisfactionChoice', {choice: choice}); |
| 201 | } |
| 202 | }, |
| 203 | showLoading: function() { |
| 204 | this.loadingCount++; |
| 205 | if (this.loadingCount == 1) { |
| 206 | $('<div id="wordfenceWorking">' + __('Wordfence is working...') + '</div>').appendTo('body'); |
| 207 | } |
| 208 | }, |
| 209 | removeLoading: function() { |
| 210 | this.loadingCount--; |
| 211 | if (this.loadingCount == 0) { |
| 212 | jQuery('#wordfenceWorking').remove(); |
| 213 | } |
| 214 | }, |
| 215 | |
| 216 | /** |
| 217 | * Returns the nonce for the given action. If there isn't one, returns null. |
| 218 | * |
| 219 | * @param {string} action |
| 220 | * @returns {string|null} |
| 221 | */ |
| 222 | ajaxNonce: function(action) { |
| 223 | const normalizedAction = String(action ?? '').replace(/^wordfence_/, ''); |
| 224 | for (const entry of Object.values(this.nonce ?? {})) { |
| 225 | if (entry?.actions?.includes(normalizedAction)) { |
| 226 | return entry.nonce ?? null; |
| 227 | } |
| 228 | } |
| 229 | return null; |
| 230 | }, |
| 231 | |
| 232 | /** |
| 233 | * Updates the cached nonce for the given action. |
| 234 | * |
| 235 | * @param {string} action |
| 236 | * @param {string} newNonce |
| 237 | * @returns {boolean} |
| 238 | */ |
| 239 | updateAjaxNonce: function(action, newNonce) { |
| 240 | if (!newNonce) { return false; } |
| 241 | const normalizedAction = String(action ?? '').replace(/^wordfence_/, ''); |
| 242 | for (const entry of Object.values(this.nonce ?? {})) { |
| 243 | if (entry?.actions?.includes(normalizedAction)) { |
| 244 | entry.nonce = newNonce; |
| 245 | return true; |
| 246 | } |
| 247 | } |
| 248 | return false; |
| 249 | }, |
| 250 | |
| 251 | /** |
| 252 | * Calls the AJAX endpoint for the given action with the payload provided. Depending on the response, calls cb |
| 253 | * or cbErr with the result. |
| 254 | * |
| 255 | * @param {string} action |
| 256 | * @param {string|array|object} data |
| 257 | * @param {function} cb |
| 258 | * @param {function} cbErr |
| 259 | * @param {boolean} noLoading |
| 260 | */ |
| 261 | ajax(action, data, cb = () => {}, cbErr = () => {}, noLoading = false) { |
| 262 | const onSuccess = (typeof cb === 'function') ? cb : () => {}; |
| 263 | const onError = (typeof cbErr === 'function') ? cbErr : () => {}; |
| 264 | |
| 265 | if (typeof data === 'string') { |
| 266 | data += `${data.length > 0 ? '&' : ''}action=${action}&nonce=${this.ajaxNonce(action)}`; |
| 267 | } |
| 268 | else if (typeof(data) == 'object' && data instanceof Array) { |
| 269 | data.push({ name: 'action', value: action }); |
| 270 | data.push({ name: 'nonce', value: this.ajaxNonce(action) }); |
| 271 | } |
| 272 | else if (data && typeof data === 'object') { |
| 273 | data = Object.assign({}, data, { action, nonce: this.ajaxNonce(action) }); |
| 274 | } |
| 275 | |
| 276 | if (!noLoading) { this.showLoading(); } |
| 277 | jQuery.ajax({ |
| 278 | type: 'POST', |
| 279 | url: WordfenceAdminVars.ajaxURL, |
| 280 | dataType: 'json', |
| 281 | data, |
| 282 | success: (json) => { |
| 283 | if (!noLoading) { this.removeLoading(); } |
| 284 | this.updateAjaxNonce(action, json?.nonce); |
| 285 | if (json?.errorMsg) { |
| 286 | window.WFEventEmitter.emit('showModal', { name: 'simple-confirmation-modal', title: __('An error occurred'), message: json.errorMsg }); |
| 287 | } |
| 288 | onSuccess(json); |
| 289 | }, |
| 290 | error: (response) => { |
| 291 | if (!noLoading) { this.removeLoading(); } |
| 292 | onError(); |
| 293 | }, |
| 294 | }); |
| 295 | }, |
| 296 | parseHashes: function() { |
| 297 | var hashes = window.location.hash.replace('%23', '#'); |
| 298 | var splitHashes = hashes.split('#'); |
| 299 | var result = []; |
| 300 | for (var i = 0; i < splitHashes.length; i++) { |
| 301 | if (splitHashes[i].length > 0) { |
| 302 | result.push(splitHashes[i]); |
| 303 | } |
| 304 | } |
| 305 | return result; |
| 306 | }, |
| 307 | inet_aton: function(dot) { |
| 308 | var d = dot.split('.'); |
| 309 | return ((((((+d[0]) * 256) + (+d[1])) * 256) + (+d[2])) * 256) + (+d[3]); |
| 310 | }, |
| 311 | inet_ntoa: function(num) { |
| 312 | var d = num % 256; |
| 313 | for (var i = 3; i > 0; i--) { |
| 314 | num = Math.floor(num / 256); |
| 315 | d = num % 256 + '.' + d; |
| 316 | } |
| 317 | return d; |
| 318 | }, |
| 319 | |
| 320 | inet_pton: function(a) { |
| 321 | // discuss at: http://phpjs.org/functions/inet_pton/ |
| 322 | // original by: Theriault |
| 323 | // example 1: inet_pton('::'); |
| 324 | // returns 1: '\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0' |
| 325 | // example 2: inet_pton('127.0.0.1'); |
| 326 | // returns 2: '\x7F\x00\x00\x01' |
| 327 | |
| 328 | var r, m, x, i, j, f = String.fromCharCode; |
| 329 | m = a.match(/^(?:\d{1,3}(?:\.|$)){4}/); // IPv4 |
| 330 | if (m) { |
| 331 | m = m[0].split('.'); |
| 332 | m = f(m[0]) + f(m[1]) + f(m[2]) + f(m[3]); |
| 333 | // Return if 4 bytes, otherwise false. |
| 334 | return m.length === 4 ? m : false; |
| 335 | } |
| 336 | r = /^((?:[\da-f]{1,4}(?::|)){0,8})(::)?((?:[\da-f]{1,4}(?::|)){0,8})$/i; |
| 337 | m = a.match(r); // IPv6 |
| 338 | if (m) { |
| 339 | if (a == '::') { |
| 340 | return "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; |
| 341 | } |
| 342 | |
| 343 | var colonCount = a.split(':').length - 1; |
| 344 | var doubleColonPos = a.indexOf('::'); |
| 345 | if (doubleColonPos > -1) { |
| 346 | var expansionLength = ((doubleColonPos == 0 || doubleColonPos == a.length - 2) ? 9 : 8) - colonCount; |
| 347 | var expansion = ''; |
| 348 | for (i = 0; i < expansionLength; i++) { |
| 349 | expansion += ':0000'; |
| 350 | } |
| 351 | a = a.replace('::', expansion + ':'); |
| 352 | a = a.replace(/(?:^\:|\:$)/, '', a); |
| 353 | } |
| 354 | |
| 355 | var ipGroups = a.split(':'); |
| 356 | var ipBin = ''; |
| 357 | for (i = 0; i < ipGroups.length; i++) { |
| 358 | var group = ipGroups[i]; |
| 359 | if (group.length > 4) { |
| 360 | return false; |
| 361 | } |
| 362 | group = ("0000" + group).slice(-4); |
| 363 | var b1 = parseInt(group.slice(0, 2), 16); |
| 364 | var b2 = parseInt(group.slice(-2), 16); |
| 365 | if (isNaN(b1) || isNaN(b2)) { |
| 366 | return false; |
| 367 | } |
| 368 | ipBin += f(b1) + f(b2); |
| 369 | } |
| 370 | |
| 371 | return ipBin.length == 16 ? ipBin : false; |
| 372 | } |
| 373 | return false; // Invalid IP. |
| 374 | }, |
| 375 | inet_ntop: function(a) { |
| 376 | // discuss at: http://phpjs.org/functions/inet_ntop/ |
| 377 | // original by: Theriault |
| 378 | // example 1: inet_ntop('\x7F\x00\x00\x01'); |
| 379 | // returns 1: '127.0.0.1' |
| 380 | // example 2: inet_ntop('\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\1'); |
| 381 | // returns 2: '::1' |
| 382 | |
| 383 | var i = 0, |
| 384 | m = '', |
| 385 | c = []; |
| 386 | a += ''; |
| 387 | if (a.length === 4) { // IPv4 |
| 388 | return [ |
| 389 | a.charCodeAt(0), a.charCodeAt(1), a.charCodeAt(2), a.charCodeAt(3)].join('.'); |
| 390 | } else if (a.length === 16) { // IPv6 |
| 391 | for (i = 0; i < 16; i++) { |
| 392 | c.push(((a.charCodeAt(i++) << 8) + a.charCodeAt(i)) |
| 393 | .toString(16)); |
| 394 | } |
| 395 | return c.join(':') |
| 396 | .replace(/((^|:)0(?=:|$))+:?/g, function(t) { |
| 397 | m = (t.length > m.length) ? t : m; |
| 398 | return t; |
| 399 | }) |
| 400 | .replace(m || ' ', '::'); |
| 401 | } else { // Invalid length |
| 402 | return false; |
| 403 | } |
| 404 | }, |
| 405 | |
| 406 | getParameterByName: function(name, url) { |
| 407 | if (!url) url = window.location.href; |
| 408 | name = name.replace(/[\[\]]/g, "\\$&"); |
| 409 | var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"), |
| 410 | results = regex.exec(url); |
| 411 | if (!results) return null; |
| 412 | if (!results[2]) return ''; |
| 413 | return decodeURIComponent(results[2].replace(/\+/g, " ")); |
| 414 | }, |
| 415 | }; |
| 416 | |
| 417 | window['WFAD'] = window['wordfenceAdmin']; |
| 418 | } |
| 419 | |
| 420 | __ = window.wfi18n.__; |
| 421 | sprintf = window.wfi18n.sprintf; |
| 422 | |
| 423 | jQuery(function() { |
| 424 | wordfenceAdmin.init(); |
| 425 | jQuery(window).on('focus', function() { |
| 426 | if (jQuery('body').hasClass('wordfenceLiveActivityPaused')) { |
| 427 | jQuery('body').removeClass('wordfenceLiveActivityPaused'); |
| 428 | } |
| 429 | }); |
| 430 | }); |
| 431 | })(jQuery); |
| 432 | |
| 433 | //wfMobileMenu |
| 434 | (function ($, document, window) { |
| 435 | var __ = window.wfi18n.__; |
| 436 | |
| 437 | var defaults = { |
| 438 | width: '280px', |
| 439 | clickOverlayDismiss: true, |
| 440 | menuItems: [], |
| 441 | onDismiss: false, |
| 442 | }; |
| 443 | |
| 444 | var publicMethod = $.fn['wfMobileMenu'] = $['wfMobileMenu'] = function (options) { |
| 445 | var opts = $.extend({}, defaults, options); |
| 446 | |
| 447 | var overlay = $('<div class="wf-mobile-menu-overlay"></div>').css('opacity', 0); |
| 448 | if (opts.clickOverlayDismiss) { |
| 449 | overlay.on('click', function(e) { |
| 450 | e.preventDefault(); |
| 451 | e.stopPropagation(); |
| 452 | |
| 453 | typeof opts.onDismiss === 'function' && opts.onDismiss(false); |
| 454 | $.wfMobileMenu.close(); |
| 455 | }); |
| 456 | } |
| 457 | $('body').append(overlay); |
| 458 | |
| 459 | var menu = $('<div class="wf-mobile-menu"><ul class="wf-mobile-menu-items"></ul></div>').css('width', opts.width).css('bottom', '-9999px'); |
| 460 | var itemsWrapper = menu.find('.wf-mobile-menu-items'); |
| 461 | for (var i = 0; i < opts.menuItems.length; i++) { |
| 462 | var button = $('<li><a href="#" class="wf-btn wf-btn-callout-subtle" role="button"></a></li>'); |
| 463 | button.find('a').text(opts.menuItems[i].title).css('width', opts.width).on('click', null, {action: opts.menuItems[i].action}, function(e) { |
| 464 | e.preventDefault(); |
| 465 | e.stopPropagation(); |
| 466 | |
| 467 | typeof opts.onDismiss === 'function' && opts.onDismiss(true); |
| 468 | $.wfMobileMenu.close(); |
| 469 | e.data.action(); |
| 470 | }); |
| 471 | |
| 472 | if (opts.menuItems[i].primary) { |
| 473 | button.find('a').addClass('wf-btn-primary'); |
| 474 | } |
| 475 | else { |
| 476 | button.find('a').addClass('wf-btn-default'); |
| 477 | } |
| 478 | |
| 479 | if (opts.menuItems[i].disabled) { |
| 480 | button.find('a').addClass('wf-disabled'); |
| 481 | } |
| 482 | |
| 483 | itemsWrapper.append(button); |
| 484 | } |
| 485 | |
| 486 | var button = $('<li class="wf-padding-add-top-small"><a href="#" class="wf-btn wf-btn-callout-subtle wf-btn-default" role="button">' + __('Close') + '</a></li>'); |
| 487 | button.find('a').css('width', opts.width).on('click', function(e) { |
| 488 | e.preventDefault(); |
| 489 | e.stopPropagation(); |
| 490 | |
| 491 | typeof opts.onDismiss === 'function' && opts.onDismiss(false); |
| 492 | $.wfMobileMenu.close(); |
| 493 | }); |
| 494 | itemsWrapper.append(button); |
| 495 | |
| 496 | $('body').append(menu); |
| 497 | menu.css('bottom', '-' + menu.height() + 'px'); |
| 498 | |
| 499 | overlay.animate({ |
| 500 | "opacity": 1 |
| 501 | }); |
| 502 | menu.animate({ |
| 503 | bottom: '0px' |
| 504 | }, |
| 505 | { |
| 506 | complete: function() { |
| 507 | typeof opts.onComplete === 'function' && opts.onComplete(); |
| 508 | } |
| 509 | }); |
| 510 | }; |
| 511 | |
| 512 | publicMethod.close = function() { |
| 513 | var overlay = $('.wf-mobile-menu-overlay'); |
| 514 | overlay.animate({ |
| 515 | "opacity": 0 |
| 516 | }, |
| 517 | { |
| 518 | complete: function() { |
| 519 | overlay.remove(); |
| 520 | } |
| 521 | }); |
| 522 | |
| 523 | var menu = $('.wf-mobile-menu'); |
| 524 | menu.animate({ |
| 525 | bottom: '-' + menu.height() + 'px' |
| 526 | }, |
| 527 | { |
| 528 | complete: function() { |
| 529 | menu.remove(); |
| 530 | } |
| 531 | }); |
| 532 | }; |
| 533 | }(jQuery, document, window)); |
| 534 | |
| 535 | /*! @source https://github.com/eligrey/FileSaver.js/blob/master/dist/FileSaver.min.js */ |
| 536 | |
| 537 | (function(a,b){if("function"==typeof define&&define.amd)define([],b);else if("undefined"!=typeof exports)b();else{b(),a.FileSaver={exports:{}}.exports}})(this,function(){"use strict";function b(a,b){return"undefined"==typeof b?b={autoBom:!1}:"object"!=typeof b&&(console.warn("Deprecated: Expected third argument to be a object"),b={autoBom:!b}),b.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(a.type)?new Blob(["\uFEFF",a],{type:a.type}):a}function c(a,b,c){var d=new XMLHttpRequest;d.open("GET",a),d.responseType="blob",d.onload=function(){g(d.response,b,c)},d.onerror=function(){console.error("could not download file")},d.send()}function d(a){var b=new XMLHttpRequest;b.open("HEAD",a,!1);try{b.send()}catch(a){}return 200<=b.status&&299>=b.status}function e(a){try{a.dispatchEvent(new MouseEvent("click"))}catch(c){var b=document.createEvent("MouseEvents");b.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),a.dispatchEvent(b)}}var f="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof global&&global.global===global?global:void 0,a=/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),g=f.saveAs||("object"!=typeof window||window!==f?function(){}:"download"in HTMLAnchorElement.prototype&&!a?function(b,g,h){var i=f.URL||f.webkitURL,j=document.createElement("a");g=g||b.name||"download",j.download=g,j.rel="noopener","string"==typeof b?(j.href=b,j.origin===location.origin?e(j):d(j.href)?c(b,g,h):e(j,j.target="_blank")):(j.href=i.createObjectURL(b),setTimeout(function(){i.revokeObjectURL(j.href)},4E4),setTimeout(function(){e(j)},0))}:"msSaveOrOpenBlob"in navigator?function(f,g,h){if(g=g||f.name||"download","string"!=typeof f)navigator.msSaveOrOpenBlob(b(f,h),g);else if(d(f))c(f,g,h);else{var i=document.createElement("a");i.href=f,i.target="_blank",setTimeout(function(){e(i)})}}:function(b,d,e,g){if(g=g||open("","_blank"),g&&(g.document.title=g.document.body.innerText="downloading..."),"string"==typeof b)return c(b,d,e);var h="application/octet-stream"===b.type,i=/constructor/i.test(f.HTMLElement)||f.safari,j=/CriOS\/[\d]+/.test(navigator.userAgent);if((j||h&&i||a)&&"undefined"!=typeof FileReader){var k=new FileReader;k.onloadend=function(){var a=k.result;a=j?a:a.replace(/^data:[^;]*;/,"data:attachment/file;"),g?g.location.href=a:location=a,g=null},k.readAsDataURL(b)}else{var l=f.URL||f.webkitURL,m=l.createObjectURL(b);g?g.location=m:location.href=m,g=null,setTimeout(function(){l.revokeObjectURL(m)},4E4)}});f.saveAs=g.saveAs=g,"undefined"!=typeof module&&(module.exports=g)}); |
| 538 |