first
This commit is contained in:
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
// Silence is golden.
|
||||
// Hide file structure from users on unprotected servers.
|
@ -0,0 +1,140 @@
|
||||
/*!
|
||||
* jQuery postMessage - v0.5 - 9/11/2009
|
||||
* http://benalman.com/projects/jquery-postmessage-plugin/
|
||||
*
|
||||
* Copyright (c) 2009 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*
|
||||
* Non-jQuery fork by Jeff Lee
|
||||
*
|
||||
* This fork consists of the following changes:
|
||||
* 1. Basic code cleanup and restructuring, for legibility.
|
||||
* 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
|
||||
* in terms of both function names and object scope. Scope is specified by
|
||||
* the the "this" context of NoJQueryPostMessageMixin();
|
||||
* 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
|
||||
* at least three different GitHub users requesting the removal of this
|
||||
* "Opera sniff" on the original project's Issues page, so I figured this
|
||||
* would be a relatively safe change.
|
||||
* 4. `postMessage` no longer uses `$.param` to serialize messages that are not
|
||||
* strings. I actually prefer this structure anyway. `receiveMessage` does
|
||||
* not implement a corresponding deserialization step, and as such it seems
|
||||
* cleaner and more symmetric to leave both data serialization and
|
||||
* deserialization to the client.
|
||||
* 5. The use of `$.isFunction` is replaced by a functionally-identical check.
|
||||
* 6. The `$:nomunge` YUI option is no longer necessary.
|
||||
*/
|
||||
|
||||
function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
|
||||
|
||||
var setMessageCallback, unsetMessageCallback, currentMsgCallback,
|
||||
intervalId, lastHash, cacheBust = 1;
|
||||
|
||||
if (window.postMessage) {
|
||||
|
||||
if (window.addEventListener) {
|
||||
setMessageCallback = function(callback) {
|
||||
window.addEventListener('message', callback, false);
|
||||
}
|
||||
|
||||
unsetMessageCallback = function(callback) {
|
||||
window.removeEventListener('message', callback, false);
|
||||
}
|
||||
} else {
|
||||
setMessageCallback = function(callback) {
|
||||
window.attachEvent('onmessage', callback);
|
||||
}
|
||||
|
||||
unsetMessageCallback = function(callback) {
|
||||
window.detachEvent('onmessage', callback);
|
||||
}
|
||||
}
|
||||
|
||||
this[postBinding] = function(message, targetUrl, target) {
|
||||
if (!targetUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The browser supports window.postMessage, so call it with a targetOrigin
|
||||
// set appropriately, based on the targetUrl parameter.
|
||||
target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
|
||||
}
|
||||
|
||||
// Since the browser supports window.postMessage, the callback will be
|
||||
// bound to the actual event associated with window.postMessage.
|
||||
this[receiveBinding] = function(callback, sourceOrigin, delay) {
|
||||
// Unbind an existing callback if it exists.
|
||||
if (currentMsgCallback) {
|
||||
unsetMessageCallback(currentMsgCallback);
|
||||
currentMsgCallback = null;
|
||||
}
|
||||
|
||||
if (!callback) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind the callback. A reference to the callback is stored for ease of
|
||||
// unbinding.
|
||||
currentMsgCallback = setMessageCallback(function(e) {
|
||||
switch(Object.prototype.toString.call(sourceOrigin)) {
|
||||
case '[object String]':
|
||||
if (sourceOrigin !== e.origin) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case '[object Function]':
|
||||
if (sourceOrigin(e.origin)) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
callback(e);
|
||||
});
|
||||
};
|
||||
|
||||
} else {
|
||||
|
||||
this[postBinding] = function(message, targetUrl, target) {
|
||||
if (!targetUrl) {
|
||||
return;
|
||||
}
|
||||
|
||||
// The browser does not support window.postMessage, so set the location
|
||||
// of the target to targetUrl#message. A bit ugly, but it works! A cache
|
||||
// bust parameter is added to ensure that repeat messages trigger the
|
||||
// callback.
|
||||
target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
|
||||
}
|
||||
|
||||
// Since the browser sucks, a polling loop will be started, and the
|
||||
// callback will be called whenever the location.hash changes.
|
||||
this[receiveBinding] = function(callback, sourceOrigin, delay) {
|
||||
if (intervalId) {
|
||||
clearInterval(intervalId);
|
||||
intervalId = null;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
delay = typeof sourceOrigin === 'number'
|
||||
? sourceOrigin
|
||||
: typeof delay === 'number'
|
||||
? delay
|
||||
: 100;
|
||||
|
||||
intervalId = setInterval(function(){
|
||||
var hash = document.location.hash,
|
||||
re = /^#?\d+&/;
|
||||
if ( hash !== lastHash && re.test( hash ) ) {
|
||||
lastHash = hash;
|
||||
callback({ data: hash.replace( re, '' ) });
|
||||
}
|
||||
}, delay );
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
12
wp-content/plugins/easy-post-views-count/freemius/assets/js/nojquery.ba-postmessage.min.js
vendored
Normal file
12
wp-content/plugins/easy-post-views-count/freemius/assets/js/nojquery.ba-postmessage.min.js
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
/*
|
||||
* nojquery-postmessage by Jeff Lee
|
||||
* a non-jQuery fork of:
|
||||
*
|
||||
* jQuery postMessage - v0.5 - 9/11/2009
|
||||
* http://benalman.com/projects/jquery-postmessage-plugin/
|
||||
*
|
||||
* Copyright (c) 2009 "Cowboy" Ben Alman
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* http://benalman.com/about/license/
|
||||
*/
|
||||
function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
|
@ -0,0 +1,135 @@
|
||||
(function ($, undef) {
|
||||
var global = this;
|
||||
|
||||
// Namespace.
|
||||
global.FS = global.FS || {};
|
||||
|
||||
global.FS.PostMessage = function ()
|
||||
{
|
||||
var
|
||||
_is_child = false,
|
||||
_postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
|
||||
_callbacks = {},
|
||||
_base_url,
|
||||
_parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
|
||||
_parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
|
||||
_init = function () {
|
||||
_postman.receiveMessage(function (e) {
|
||||
var data = JSON.parse(e.data);
|
||||
|
||||
if (_callbacks[data.type]) {
|
||||
for (var i = 0; i < _callbacks[data.type].length; i++) {
|
||||
// Execute type callbacks.
|
||||
_callbacks[data.type][i](data.data);
|
||||
}
|
||||
}
|
||||
}, _base_url);
|
||||
},
|
||||
_hasParent = ('' !== _parent_url),
|
||||
$window = $(window),
|
||||
$html = $('html');
|
||||
|
||||
return {
|
||||
init : function (url, iframes)
|
||||
{
|
||||
_base_url = url;
|
||||
_init();
|
||||
|
||||
// Automatically receive forward messages.
|
||||
FS.PostMessage.receiveOnce('forward', function (data){
|
||||
window.location = data.url;
|
||||
});
|
||||
|
||||
iframes = iframes || [];
|
||||
|
||||
if (iframes.length > 0) {
|
||||
$window.on('scroll', function () {
|
||||
for (var i = 0; i < iframes.length; i++) {
|
||||
FS.PostMessage.postScroll(iframes[i]);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
init_child : function ()
|
||||
{
|
||||
this.init(_parent_subdomain);
|
||||
|
||||
_is_child = true;
|
||||
|
||||
// Post height of a child right after window is loaded.
|
||||
$(window).bind('load', function () {
|
||||
FS.PostMessage.postHeight();
|
||||
|
||||
// Post message that window was loaded.
|
||||
FS.PostMessage.post('loaded');
|
||||
});
|
||||
},
|
||||
hasParent : function ()
|
||||
{
|
||||
return _hasParent;
|
||||
},
|
||||
postHeight : function (diff, wrapper) {
|
||||
diff = diff || 0;
|
||||
wrapper = wrapper || '#wrap_section';
|
||||
this.post('height', {
|
||||
height: diff + $(wrapper).outerHeight(true)
|
||||
});
|
||||
},
|
||||
postScroll : function (iframe) {
|
||||
this.post('scroll', {
|
||||
top: $window.scrollTop(),
|
||||
height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
|
||||
}, iframe);
|
||||
},
|
||||
post : function (type, data, iframe)
|
||||
{
|
||||
console.debug('PostMessage.post', type);
|
||||
|
||||
if (iframe)
|
||||
{
|
||||
// Post to iframe.
|
||||
_postman.postMessage(JSON.stringify({
|
||||
type: type,
|
||||
data: data
|
||||
}), iframe.src, iframe.contentWindow);
|
||||
}
|
||||
else {
|
||||
// Post to parent.
|
||||
_postman.postMessage(JSON.stringify({
|
||||
type: type,
|
||||
data: data
|
||||
}), _parent_url, window.parent);
|
||||
}
|
||||
},
|
||||
receive: function (type, callback)
|
||||
{
|
||||
console.debug('PostMessage.receive', type);
|
||||
|
||||
if (undef === _callbacks[type])
|
||||
_callbacks[type] = [];
|
||||
|
||||
_callbacks[type].push(callback);
|
||||
},
|
||||
receiveOnce: function (type, callback)
|
||||
{
|
||||
if (this.is_set(type))
|
||||
return;
|
||||
|
||||
this.receive(type, callback);
|
||||
},
|
||||
// Check if any callbacks assigned to a specified message type.
|
||||
is_set: function (type)
|
||||
{
|
||||
return (undef != _callbacks[type]);
|
||||
},
|
||||
parent_url: function ()
|
||||
{
|
||||
return _parent_url;
|
||||
},
|
||||
parent_subdomain: function ()
|
||||
{
|
||||
return _parent_subdomain;
|
||||
}
|
||||
};
|
||||
}();
|
||||
})(jQuery);
|
Reference in New Issue
Block a user