Initial commit

This commit is contained in:
Almira Krdzic
2018-08-06 15:18:02 +02:00
commit d86f748bc6
363 changed files with 130876 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
<?php
//Nothing to see here

View File

@@ -0,0 +1,55 @@
(function (gflocking, $) {
var objectType;
$(document).ready(function () {
objectType = gflockingVars.objectType;
gflocking.init();
});
gflocking.init = function () {
initHeartbeat();
};
function initHeartbeat() {
var checkLocksKey = 'gform-check-locked-objects-' + objectType;
wp.heartbeat.interval( 30 );
$(document).on('heartbeat-tick.' + checkLocksKey,function (e, data) {
var locked = data[checkLocksKey] || {};
$('.gf-locking').each(function (i, el) {
var id , $row = $(el), lock_data, avatar;
id = $row.data("id");
if (locked.hasOwnProperty(id)) {
if (!$row.hasClass('wp-locked')) {
lock_data = locked[id];
$row.find('.locked-text').text(lock_data.text);
$row.find('.check-column input[type=checkbox]').prop('checked', false);
if (lock_data.avatar_src) {
avatar = $('<img class="avatar avatar-18 photo" width="18" height="18" />').attr('src', lock_data.avatar_src.replace(/&amp;/g, '&'));
$row.find('.locked-avatar').empty().append(avatar);
}
$row.addClass('wp-locked');
}
} else if ($row.hasClass('wp-locked')) {
$row.removeClass('wp-locked').delay(1000).find('.locked-info span').empty();
}
});
}).on('heartbeat-send.' + checkLocksKey, function (e, data) {
var check = [];
$('.gf-locking').each(function (i, row) {
check.push($(row).data("id"));
});
if (check.length)
data[checkLocksKey] = check;
});
}
}(window.gflocking = window.gflocking || {}, jQuery));

View File

@@ -0,0 +1 @@
!function(a,b){function c(){var a="gform-check-locked-objects-"+d;wp.heartbeat.interval(30),b(document).on("heartbeat-tick."+a,function(c,d){var e=d[a]||{};b(".gf-locking").each(function(a,c){var d,f,g,h=b(c);d=h.data("id"),e.hasOwnProperty(d)?h.hasClass("wp-locked")||(f=e[d],h.find(".locked-text").text(f.text),h.find(".check-column input[type=checkbox]").prop("checked",!1),f.avatar_src&&(g=b('<img class="avatar avatar-18 photo" width="18" height="18" />').attr("src",f.avatar_src.replace(/&amp;/g,"&")),h.find(".locked-avatar").empty().append(g)),h.addClass("wp-locked")):h.hasClass("wp-locked")&&h.removeClass("wp-locked").delay(1e3).find(".locked-info span").empty()})}).on("heartbeat-send."+a,function(c,d){var e=[];b(".gf-locking").each(function(a,c){e.push(b(c).data("id"))}),e.length&&(d[a]=e)})}var d;b(document).ready(function(){d=gflockingVars.objectType,a.init()}),a.init=function(){c()}}(window.gflocking=window.gflocking||{},jQuery);

View File

@@ -0,0 +1,42 @@
(function (gflocking, $) {
var objectID, objectType;
$(document).ready( function() {
objectID = gflockingVars.objectID;
objectType = gflockingVars.objectType;
gflocking.init();
});
gflocking.init = function () {
initHeartbeat();
};
function initHeartbeat() {
wp.heartbeat.interval( 30 );
var checkLocksKey = 'gform-check-locked-objects-' + objectType;
$( document ).on( 'heartbeat-tick.' + checkLocksKey, function( e, data ) {
var locked = data[checkLocksKey] || {};
if ( locked.hasOwnProperty( objectID ) ) {
var lock_data = locked[objectID];
$('.locked-text').text( lock_data.text );
if ( lock_data.avatar_src ) {
var avatar = $('<img class="avatar avatar-18 photo" width="18" height="18" />').attr( 'src', lock_data.avatar_src.replace(/&amp;/g, '&') );
$('.locked-avatar').empty().append( avatar );
}
} else {
$(".locked-info span").empty();
}
}).on( 'heartbeat-send.' + checkLocksKey, function( e, data ) {
var check = [];
check.push( objectID);
data[checkLocksKey] = check;
});
}
}(window.gflocking = window.gflocking || {}, jQuery));

View File

@@ -0,0 +1 @@
!function(a,b){function c(){wp.heartbeat.interval(30);var a="gform-check-locked-objects-"+e;b(document).on("heartbeat-tick."+a,function(c,e){var f=e[a]||{};if(f.hasOwnProperty(d)){var g=f[d];if(b(".locked-text").text(g.text),g.avatar_src){var h=b('<img class="avatar avatar-18 photo" width="18" height="18" />').attr("src",g.avatar_src.replace(/&amp;/g,"&"));b(".locked-avatar").empty().append(h)}}else b(".locked-info span").empty()}).on("heartbeat-send."+a,function(b,c){var e=[];e.push(d),c[a]=e})}var d,e;b(document).ready(function(){d=gflockingVars.objectID,e=gflockingVars.objectType,a.init()}),a.init=function(){c()}}(window.gflocking=window.gflocking||{},jQuery);

