");
}
/**
* turn object to escape html string
*/
this.objectToEscepeHtmlString = function(obj){
if(typeof obj != "object")
return(obj);
var str = JSON.stringify(obj);
str = t.htmlspecialchars(str);
return(str);
};
/**
* escape html, turn html to a string
*/
this.htmlspecialchars = function(string){
if(!string)
return(string);
return string
.replace(/&/g, "&")
.replace(//g, ">")
.replace(/"/g, """)
.replace(/'/g, "'");
};
/**
* escape double slash
*/
this.escapeDoubleQuote = function(str){
if(!str)
return(str);
return str.replace('"','\"');
};
/**
* capitalize first letter
*/
this.capitalizeFirstLetter = function(str){
str = str.substr(0, 1).toUpperCase() + str.substr(1).toLowerCase();
return(str);
};
/**
* get transparency value from 0 to 100
*/
this.getTransparencyFromRgba = function(rgba, inPercent){
var temp = rgba.split(',');
if(temp.length == 4){
inPercent = (typeof inPercent !== 'undefined') ? inPercent : true;
return (inPercent) ? temp[3].replace(/[^\d.]/g, "") : temp[3].replace(/[^\d.]/g, "") * 100;
}
return false;
};
/**
* add px or leave % if needed
*/
this.normalizeSizeValue = function(strValue){
strValue = String(strValue);
strValue.toLowerCase();
if(jQuery.isNumeric(strValue))
strValue += "px";
return(strValue);
};
/**
* remove line breaks and tabs
*/
this.removeLineBreaks = function(str, replaceSign){
if(!replaceSign)
var replaceSign = "";
str.replace(/\s+/g, replaceSign);
return(str);
};
/**
* remove amp from string
*/
this.convertAmpSign = function(str){
var str = str.replace(/&/g, '&');
return(str);
};
/**
* filter object, leave child items by keys
*/
this.filterObjectByKeys = function(obj, arrKeys){
if(typeof obj != "object")
return(obj);
if(jQuery.isArray(arrKeys) == false)
throw new Error("filterObjectByKeys error - arrKeys should be array");
var outputObj = {};
jQuery.each(arrKeys, function(index, key){
if(obj.hasOwnProperty(key))
outputObj[key] = obj[key];
});
return(outputObj);
};
this.__________PATHS_AND_URLS_____ = function(){};
/**
* get base name from path
*/
this.pathinfo = function(path) {
var obj = {};
if(typeof path == "object"){
trace(path);
throw new Error("pathinfo error: path is object");
}
obj.basename = path.replace(/\\/g,'/').replace(/.*\//, '');
obj.filename = obj.basename.substr(0,obj.basename.lastIndexOf('.'));
return(obj);
}
/**
* strip path slashes from both sides
*/
this.stripPathSlashes = function(path){
return path.replace(/^\/|\/$/g, '');
};
/**
* convert to full url
*/
this.urlToFull = function(url, urlBase){
if(!url)
return(url);
if(!urlBase)
var urlBase = g_urlBaseUC;
//try to convert assets path from provider
url = g_providerAdmin.urlAssetsToFull(url);
if(!url)
return("");
if(typeof url == "number")
url = String(url);
if(typeof url != "string"){
trace(url);
throw new Error("url should be a string type");
}
var urlSmall = url.toLowerCase();
if(urlSmall.indexOf("http://") !== -1 || urlSmall.indexOf("https://") !== -1)
return(url);
if(url.indexOf(urlBase) !== -1)
return(url);
url = jQuery.trim(url);
if(!url || url == "")
return("");
url = urlBase + url;
return(url);
}
/**
* convert to relative url
*/
this.urlToRelative = function(url, urlBase){
if(!urlBase)
var urlBase = g_urlBaseUC;
url = url.replace(urlBase, "");
return(url);
};
/**
* get url of some view
*/
this.getUrlView = function(view, options, isNoWindow){
var urlBase = g_urlViewBaseUC;
if(isNoWindow === true)
urlBase = g_urlViewBaseNowindowUC;
var url = t.addUrlParam(urlBase, "view", view);
if(options && options != ""){
//make url from object
if(typeof(options) == "object"){
jQuery.each(options, function(key, value){
if(typeof value == "object"){
value = JSON.stringify(value);
value = t.encodeContent(value);
}
url += "&"+key+"="+value;
});
}
else
url += "&"+options;
}
return(url);
};
/**
* get current view url
*/
this.getUrlCurrentView = function(options){
var url = g_urlViewBaseUC+"&view=" + g_view;
if(options)
url += "&"+options;
return(url);
};
this.__________VALIDATION_FUNCTIONS_____ = function(){};
/**
* validate that object has some element name
*/
this.validateObjProperty = function(obj, propertyName, objName){
if(typeof obj != "object")
throw new Error("The object is empty (with property: " + elementName);
if(typeof propertyName == "object"){
jQuery(propertyName).each(function(index, pname){
t.validateObjProperty(obj, pname, objName);
});
return(false);
}
if(obj.hasOwnProperty(propertyName) == false){
trace(obj);
if(!objName)
objName = "";
throw new Error("The "+objName+" object should has property: " + propertyName);
}
};
/**
* validate that the dom object exists
* the obj has to be jquery object of don element
*/
this.validateDomElement = function(obj, objName){
if(typeof obj != "object"){
trace(obj);
trace(typeof obj);
console.trace();
throw new Error("The object: "+objName+" not inited well");
}
if(obj.length == 0)
throw new Error(objName+" not found!");
};
/**
* validate that field not empty
*/
this.validateNotEmpty = function(val, fieldName){
if(typeof val == "undefined" || jQuery.trim(val) == "")
throw new Error("Please fill "+ fieldName + " field");
};
/**
* validate that some value is object
*/
this.validateIsObject = function(val, fieldName){
if(typeof val !== "object")
throw new Error("The field must be object: "+fieldName);
};
/**
* validate name field
*/
this.validateNameField = function(val, fieldName){
var errorMessage = "The field "+ fieldName + " allow only english lowercase letters, numbers and underscore. Example: first_name ";
var regex = /^[a-z0-9_]+$/;
if(regex.test(val) == false)
throw new Error(errorMessage);
}
this._____________DIALOGS__________ = function(){};
/**
* get custom dialog (position absolute div) offset relative to the button
*/
this.getCustomDialogOffset = function(objDialog, objButton){
var extraY = 0;
var dpWidth = objDialog.outerWidth();
var dpHeight = objDialog.outerHeight();
var inputHeight = objButton.outerHeight();
var doc = objDialog[0].ownerDocument;
var docElem = doc.documentElement;
var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
var viewHeight = docElem.clientHeight + $(doc).scrollTop();
var offset = objButton.offset();
offset.top += inputHeight;
offset.left -=
Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
Math.abs(offset.left + dpWidth - viewWidth) : 0);
offset.top -=
Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
Math.abs(dpHeight + inputHeight - extraY) : extraY));
return offset;
}
/**
* set image browser dialog path
*/
this.setAddImagePath = function(path, url){
if(typeof g_providerAdmin.setPathSelectImages == "function")
g_providerAdmin.setPathSelectImages(path, path, url);
};
/**
* open "add image" dialog
*/
this.openAddImageDialog = function(title, onInsert, isMultiple, source){
g_providerAdmin.setParent(t); //for convert to relative
g_providerAdmin.openAddImageDialog(title, onInsert, isMultiple, source);
};
/**
* open "add image" dialog
*/
this.openAddMp3Dialog = function(title, onInsert, isMultiple, source){
g_providerAdmin.setParent(t); //for convert to relative
g_providerAdmin.openAddMp3Dialog(title, onInsert, isMultiple, source);
};
/**
* open "add image" dialog
*/
this.openAddPostDialog = function(title, onInsert, postType){
g_providerAdmin.setParent(t); //for convert to relative
g_providerAdmin.openSelectArticleDialog(title, onInsert, postType);
};
/**
* open video dialog
*/
this.openVideoDialog = function(callbackFunction, itemData){
g_ugMediaDialog.openVideoDialog(callbackFunction, itemData);
};
/**
* common dialog ajax request
*/
this.dialogAjaxRequest = function(dialogID, action, data, funcSuccess, params){
dialogID = dialogID.replace("#", "");
g_ucAdmin.setAjaxLoaderID(dialogID + "_loader");
g_ucAdmin.setErrorMessageID(dialogID + "_error");
g_ucAdmin.setSuccessMessageID(dialogID + "_success");
g_ucAdmin.setAjaxHideButtonID(dialogID + "_action");
var isNoClose = t.getVal(params, "noclose");
g_ucAdmin.ajaxRequest(action, data, function(response){
if(isNoClose !== true){
setTimeout(function(){
jQuery("#"+dialogID).dialog("close");
}, 500);
}
if(typeof(funcSuccess) == "function")
funcSuccess(response);
});
};
/**
* common dialog ajax request
*/
this.panelAjaxRequest = function(settingID, action, data, funcSuccess, params){
if(!params)
params = {};
params["noclose"] = true;
t.dialogAjaxRequest(settingID, action, data, funcSuccess, params);
};
/**
* get data from iframe dialog
*/
this.iframeDialogGetData = function(){
var iframeID = "unite-settings-dialog-iframe_iframe";
var objIframe = jQuery("#"+iframeID);
t.validateDomElement(objIframe, "Iframe object");
var contents = objIframe.contents();
if(!contents)
throw new Error("Can't reach iframe contents");
if(typeof contents[0].getIframeData != "function")
throw new Error("getIframeData function not found in document - document.getIframeData = function()");
var data = contents[0].getIframeData();
return(data);
};
/**
* open dialog with some view in iframe
* get content by id
*/
this.openIframeDialog = function(view, params, dialogOptions, onUpdateClick){
var dialogID = "unite-settings-dialog-iframe";
var iframeID = dialogID+"_iframe";
var objDialog = jQuery("#"+dialogID);
//add dialog if absent
if(objDialog.length == 0){
var htmlDialog = '';
htmlDialog += '';
htmlDialog += '
';
jQuery("body").append(htmlDialog);
objDialog = jQuery('#'+dialogID);
}
var objIframe = jQuery("#"+iframeID);
//put loader
var contents = objIframe.contents();
if(contents){
contents.find("html").html("Loading...");
}
//set url
var urlView = t.getUrlView(view, params, true);
objIframe.attr("src", urlView);
//open dialog
if(!dialogOptions)
dialogOptions = {};
if(onUpdateClick){
var buttons = {};
buttons[g_uctext["update"]] = function(){
var data = g_ucAdmin.iframeDialogGetData();
onUpdateClick(data, objDialog);
};
dialogOptions.buttons = buttons;
}
//onclose, null iframe
dialogOptions.close = function(){
/*
setTimeout(function(){
objIframe.attr("src", "");
}, 3000);
*/
};
dialogOptions.minWidth = 1100;
t.openCommonDialog(dialogID, null, dialogOptions);
};
/**
* open common dialog with all inside actions
*/
this.openCommonDialog = function(id, onOpen, options, closeOnEmptyClick){
if(typeof id == "object"){
var id = id.prop("id");
if(!id)
throw new Error("The dialog should have ID");
id = "#"+id;
}
if(id.charAt(0) != "#")
id = "#"+id;
if(jQuery(id).length == 0)
throw new Error("Dialog with ID: "+id + " don't exists!");
var buttonOpts = {};
var noClose = t.getVal(options, "no_close_button");
if(!noClose){
buttonOpts[g_uctext.close] = function(){
jQuery(id).dialog("close");
};
}
jQuery(id+"_loader").hide();
jQuery(id+"_error").hide();
jQuery(id+"_success").hide();
jQuery(id+"_action").show();
var dialogOptions = {
buttons:buttonOpts,
minWidth:600,
minHeight:300,
modal:true,
dialogClass:"unite-ui",
open:function(){
if(typeof onOpen == "function")
onOpen();
//set close on empty click events
if(closeOnEmptyClick === true){
var objDialogWrapper = jQuery(id).parents(".ui-dialog");
var objOverlay = objDialogWrapper.siblings(".ui-widget-overlay");
objOverlay.on("click",function(){
jQuery(id).dialog("close");
objOverlay.off("click");
});
}
}
};
if(options && typeof options == "object")
dialogOptions = jQuery.extend(dialogOptions, options);
jQuery(id).dialog(dialogOptions);
};
/**
* add button on the left.
* use it on create
*/
this.dialogAddLeftButton = function(objDialog, title, funcOnClick){
var objButtonPane = objDialog.closest(".ui-dialog").find(".ui-dialog-buttonpane");
var html = "";
html += "";
html += "
";
var objButtonset = jQuery(html);
objButtonPane.append(objButtonset);
var objButton = objButtonset.children("button");
if(typeof funcOnClick == "function")
objButton.on("click",funcOnClick);
return(objButton);
};
this.__________AJAX_REQUEST_____ = function(){};
/**
* show error message or call once custom handler function
*/
this.showErrorMessage = function(htmlError){
if(g_errorMessageID !== null){
switch(typeof g_errorMessageID){
case "object":
g_errorMessageID.show().html(htmlError);
break;
case "function":
g_errorMessageID(htmlError);
break;
default:
jQuery("#"+g_errorMessageID).show().html(htmlError);
break;
}
}else
jQuery("#error_message").show().html(htmlError);
showAjaxButton();
};
/**
* hide error message
*/
function hideErrorMessage(){
if(g_errorMessageID !== null){
switch(typeof g_errorMessageID){
case "object":
g_errorMessageID.hide();
break;
case "string":
jQuery("#"+g_errorMessageID).hide();
break;
case "function":
if(typeof g_errorMessageHideFunc == "function")
g_errorMessageHideFunc();
break;
}
if(g_hideMessageCounter > 0){
g_hideMessageCounter = 0;
g_errorMessageID = null;
g_errorMessageHideFunc = null;
}else
g_hideMessageCounter++;
}else
jQuery("#error_message").hide();
};
/**
* set error message id
*/
this.setErrorMessageID = function(id){
g_errorMessageID = id;
g_hideMessageCounter = 0;
};
/**
* set hide error func
*/
this.setErrorMessageOnHide = function(func){
g_errorMessageHideFunc = func;
}
/**
* set success message id
*/
this.setSuccessMessageID = function(id){
g_successMessageID = id;
};
/**
* show success message
*/
this.showSuccessMessage = function(htmlSuccess){
var id = "#success_message";
var delay = 2000;
if(g_successMessageID){
id = "#"+g_successMessageID;
delay = 500;
}
if (htmlSuccess !== 'Layout Updated'){
jQuery(id).show().html(htmlSuccess);
} else {
var content ='' + 'Saved Successfully' + '';
jQuery(id).show().html(content);
}
setTimeout(t.hideSuccessMessage,delay);
};
/**
* hide success message
*/
this.hideSuccessMessage = function(){
if(g_successMessageID){
jQuery("#"+g_successMessageID).hide();
g_successMessageID = null; //can be used only once.
}
else
jQuery("#success_message").slideUp("slow").fadeOut("slow");
showAjaxButton();
};
/**
* set ajax loader id that will be shown, and hidden on ajax request
* this loader will be shown only once, and then need to be sent again.
*/
this.setAjaxLoaderID = function (id) {
g_ajaxLoaderID = id;
};
/**
* show loader on ajax actions
*/
var showAjaxLoader = function () {
if (!g_ajaxLoaderID)
return;
if (typeof (g_ajaxLoaderID) == "function")
g_ajaxLoaderID("show_loader");
else
jQuery("#" + g_ajaxLoaderID).show();
};
/**
* hide and remove ajax loader. next time has to be set again before "ajaxRequest" function.
*/
var hideAjaxLoader = function () {
if (!g_ajaxLoaderID)
return;
if (typeof g_ajaxLoaderID == "function") {
g_ajaxLoaderID("hide_loader");
} else {
jQuery("#" + g_ajaxLoaderID).hide();
g_ajaxLoaderID = null;
}
};
/**
* set ajax loading button id that will be disabled/enabled on ajax request
* this button will switch only once, and then need to be sent again.
*/
this.setAjaxLoadingButtonID = function (id) {
g_ajaxLoadingButtonID = id;
};
/**
* show loading button on ajax actions
*/
var showAjaxLoadingButton = function () {
if (!g_ajaxLoadingButtonID)
return;
var objButton = jQuery("#" + g_ajaxLoadingButtonID);
objButton
.prop("disabled", true)
.text(objButton.data("text-loading"));
};
/**
* hide and remove ajax loading button. next time has to be set again before "ajaxRequest" function.
*/
var hideAjaxLoadingButton = function () {
if (!g_ajaxLoadingButtonID)
return;
var objButton = jQuery("#" + g_ajaxLoadingButtonID);
objButton
.prop("disabled", false)
.text(objButton.data("text-default"));
g_ajaxLoadingButtonID = null;
};
/**
* set button to hide / show on ajax operations.
*/
this.setAjaxHideButtonID = function (buttonID) {
g_ajaxHideButtonID = buttonID;
};
/**
* if exist ajax button to hide, hide it.
*/
function hideAjaxButton() {
if (!g_ajaxHideButtonID)
return (false);
if (typeof g_ajaxHideButtonID == "function") {
g_ajaxHideButtonID("hide_button");
} else {
jQuery("#" + g_ajaxHideButtonID).hide();
}
}
/**
* if exist ajax button, show it, and remove the button id.
*/
function showAjaxButton() {
if (!g_ajaxHideButtonID)
return (false);
if (typeof g_ajaxHideButtonID == "function") {
g_ajaxHideButtonID("show_button");
} else {
jQuery("#" + g_ajaxHideButtonID).show();
g_ajaxHideButtonID = null;
}
}
/**
* add url param
*/
this.addUrlParam = function(url, param, value){
if(url.indexOf("?") == -1)
url += "?";
else
url += "&";
if(typeof value == "undefined")
url += param;
else
url += param + "=" + value;
return(url);
}
/**
* get ajax url with action and params
*/
this.getUrlAjax = function(action, params){
var url = g_urlAjaxActionsUC;
url = t.addUrlParam(url, "action", g_pluginNameUC+"_ajax_action");
if(typeof g_ucNonce == "string")
url = t.addUrlParam(url, "nonce", g_ucNonce);
if(action)
url = t.addUrlParam(url, "client_action", action);
if(params)
url = t.addUrlParam(url, params);
return(url);
}
/**
* add form files to data
*/
this.addFormFilesToData = function(formID, objData){
var objForm = jQuery("#"+formID);
if(objForm.length == 0)
throw new Error("form with ID: "+ formID + " not found");
var objFiles = objForm.find("input[type='file']");
if(objFiles.length == 0)
throw new Error("no file inputs found in form: " + formID);
jQuery.each(objFiles, function(index, objFile){
var fieldName = objFile.name;
jQuery.each(objFile.files, function(index2, file){
objData.append(fieldName, file);
});
});
}
/**
* check ajax return
*/
this.ajaxReturnCheck = function(response, successFunction){
if(!response){
t.showErrorMessage("Empty ajax response!");
return(false);
}
if(typeof response != "object"){
try{
response = jQuery.parseJSON(response);
}catch(e){
t.showErrorMessage("Ajax Error!!! not ajax response");
t.debug(response);
return(false);
}
}
if(response == -1){
t.showErrorMessage("ajax error!!!");
return(false);
}
if(response == 0){
t.showErrorMessage("ajax error, action: "+action+" not found");
return(false);
}
if(response.success == undefined){
t.showErrorMessage("The 'success' param is a must!");
return(false);
}
if(response.success == false){
t.showErrorMessage(response.message);
return(false);
}
//run a success event function
if(typeof successFunction == "function"){
//show success message only if custom id exists
if(response.message && g_successMessageID)
t.showSuccessMessage(response.message);
successFunction(response);
}
else{
if(response.message)
t.showSuccessMessage(response.message);
}
if(response.is_redirect)
location.href=response.redirect_url;
}
/**
* Ajax request function. call wp ajax, if error - print error message.
* if success, call "success function"
*/
this.ajaxRequest = function(action,data,successFunction){
if(typeof data == "undefined")
var data = {};
//raw mode - for including file uploads
var isRawMode = false;
if(typeof data.append == "function"){
isRawMode = true;
var objData = data;
objData.append("action", g_pluginNameUC+"_ajax_action");
objData.append("client_action", action);
if(typeof g_ucNonce == "string")
objData.append("nonce", g_ucNonce);
}else{
//simple mode
var objData = {
action:g_pluginNameUC+"_ajax_action",
client_action:action,
data:data
};
if(typeof g_ucNonce == "string")
objData.nonce = g_ucNonce;
}
hideErrorMessage();
showAjaxLoader();
showAjaxLoadingButton();
hideAjaxButton();
var ajaxOptions = {
type:"post",
url:g_urlAjaxActionsUC,
dataType: 'json',
data:objData,
success:function(response){
hideAjaxLoader();
hideAjaxLoadingButton();
t.ajaxReturnCheck(response, successFunction);
},
error:function(jqXHR, textStatus, errorThrown){
hideAjaxLoader();
hideAjaxLoadingButton();
var readyState = jqXHR.readyState;
var showError = true;
switch(textStatus){
case "parsererror":
case "error":
var responseText = jqXHR.responseText;
if(responseText !== undefined)
t.debug(jqXHR.responseText);
else{
if(readyState == 0)
showError = false;
}
break;
}
if(showError == true)
t.showErrorMessage("Ajax Error!!! " + textStatus);
}
}
//add some options for raw mode
if(isRawMode == true){
ajaxOptions.global = false;
ajaxOptions.processData = false;
ajaxOptions.contentType = false;
}
var request = jQuery.ajax(ajaxOptions);
return(request);
};//ajaxrequest
/**
* ajax request for creating thumb from image and get thumb url
* instead of the url can get image id as well
*/
this.requestThumbUrl = function(urlImage, imageID, callbackFunction){
var data = {
urlImage: urlImage,
imageID: imageID
};
t.ajaxRequest("get_thumb_url",data, function(response){
callbackFunction(response.urlThumb);
});
};
/**
* init version dialog
*/
function initVersionDialog() {
jQuery("#uc_version_link").on("click", function (event) {
event.preventDefault();
var objDialog = jQuery("#uc_dialog_version");
var buttonOpts = {};
buttonOpts[g_uctext.cancel] = function () {
objDialog.dialog("close");
};
objDialog.dialog({
dialogClass: "unite-ui",
buttons: buttonOpts,
minWidth: 900,
modal: true,
open: function () {
var objContent = jQuery("#uc_dialog_version_content");
var isContentLoaded = objContent.data("loaded");
if (isContentLoaded === true)
return;
t.ajaxRequest("get_version_text", {}, function (response) {
var html = "" + response.text + "
";
objContent.html(html);
objContent.data("loaded", true);
});
},
});
});
}
this.z_________TIMER_FUNCTIONS_______ = function(){}
/**
* start timer
*/
this.startTimer = function(){
g_temp.timer = jQuery.now();
};
/**
* print timer
*/
this.printTimer = function(){
var currentTime = jQuery.now();
if(!g_temp.timer){
trace("timer not started!");
return(false);
}
var diff = currentTime - g_temp.timer;
trace("time passed: "+diff);
};
/**
* print time stamp
*/
this.printTimeStamp = function(stamp){
if(!stamp)
var stamp = jQuery.now();
var date1 = new Date(stamp);
trace(date1);
}
this.z_________DATA_FUNCTIONS_______ = function(){};
/**
* set data value
*/
this.storeGlobalData = function(key, value){
key = "unite_data_"+key;
jQuery.data(document.body, key, value);
};
/**
* get global data
*/
this.getGlobalData = function(key){
key = "unite_data_"+key;
var value = jQuery.data(document.body, key);
return(value);
};
this.__________THIRD_PARTY_____ = function(){};
/**
* get settings of dropzone that turn it to single line
*/
this.getDropzoneSingleLineSettings = function(){
var htmlTemplate = '';
htmlTemplate += '
';
htmlTemplate += '
';
htmlTemplate += '
';
htmlTemplate += '
';
htmlTemplate += '
';
htmlTemplate += '
';
htmlTemplate += '
';
var settings = {
createImageThumbnails:false,
addRemoveLinks:true,
previewTemplate: htmlTemplate,
dictRemoveFile: "remove",
dictCancelUpload: "cancel"
//dictRemoveFile: ""
};
return(settings);
}
/**
* clear provider setting
*/
this.clearProviderSetting = function(type, objInput, dataname){
if(typeof g_providerAdmin.clearSetting != "function")
return(false);
var response = g_providerAdmin.clearSetting(type, objInput, dataname);
return(response);
}
/**
* set value of provider setting
*/
this.providerSettingSetValue = function(type, objInput, value){
if(typeof g_providerAdmin.setSettingValue != "function")
return(false);
var response = g_providerAdmin.setSettingValue(type, objInput, value);
return(response);
};
/**
* init provider settings
*/
this.initProviderSettingEvents = function(type, objInput){
if(typeof g_providerAdmin.initSettingEvents != "function")
return(true);
g_providerAdmin.initSettingEvents(type, objInput);
};
function ____________ACTIVATION____________(){};
/**
* actuvate pro init
*/
function activateProDialog() {
g_dialogActivation.dialog({
dialogClass:"uc-activation-dialog",
width:700,
height:500,
modal:true,
create:function () {
g_dialogActivation.find('.popup-close').on("click",function() {jQuery('.activateProDialog').dialog('close');});
},
open: function () {
g_dialogActivation.find('.uc-start').removeClass('hidden');
g_dialogActivation.find('.uc-fail').addClass('hidden');
g_dialogActivation.find('.uc-activated').addClass('hidden');
},
close: function () {
g_dialogActivation.find('.uc-start').addClass('hidden');
g_dialogActivation.find('.uc-fail').addClass('hidden');
g_dialogActivation.find('.uc-activated').addClass('hidden');
}
});
}
/**
* on activate pro button click
*/
function onActivateButtonClick(){
var objButton = jQuery(this);
var codeType = objButton.data("codetype");
var product = objButton.data("product");
var objCode = jQuery("#uc_activate_pro_code");
var code = "";
if(objCode.length){
code = jQuery("#uc_activate_pro_code").val();
code = jQuery.trim(code);
}
g_ucAdmin.setAjaxLoaderID("uc_loader_activate_pro");
g_ucAdmin.setAjaxHideButtonID("uc_button_activate_pro");
g_ucAdmin.setErrorMessageID(function(message){
g_dialogActivation.find('.uc-start').addClass('hidden');
g_dialogActivation.find('.uc-fail').removeClass('hidden');
g_dialogActivation.find('.popup-error').show().html(message);
});
var data = {};
data.code = code;
data.codetype = codeType;
if(product)
data.product = product;
g_ucAdmin.ajaxRequest("activate_product", data, function(response){
g_dialogActivation.find('.uc-start').addClass('hidden');
g_dialogActivation.find('.uc-fail').addClass('hidden');
g_dialogActivation.find('.uc-activated').removeClass('hidden');
var activateDays = response["expire_days"];
if(activateDays)
g_dialogActivation.find(".uc-activated .days").html(activateDays);
else
g_dialogActivation.find(".uc-activated .days").hide();
});
}
/**
* on try again click
*/
function onActivateTryAgainClick(){
g_dialogActivation.find('.uc-start').removeClass('hidden');
g_dialogActivation.find('.uc-fail').addClass('hidden');
g_dialogActivation.find('.uc-activated').addClass('hidden');
jQuery("#uc_activate_pro_code").focus();
}
/**
* on deactivate click
*/
function onDeactivateProductClick(){
var objButton = jQuery(this);
var product = objButton.data("product");
g_ucAdmin.setErrorMessageID(function(message){
alert("Error: "+message);
});
var data = {};
if(product)
data["product"] = product;
g_ucAdmin.ajaxRequest("deactivate_product", data, function(response){
confirm(response.message);
});
}
/**
* init activation dialog
*/
this.initActivationDialog = function(){
g_dialogActivation = jQuery('.activateProDialog');
if(g_dialogActivation.length == 0)
g_dialogActivation = jQuery(".uc-activation-view");
if(g_dialogActivation.length){
jQuery(".uc-link-activate-pro").on("click",activateProDialog);
jQuery("#uc_button_activate_pro").on("click",onActivateButtonClick);
jQuery("#activation_link_try_again").on("click",onActivateTryAgainClick);
}
jQuery(".uc-link-deactivate").on("click",onDeactivateProductClick);
};
this.__________CHECK_CATALOG_____ = function(){};
/**
* handle catalog check
*/
function handleCheckCatalog(){
//don't check inside iframe
if(window.top != window)
return(false);
if(typeof g_ucCheckCatalog === "undefined")
return(false);
if(g_ucCheckCatalog !== true)
return(false);
//don't show error on page refresh
t.setErrorMessageID(function(){});
var data = {};
if(g_ucCatalogAddonType)
data["addontype"] = g_ucCatalogAddonType;
setTimeout(function(){
t.ajaxRequest("check_catalog", data, function(response){});
}, 5000);
}
this.__________GLOBAL_INIT_____ = function(){};
/**
* init svg shape picker setting
*/
function initSettingShapesPicker(){
if(typeof g_ucArrSvgShapes == "undefined")
return(false);
if(typeof UniteSettingsUC == "undefined")
return(false);
var objSettings = new UniteSettingsUC();
var template = "";
var params = {};
params["add_new"] = true;
params["add_new_button_text"] = "Add Shape";
params["add_new_action"] = "add_shape_addon";
objSettings.iconPicker_addIconsType("shape", g_ucArrSvgShapes, template, params);
var urlShapes = t.getUrlAjax("get_shapes_css");
t.loadIncludeFile("css", urlShapes);
}
/**
* fix focus on select2 inside jquery ui dialog
*/
this.fixModalDialogSelect2 = function(){
if(window.hasOwnProperty("fixModalDialogSelect2_run") == true)
return(false);
window.fixModalDialogSelect2_run = true;
jQuery.ui.dialog.prototype._allowInteraction = function(e) {
return(true);
};
}
/**
* global init
*/
this.globalInit = function(){
g_providerAdmin.setParent(t);
g_providerAdmin.init();
if(typeof g_ugMediaDialog != "undefined")
g_ugMediaDialog.init();
initVersionDialog();
handleCheckCatalog();
initSettingShapesPicker();
};
}
if(!g_ucAdmin)
var g_ucAdmin;
//user functions:
function trace(data,clear){
if(!g_ucAdmin)
g_ucAdmin = new UniteAdminUC();
g_ucAdmin.trace(data,clear);
}
function clearTrace(){
console.clear();
}
function debug(data){
if(!g_ucAdmin)
g_ucAdmin = new UniteAdminUC();
g_ucAdmin.debug(data);
}
/**
* debug line by line
*/
function debugLine(data){
data += " "+Math.random();
var html = jQuery("#div_debug").html();
html += "
";
html += data;
jQuery("#div_debug").show().html(html);
}
//run the init function
jQuery(document).ready(function(){
if(!g_ucAdmin)
g_ucAdmin = new UniteAdminUC();
g_ucAdmin.globalInit();
});