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.primefaces.core.core.js Maven / Gradle / Ivy
(function(window) {
if(window.PrimeFaces) {
PrimeFaces.debug("PrimeFaces already loaded, ignoring duplicate execution.");
return;
}
var PrimeFaces = {
escapeClientId : function(id) {
return "#" + id.replace(/:/g,"\\:");
},
cleanWatermarks : function(){
$.watermark.hideAll();
},
showWatermarks : function(){
$.watermark.showAll();
},
addSubmitParam : function(parent, params) {
var form = $(this.escapeClientId(parent));
for(var key in params) {
form.append(" ");
}
return this;
},
/**
* Submits a form and clears ui-submit-param after that to prevent dom caching issues
*/
submit : function(formId, target) {
var form = $(this.escapeClientId(formId));
if(target) {
form.attr('target', target);
}
form.submit().children('input.ui-submit-param').remove();
},
attachBehaviors : function(element, behaviors) {
$.each(behaviors, function(event, fn) {
element.bind(event, function(e) {
fn.call(element, e);
});
});
},
getCookie : function(name) {
return $.cookie(name);
},
setCookie : function(name, value) {
$.cookie(name, value);
},
cookiesEnabled: function() {
var cookieEnabled = (navigator.cookieEnabled) ? true : false;
if(typeof navigator.cookieEnabled === 'undefined' && !cookieEnabled) {
document.cookie="testcookie";
cookieEnabled = (document.cookie.indexOf("testcookie") !== -1) ? true : false;
}
return (cookieEnabled);
},
skinInput : function(input) {
input.hover(
function() {
$(this).addClass('ui-state-hover');
},
function() {
$(this).removeClass('ui-state-hover');
}
).focus(function() {
$(this).addClass('ui-state-focus');
}).blur(function() {
$(this).removeClass('ui-state-focus');
});
//aria
input.attr('role', 'textbox')
.attr('aria-disabled', input.is(':disabled'))
.attr('aria-readonly', input.prop('readonly'));
if(input.is('textarea')) {
input.attr('aria-multiline', true);
}
return this;
},
skinButton : function(button) {
button.mouseover(function(){
var el = $(this);
if(!button.prop('disabled')) {
el.addClass('ui-state-hover');
}
}).mouseout(function() {
$(this).removeClass('ui-state-active ui-state-hover');
}).mousedown(function() {
var el = $(this);
if(!button.prop('disabled')) {
el.addClass('ui-state-active').removeClass('ui-state-hover');
}
}).mouseup(function() {
$(this).removeClass('ui-state-active').addClass('ui-state-hover');
}).focus(function() {
$(this).addClass('ui-state-focus');
}).blur(function() {
$(this).removeClass('ui-state-focus ui-state-active');
}).keydown(function(e) {
if(e.keyCode === $.ui.keyCode.SPACE || e.keyCode === $.ui.keyCode.ENTER || e.keyCode === $.ui.keyCode.NUMPAD_ENTER) {
$(this).addClass('ui-state-active');
}
}).keyup(function() {
$(this).removeClass('ui-state-active');
});
//aria
button.attr('role', 'button').attr('aria-disabled', button.prop('disabled'));
return this;
},
skinSelect : function(select) {
select.mouseover(function() {
var el = $(this);
if(!el.hasClass('ui-state-focus'))
el.addClass('ui-state-hover');
}).mouseout(function() {
$(this).removeClass('ui-state-hover');
}).focus(function() {
$(this).addClass('ui-state-focus').removeClass('ui-state-hover');
}).blur(function() {
$(this).removeClass('ui-state-focus ui-state-hover');
});
return this;
},
isIE: function(version) {
return (version === undefined) ? this.browser.msie: (this.browser.msie && parseInt(this.browser.version, 10) === version);
},
info: function(log) {
if(this.logger) {
this.logger.info(log);
}
},
debug: function(log) {
if(this.logger) {
this.logger.debug(log);
}
},
warn: function(log) {
if(this.logger) {
this.logger.warn(log);
}
},
error: function(log) {
if(this.logger) {
this.logger.error(log);
}
},
setCaretToEnd: function(element) {
if(element) {
element.focus();
var length = element.value.length;
if(length > 0) {
if(element.setSelectionRange) {
element.setSelectionRange(0, length);
}
else if (element.createTextRange) {
var range = element.createTextRange();
range.collapse(true);
range.moveEnd('character', 1);
range.moveStart('character', 1);
range.select();
}
}
}
},
changeTheme: function(newTheme) {
if(newTheme && newTheme !== '') {
var themeLink = $('link[href*="javax.faces.resource/theme.css"]'),
themeURL = themeLink.attr('href'),
plainURL = themeURL.split('&')[0],
oldTheme = plainURL.split('ln=')[1],
newThemeURL = themeURL.replace(oldTheme, 'primefaces-' + newTheme);
themeLink.attr('href', newThemeURL);
}
},
escapeRegExp: function(text) {
return text.replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
},
escapeHTML: function(value) {
return value.replace(/&/g,'&').replace(//g,'>');
},
clearSelection: function() {
if(window.getSelection) {
if(window.getSelection().empty) {
window.getSelection().empty();
} else if(window.getSelection().removeAllRanges) {
window.getSelection().removeAllRanges();
}
}
else if(document.selection && document.selection.empty) {
try {
document.selection.empty();
} catch(error) {
//ignore IE bug
}
}
},
getSelection: function() {
var text = '';
if (window.getSelection) {
text = window.getSelection();
} else if (document.getSelection) {
text = document.getSelection();
} else if (document.selection) {
text = document.selection.createRange().text;
}
return text;
},
hasSelection: function() {
return this.getSelection().length > 0;
},
cw : function(widgetConstructor, widgetVar, cfg, resource) {
PrimeFaces.createWidget(widgetConstructor, widgetVar, cfg, resource);
},
createWidget : function(widgetConstructor, widgetVar, cfg, resource) {
if(PrimeFaces.widget[widgetConstructor]) {
if(PrimeFaces.widgets[widgetVar]) {
PrimeFaces.widgets[widgetVar].refresh(cfg); //ajax update
}
else {
PrimeFaces.widgets[widgetVar] = new PrimeFaces.widget[widgetConstructor](cfg); //page init
}
}
else {
var scriptURI = $('script[src*="/javax.faces.resource/primefaces.js"]').attr('src').replace('primefaces.js', resource + '/' + resource + '.js'),
cssURI = $('link[href*="/javax.faces.resource/primefaces.css"]').attr('href').replace('primefaces.css', resource + '/' + resource + '.css'),
cssResource = ' ';
//load css
$('head').append(cssResource);
//load script and initialize widget
PrimeFaces.getScript(location.protocol + '//' + location.host + scriptURI, function() {
setTimeout(function() {
PrimeFaces.widgets[widgetVar] = new PrimeFaces.widget[widgetConstructor](cfg);
}, 100);
});
}
},
inArray: function(arr, item) {
for(var i = 0; i < arr.length; i++) {
if(arr[i] === item) {
return true;
}
}
return false;
},
isNumber: function(value) {
return typeof value === 'number' && isFinite(value);
},
getScript: function(url, callback) {
$.ajax({
type: "GET",
url: url,
success: callback,
dataType: "script",
cache: true
});
},
focus : function(id, context) {
var selector = ':not(:submit):not(:button):input:visible:enabled';
setTimeout(function() {
if(id) {
var jq = $(PrimeFaces.escapeClientId(id));
if(jq.is(selector)) {
jq.focus();
}
else {
jq.find(selector).eq(0).focus();
}
}
else if(context) {
$(PrimeFaces.escapeClientId(context)).find(selector).eq(0).focus();
}
else {
$(selector).eq(0).focus();
}
}, 250);
// remember that a custom focus has been rendered
// this avoids to retain the last focus after ajax update
PrimeFaces.customFocus = true;
},
monitorDownload: function(start, complete) {
if(this.cookiesEnabled()) {
if(start) {
start();
}
window.downloadMonitor = setInterval(function() {
var downloadComplete = PrimeFaces.getCookie('primefaces.download');
if(downloadComplete === 'true') {
if(complete) {
complete();
}
clearInterval(window.downloadMonitor);
PrimeFaces.setCookie('primefaces.download', null);
}
}, 250);
}
},
/**
* Scrolls to a component with given client id
*/
scrollTo: function(id) {
var offset = $(PrimeFaces.escapeClientId(id)).offset();
$('html,body').animate({
scrollTop:offset.top
,
scrollLeft:offset.left
},{
easing: 'easeInCirc'
},1000);
},
/**
* Aligns container scrollbar to keep item in container viewport, algorithm copied from jquery-ui menu widget
*/
scrollInView: function(container, item) {
if(item.length === 0) {
return;
}
var borderTop = parseFloat(container.css('borderTopWidth')) || 0,
paddingTop = parseFloat(container.css('paddingTop')) || 0,
offset = item.offset().top - container.offset().top - borderTop - paddingTop,
scroll = container.scrollTop(),
elementHeight = container.height(),
itemHeight = item.outerHeight(true);
if(offset < 0) {
container.scrollTop(scroll + offset);
}
else if((offset + itemHeight) > elementHeight) {
container.scrollTop(scroll + offset - elementHeight + itemHeight);
}
},
calculateScrollbarWidth: function() {
if(!this.scrollbarWidth) {
if(this.browser.msie) {
var $textarea1 = $('')
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body'),
$textarea2 = $('')
.css({ position: 'absolute', top: -1000, left: -1000 }).appendTo('body');
this.scrollbarWidth = $textarea1.width() - $textarea2.width();
$textarea1.add($textarea2).remove();
}
else {
var $div = $('
')
.css({ width: 100, height: 100, overflow: 'auto', position: 'absolute', top: -1000, left: -1000 })
.prependTo('body').append('
').find('div')
.css({ width: '100%', height: 200 });
this.scrollbarWidth = 100 - $div.width();
$div.parent().remove();
}
}
return this.scrollbarWidth;
},
//adapted from jquery browser plugin
resolveUserAgent: function(ua) {
if($.browser) {
this.browser = $.browser;
}
else {
ua = ua.toLowerCase();
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
/(msie) ([\w.]+)/.exec(ua) ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [],
userAgent = {
browser: match[ 1 ] || "",
version: match[ 2 ] || "0"
},
browser = {};
if(userAgent.browser) {
browser[userAgent.browser] = true;
browser.version = userAgent.version;
}
if (browser.chrome) {
browser.webkit = true;
} else if (browser.webkit) {
browser.safari = true;
}
this.browser = browser;
}
},
bcn: function(element, event, functions) {
if(functions) {
for(var i = 0; i < functions.length; i++) {
var retVal = functions[i].call(element, event);
if(retVal === false) {
if(event.preventDefault) {
event.preventDefault();
}
else {
event.returnValue = false;
}
break;
}
}
}
},
/**
* moved to core.dialog.js
*/
openDialog: function(cfg) {
PrimeFaces.dialog.DialogHandler.openDialog(cfg);
},
closeDialog: function(cfg) {
PrimeFaces.dialog.DialogHandler.closeDialog(cfg);
},
showMessageInDialog: function(msg) {
PrimeFaces.dialog.DialogHandler.showMessageInDialog(msg);
},
confirm: function(msg) {
PrimeFaces.dialog.DialogHandler.confirm(msg);
},
zindex : 1000,
customFocus : false,
detachedWidgets : [],
PARTIAL_REQUEST_PARAM : "javax.faces.partial.ajax",
PARTIAL_UPDATE_PARAM : "javax.faces.partial.render",
PARTIAL_PROCESS_PARAM : "javax.faces.partial.execute",
PARTIAL_SOURCE_PARAM : "javax.faces.source",
BEHAVIOR_EVENT_PARAM : "javax.faces.behavior.event",
PARTIAL_EVENT_PARAM : "javax.faces.partial.event",
RESET_VALUES_PARAM : "primefaces.resetvalues",
IGNORE_AUTO_UPDATE_PARAM : "primefaces.ignoreautoupdate",
VIEW_STATE : "javax.faces.ViewState",
CLIENT_WINDOW : "javax.faces.ClientWindow",
VIEW_ROOT : "javax.faces.ViewRoot",
CLIENT_ID_DATA : "primefaces.clientid"
};
/**
* PrimeFaces Namespaces
*/
PrimeFaces.settings = {};
PrimeFaces.util = {};
PrimeFaces.widgets = {};
/**
* Locales
*/
PrimeFaces.locales = {
'en_US': {
closeText: 'Close',
prevText: 'Previous',
nextText: 'Next',
monthNames: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ],
monthNamesShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ],
dayNames: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
dayNamesShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Tue', 'Fri', 'Sat'],
dayNamesMin: ['S', 'M', 'T', 'W ', 'T', 'F ', 'S'],
weekHeader: 'Week',
firstDay: 0,
isRTL: false,
showMonthAfterYear: false,
yearSuffix:'',
timeOnlyTitle: 'Only Time',
timeText: 'Time',
hourText: 'Time',
minuteText: 'Minute',
secondText: 'Second',
currentText: 'Current Date',
ampm: false,
month: 'Month',
week: 'week',
day: 'Day',
allDayText: 'All Day'
}
};
PF = function(widgetVar) {
var widgetInstance = PrimeFaces.widgets[widgetVar];
if (!widgetInstance) {
if (window.console && console.log) {
console.log("Widget for var '" + widgetVar + "' not available!");
}
PrimeFaces.error("Widget for var '" + widgetVar + "' not available!");
}
return widgetInstance;
};
PrimeFaces.resolveUserAgent(navigator.userAgent);
//expose globally
window.PrimeFaces = PrimeFaces;
})(window);