View File

@@ -0,0 +1,192 @@
(function (gflocking, $) {
$(document).ready(function () {
gflocking.init();
});
var objectID, objectType, strings, hasLock, lockUI, rejectionCountdown, rejectionRequestTimeout, lockRequestInProgress = false;
gflocking.init = function () {
hasLock = gflockingVars.hasLock;
objectID = gflockingVars.objectID;
objectType = gflockingVars.objectType;
lockUI = gflockingVars.lockUI;
strings = gflockingVars.strings;
initHeartbeat();
initUI();
};
function lock_request_timedout() {
$("#gform-lock-request-status").html(strings.noResponse);
$("#gform-lock-request-button").attr("disabled", false).text(strings.requestAgain);
lockRequestInProgress = false;
rejectionRequestTimeout = true;
rejectionCountdown = false;
wp.heartbeat.interval( 30 );
}
function initUI() {
$("#gform-lock-request-button").click(function () {
var $this = $(this), key;
$this.text("Request sent");
$this.attr("disabled", true);
$("#gform-lock-request-status").html("");
rejectionRequestTimeout = false;
lockRequestInProgress = true;
wp.heartbeat.interval( 5 );
rejectionCountdown = setTimeout(lock_request_timedout, 120000);
$.getJSON(ajaxurl, { action: "gf_lock_request_" + objectType, object_id: objectID })
.done(function (json) {
$("#gform-lock-request-status").html(json.html);
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + ', ' + error;
$("#gform-lock-request-status").html(strings.requestError + ": " + err);
});
});
$("#gform-reject-lock-request-button").click(function () {
$.getJSON(ajaxurl, { action: "gf_reject_lock_request_" + objectType, object_id: objectID, object_type: objectType })
.done(function (json) {
$('#gform-lock-dialog').hide();
})
.fail(function (jqxhr, textStatus, error) {
var err = textStatus + ', ' + error;
$("#gform-lock-request-status").html(strings.requestError + ": " + err);
$('#gform-lock-dialog').hide();
});
});
}
function initHeartbeat() {
wp.heartbeat.interval( 30 );
$("#wpfooter").append(lockUI);
// todo: refresh nonces
var refreshLockKey = 'gform-refresh-lock-' + objectType;
var requestLockKey = 'gform-request-lock-' + objectType;
$(document).on('heartbeat-send.' + refreshLockKey, function (e, data) {
var send = {};
if (!objectID || !$('#gform-lock-dialog').length)
return;
if (hasLock == 0)
return;
send['objectID'] = objectID;
data[refreshLockKey] = send;
});
$(document).on('heartbeat-send.' + requestLockKey, function (e, data) {
var send = {};
if (!lockRequestInProgress)
return data;
send['objectID'] = objectID;
data[requestLockKey] = send;
});
// update the lock or show the dialog if somebody has taken over editing
$(document).on('heartbeat-tick.' + refreshLockKey, function (e, data) {
var received, wrap, avatar, details;
if (data[refreshLockKey]) {
received = data[refreshLockKey];
if (received.lock_error || received.lock_request) {
details = received.lock_error ? received.lock_error : received.lock_request;
wrap = $('#gform-lock-dialog');
if (!wrap.length)
return;
if (!wrap.is(':visible')) {
if (details.avatar_src) {
avatar = $('<img class="avatar avatar-64 photo" width="64" height="64" />').attr('src', details.avatar_src.replace(/&amp;/g, '&'));
wrap.find('div.gform-locked-avatar').empty().append(avatar);
}
wrap.show().find('.currently-editing').text(details.text);
if (received.lock_request) {
$("#gform-reject-lock-request-button").show();
} else {
$("#gform-reject-lock-request-button").hide();
}
wrap.find('.wp-tab-first').focus();
} else {
// dialog is already visible so the context is different
if (received.lock_error) {
if ($("#gform-reject-lock-request-button").is(":visible")) {
if (received.lock_error.avatar_src) {
avatar = $('<img class="avatar avatar-64 photo" width="64" height="64" />').attr('src', received.lock_error.avatar_src.replace(/&amp;/g, '&'));
wrap.find('div.gform-locked-avatar').empty().append(avatar);
}
$("#gform-reject-lock-request-button").hide();
wrap.show().find('.currently-editing').text(received.lock_error.text);
}
} else if (received.lock_request) {
$("#gform-lock-request-status").html(received.lock_request.text);
}
}
}
}
});
$(document).on('heartbeat-tick.' + requestLockKey, function (e, data) {
var received, wrap, status;
if (data[requestLockKey]) {
received = data[requestLockKey];
if (received.status) {
status = received.status;
wrap = $('#gform-lock-dialog');
if (!wrap.length)
return;
if (status != 'pending') {
clearTimeout(rejectionCountdown);
rejectionCountdown = false;
lockRequestInProgress = false
}
switch (status) {
case "granted" :
$("#gform-lock-request-status").html(strings.gainedControl);
$("#gform-take-over-button").show();
$("#gform-lock-request-button").hide();
hasLock = true;
break;
case "deleted" :
$("#gform-lock-request-button").text(strings.requestAgain).attr("disabled", false);
$("#gform-lock-request-status").html(strings.rejected);
break;
case "pending" :
$("#gform-lock-request-status").html(strings.pending);
}
}
}
});
}
}(window.gflocking = window.gflocking || {}, jQuery));

