2014-04-13 00:46:31 +00:00
|
|
|
$().ready(function() {
|
2014-04-13 12:34:40 +00:00
|
|
|
$('.show-modal').click(function (e) {
|
|
|
|
var $this = $(this);
|
|
|
|
if ($this.is('a')) {
|
|
|
|
e.preventDefault();
|
|
|
|
}
|
|
|
|
var $modal_id = $this.attr('data-modal-id') || 'main';
|
|
|
|
var $modal = $('#' + $modal_id + 'Modal');
|
|
|
|
var href = $this.attr('href');
|
|
|
|
if($modal.length) {
|
|
|
|
$modal.find('.modalOKButton').attr('href', href);
|
2014-04-13 00:46:31 +00:00
|
|
|
|
|
|
|
var param = $this.attr('data-modal-param');
|
|
|
|
if(param) {
|
|
|
|
var ary = param.split(',');
|
|
|
|
for (var index = 0; index < ary.length && index < 9; ++index) {
|
|
|
|
var value = ary[index];
|
2014-04-13 12:34:40 +00:00
|
|
|
$($modal).find('span.modalP' + (index+1)).text(value);
|
2014-04-13 00:46:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$modal.modal('show');
|
2014-04-13 18:30:45 +00:00
|
|
|
} else {
|
2014-04-13 12:34:40 +00:00
|
|
|
// Just in case we forgot the dialog box
|
|
|
|
var conf = confirm("Are you sure?");
|
|
|
|
if (conf === true) {
|
|
|
|
window.location = href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
2014-04-13 18:30:45 +00:00
|
|
|
|
|
|
|
psm_flash_message();
|
|
|
|
psm_tooltips();
|
2014-04-13 00:46:31 +00:00
|
|
|
});
|
2014-01-10 10:03:07 +00:00
|
|
|
|
2014-04-24 21:31:48 +00:00
|
|
|
function psm_xhr(mod, params, method, on_complete, options) {
|
|
|
|
method = (typeof method == 'undefined') ? 'GET' : method;
|
|
|
|
|
|
|
|
var xhr_options = {
|
|
|
|
data: params,
|
|
|
|
type: method,
|
|
|
|
success: on_complete,
|
|
|
|
error: function(jqjqXHR, textStatus, errorThrown) {
|
|
|
|
psm_flash_message(errorThrown);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
$.extend(xhr_options, options);
|
|
|
|
|
|
|
|
var result = $.ajax('index.php?xhr=1&mod=' + mod, xhr_options);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-03-21 15:38:48 +00:00
|
|
|
function psm_tooltips() {
|
|
|
|
$('input[data-toggle="tooltip"]').tooltip({
|
2014-03-28 15:24:03 +00:00
|
|
|
'trigger':'hover',
|
2014-03-21 15:38:48 +00:00
|
|
|
'placement': 'right',
|
|
|
|
'container': 'body'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2014-04-04 19:35:10 +00:00
|
|
|
function psm_goTo(url) {
|
|
|
|
window.location = url;
|
|
|
|
}
|
|
|
|
|
2014-01-10 10:03:07 +00:00
|
|
|
function trim(str) {
|
|
|
|
return str.replace(/^\s+|\s+$/g,"");
|
|
|
|
}
|
2014-01-28 23:57:36 +00:00
|
|
|
|
2014-01-10 10:03:07 +00:00
|
|
|
//left trim
|
|
|
|
function ltrim(str) {
|
|
|
|
return str.replace(/^\s+/,"");
|
|
|
|
}
|
|
|
|
|
|
|
|
//right trim
|
|
|
|
function rtrim(str) {
|
|
|
|
return str.replace(/\s+$/,"");
|
2014-02-08 17:40:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function psm_flash_message(message) {
|
|
|
|
var flashmessage = $('#flashmessage');
|
|
|
|
if(flashmessage.length){
|
|
|
|
if(typeof message != 'undefined') {
|
|
|
|
flashmessage.html(message);
|
|
|
|
}
|
|
|
|
var t = flashmessage.html();
|
|
|
|
var c = trim(t);
|
|
|
|
var t = c.replace(' ', '');
|
|
|
|
if(t){
|
|
|
|
flashmessage.slideDown();
|
|
|
|
}
|
|
|
|
}
|
2014-01-28 23:57:36 +00:00
|
|
|
}
|