Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
META-INF.resources.m.pageactions.portofino.js Maven / Gradle / Ivy
//Ex elements.js
function updateSelectOptions(relName, selectionProviderIndex, methodName) {
var selectFieldId = arguments[3 + selectionProviderIndex];
var data = {
relName : relName,
selectionProviderIndex : selectionProviderIndex
};
data[methodName] = '';
for (var i = 3; i < arguments.length; i++ ) {
var currentId = arguments[i];
var current = $(currentId);
data[current.attr('name')] = current.val();
}
var selectField = $(selectFieldId);
var postUrl = stripQueryString(selectField.closest("form[action]").attr("action") || location.href);
jQuery.ajax({
type: 'POST',
url: postUrl,
data: data,
success: function(responseData) {
var options = responseData;
if('string' === typeof(options)) {
options = jQuery.parseJSON(options);
}
selectField.empty();
for (var i = 0; i < options.length; i++) {
var option = options[i];
var y = document.createElement('option');
y.value = option['v'];
y.text = option['l'];
y.selected = option['s'];
selectField.append(y)
}
selectField.change();
}
});
}
function setupAutocomplete(autocompleteId, relName, selectionProviderIndex, methodName) {
var setupArguments = arguments;
var selectFieldId = setupArguments[4 + selectionProviderIndex];
var autocompleteObj = $(autocompleteId);
var selectField = $(selectFieldId);
autocompleteObj.typeahead(
{
minLength: 1,
highlight: true,
hint: false
},
{
source: function( request, response ) {
var data = {
relName : relName,
selectionProviderIndex : selectionProviderIndex,
labelSearch : request
};
data[methodName] = '';
for (var i = 4; i < setupArguments.length; i++ ) {
var currentId = setupArguments[i];
var current = $(currentId);
data[current.attr('name')] = current.attr('value');
}
var postUrl = stripQueryString(autocompleteObj.closest("form[action]").attr("action") || location.href);
selectField.val(""); //Reset selected object when user types
$.ajax({
type: 'POST',
dataType: 'json',
url: postUrl,
data: data,
success: function( responseData ) {
response( $.map( responseData, function( item ) {
var obj = {
label: item.l,
value: item.l,
optionValue: item.v
};
obj.toString = function() {
return JSON.stringify(obj);
};
return obj;
}));
},
error: function(request, textStatus) {
alert(textStatus);
}
});
}
}).bind("typeahead:selected", function(obj, datum, name) {
if(datum && datum.optionValue) {
selectField.val(datum.optionValue);
} else {
selectField.val("");
}
});
}
function setupDatePicker(dateFieldId, dateFormat) {
if(dateFormat.indexOf("z") >= 0) {
if(console && console.debug) {
console.debug("'z' and 'zz' are unsupported in date/time patterns. Offending pattern: " + dateFormat);
}
return;
}
var dateField = $(dateFieldId);
var config = {
format: dateFormat.replace(/y/g, "Y").replace(/d/g, "D"),
useCurrent: false,
locale: portofino.locale };
dateField.datetimepicker(config);
//Propagate change event. Required e.g. for AngularJS to pick up the change.
dateField.on("dp.change", function() { $(dateField).change() });
}
function stripQueryString(url) {
var regexp = new RegExp("\\?.*");
return url.replace(regexp, "");
}
function setupRichTextEditors() {
$('textarea.mde-form-rich-text').each(function(index, element) {
element = $(element);
var conf = element.data('mdeRichTextConfig') || {
toolbar: 'Full',
toolbarCanCollapse: false
};
if(element.ckeditor) {
element.ckeditor(function() {
var elementId = element.attr("id");
var editor = this;
if(elementId) {
$("label[for=" + elementId + "]").click(function() {
editor.focus();
})
}
}, conf);
} else if(console && console.error) {
console.error("CKEditor not loaded! Make sure that ckeditor.js and adapters/jquery.js are included in your page.");
}
});
}
function setupSelectFieldLinks() {
$("a.mde-select-field-create-new-link").click(function(event) {
var href = $(event.target).attr("href");
var dialogDiv = $('
').appendTo($("body"));
function setupDialogContents(dialog) {
function submitForm(form, event, action) {
var data = form.serializeArray();
if(action) {
var datum = new Object();
datum.name = action;
datum.value = "";
data.push(datum);
}
$.ajax({
type: form.attr('method'),
url: form.attr('action'),
data: data
}).done(function(data) {
dialog.modal("hide");
dialogDiv.html(data);
var newDialog = dialogDiv.find("div.modal");
if(newDialog.length > 0) {
setupDialogContents(newDialog);
newDialog.modal({ backdrop: 'static', show: true });
}
}).fail(function() {
alert("Form submission failed!"); //TODO
});
event.preventDefault(); // Prevent the form from submitting via the browser.
}
dialog.find("form").submit(function(event) {
var form = $(this);
submitForm(form, event, form.find("button[type=submit]").first().attr("name"));
});
dialog.find("form button[type=submit]").click(function(event) {
var button = $(this);
submitForm(button.closest("form"), event, button.attr("name"));
});
dialog.find(".modal-header button.close").click(function() {
dialog.modal("hide");
dialogDiv.remove();
});
}
dialogDiv.load(href, function() {
var dialog = $(this).find("div.modal");
setupDialogContents(dialog);
dialog.modal({ backdrop: 'static', show: true });
});
return false;
});
}
function configureBulkEditTextField(id, checkboxName) {
$("#" + id).keypress(function(event) {
var keyCode = event.keyCode || event.which;
if(keyCode != 9) { //9 = Tab
$("input[name=" + checkboxName + "]").prop("checked", true);
}
});
}
function configureBulkEditDateField(id, checkboxName) {
configureBulkEditTextField(id, checkboxName);
$("#" + id).on("dp.change", function() {
if($(this).val()) {
$("input[name=" + checkboxName + "]").prop("checked", true);
}
});
}
function configureBulkEditField(id, checkboxName) {
$("#" + id).change(function() {
if($(this).val()) {
$("input[name=" + checkboxName + "]").prop("checked", true);
}
});
}
var portofino = portofino || {};
portofino._setupRichTextEditors = setupRichTextEditors;
portofino.contextPath = '';
portofino.setupRichTextEditors = function(config) {
config = config || {};
var windowWidth, windowHeight;
if (window.innerWidth && window.innerHeight) {
windowWidth = window.innerWidth;
windowHeight = window.innerHeight;
} else if (document.compatMode=='CSS1Compat' &&
document.documentElement &&
document.documentElement.offsetWidth ) {
windowWidth = document.documentElement.offsetWidth;
windowHeight = document.documentElement.offsetHeight;
} else if (document.body && document.body.offsetWidth) {
windowWidth = document.body.offsetWidth;
windowHeight = document.body.offsetHeight;
}
var baseConfig = {};
if(windowHeight) {
baseConfig.height =
windowHeight -
$("textarea.mde-form-rich-text").offset().top -
$("footer").position().top -
350; //350 ~= toolbar 3 righe + footer + margine tolleranza
}
config = $.extend(baseConfig, {
customConfig : portofino.contextPath + '/m/pageactions/ckeditor-custom/config.js',
toolbar: 'PortofinoDefault',
toolbarCanCollapse: false,
filebrowserWindowWidth : windowWidth,
filebrowserWindowHeight : windowHeight
}, config);
$('textarea.mde-form-rich-text').data('mdeRichTextConfig', config);
portofino._setupRichTextEditors();
};
portofino.copyFormAsHiddenFields = function(source, form) {
source.find("input, select").each(function(index, elem) {
elem = $(elem);
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", elem.attr('name'));
hiddenField.setAttribute("value", elem.val());
form.append(hiddenField);
});
};
portofino.enablePageActionDragAndDrop = function(button, originalPath) {
$("div.embeddedPageActions").sortable({
connectWith: "div.embeddedPageActions",
placeholder: "embeddedPageActionPlaceholder",
cursor: "move", // cursor image
revert: true, // moves the page to its new position with a smooth transition
tolerance: "pointer" // mouse pointer overlaps the droppable
}).disableSelection().addClass("pageActionBox");
var container = $(".content");
container.prepend('\