1
includes/locking/js/locking.min.js vendored Normal file
View File

@@ -0,0 +1 @@
!function(a,b){function c(){b("#gform-lock-request-status").html(h.noResponse),b("#gform-lock-request-button").attr("disabled",!1).text(h.requestAgain),m=!1,l=!0,k=!1,wp.heartbeat.interval(30)}function d(){b("#gform-lock-request-button").click(function(){var a=b(this);a.text("Request sent"),a.attr("disabled",!0),b("#gform-lock-request-status").html(""),l=!1,m=!0,wp.heartbeat.interval(5),k=setTimeout(c,12e4),b.getJSON(ajaxurl,{action:"gf_lock_request_"+g,object_id:f}).done(function(a){b("#gform-lock-request-status").html(a.html)}).fail(function(a,c,d){var e=c+", "+d;b("#gform-lock-request-status").html(h.requestError+": "+e)})}),b("#gform-reject-lock-request-button").click(function(){b.getJSON(ajaxurl,{action:"gf_reject_lock_request_"+g,object_id:f,object_type:g}).done(function(a){b("#gform-lock-dialog").hide()}).fail(function(a,c,d){var e=c+", "+d;b("#gform-lock-request-status").html(h.requestError+": "+e),b("#gform-lock-dialog").hide()})})}function e(){wp.heartbeat.interval(30),b("#wpfooter").append(j);var a="gform-refresh-lock-"+g,c="gform-request-lock-"+g;b(document).on("heartbeat-send."+a,function(c,d){var e={};f&&b("#gform-lock-dialog").length&&0!=i&&(e.objectID=f,d[a]=e)}),b(document).on("heartbeat-send."+c,function(a,b){var d={};if(!m)return b;d.objectID=f,b[c]=d}),b(document).on("heartbeat-tick."+a,function(c,d){var e,f,g,h;if(d[a]&&(e=d[a],e.lock_error||e.lock_request)){if(h=e.lock_error?e.lock_error:e.lock_request,f=b("#gform-lock-dialog"),!f.length)return;f.is(":visible")?e.lock_error?b("#gform-reject-lock-request-button").is(":visible")&&(e.lock_error.avatar_src&&(g=b('<img class="avatar avatar-64 photo" width="64" height="64" />').attr("src",e.lock_error.avatar_src.replace(/&amp;/g,"&")),f.find("div.gform-locked-avatar").empty().append(g)),b("#gform-reject-lock-request-button").hide(),f.show().find(".currently-editing").text(e.lock_error.text)):e.lock_request&&b("#gform-lock-request-status").html(e.lock_request.text):(h.avatar_src&&(g=b('<img class="avatar avatar-64 photo" width="64" height="64" />').attr("src",h.avatar_src.replace(/&amp;/g,"&")),f.find("div.gform-locked-avatar").empty().append(g)),f.show().find(".currently-editing").text(h.text),e.lock_request?b("#gform-reject-lock-request-button").show():b("#gform-reject-lock-request-button").hide(),f.find(".wp-tab-first").focus())}}),b(document).on("heartbeat-tick."+c,function(a,d){var e,f,g;if(d[c]&&(e=d[c],e.status)){if(g=e.status,f=b("#gform-lock-dialog"),!f.length)return;switch("pending"!=g&&(clearTimeout(k),k=!1,m=!1),g){case"granted":b("#gform-lock-request-status").html(h.gainedControl),b("#gform-take-over-button").show(),b("#gform-lock-request-button").hide(),i=!0;break;case"deleted":b("#gform-lock-request-button").text(h.requestAgain).attr("disabled",!1),b("#gform-lock-request-status").html(h.rejected);break;case"pending":b("#gform-lock-request-status").html(h.pending)}}})}b(document).ready(function(){a.init()});var f,g,h,i,j,k,l,m=!1;a.init=function(){i=gflockingVars.hasLock,f=gflockingVars.objectID,g=gflockingVars.objectType,j=gflockingVars.lockUI,h=gflockingVars.strings,e(),d()}}(window.gflocking=window.gflocking||{},jQuery);