cmc-sales/php/app/webroot/js/global.js

70 lines
1.5 KiB
JavaScript
Executable file

/**
* Javascript that applies to the whole site.
*
* Apply button() to buttons and submit buttons for jQuery UI styling.
*/
$(function() {
$("button, input:submit").button();
$('#globalAjaxLoading')
.hide() // hide it initially
.ajaxStart(function() {
$(this).show();
})
.ajaxStop(function() {
$(this).hide();
});
});
function getCakeID(model, count, field) {
return model+count+capitalizeFirstLetter(field);
}
function getCakeName(model, count, field) {
return 'data['+model+']['+count+']['+field+']';
}
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
function getSelectedID(elementID) {
var id;
$(elementID+" :selected").each(function(i, selected) {
id = this.value;
});
return id;
}
function getSelectedText(elementID) {
var text;
$(elementID+" :selected").each(function(i, selected) {
text = $(selected).text();
});
return text;
}
//Setup CKEditor toolbars
var config = {
toolbar:[
['Source','Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Image','Table','HorizontalRule','SpecialChar'],
'/',
['Styles','Format'],
['Bold','Italic','Strike','Underline'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
['Link','Unlink'],
['Maximize','-','About']
],
disableNativeSpellChecker: false,
removePlugins: 'contextmenu,liststyle,tabletools'
};