Merge branch 'saas-dev' of github.com:sourcefabric/Airtime into saas-dev
This commit is contained in:
commit
7a91677d01
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php
|
||||
|
||||
require_once 'customfilters/ImageSize.php';
|
||||
|
||||
|
|
|
@ -58,10 +58,9 @@ class Application_Model_Preference
|
|||
|
||||
$result = Application_Common_Database::prepareAndExecute($sql,
|
||||
$paramMap,
|
||||
Application_Common_Database::COLUMN,
|
||||
PDO::FETCH_ASSOC,
|
||||
Application_Common_Database::ROW_COUNT,
|
||||
PDO::FETCH_ASSOC,
|
||||
$con);
|
||||
$result = count($result);
|
||||
|
||||
$paramMap = array();
|
||||
if ($result > 1) {
|
||||
|
@ -103,8 +102,8 @@ class Application_Model_Preference
|
|||
$paramMap[':value'] = $value;
|
||||
|
||||
Application_Common_Database::prepareAndExecute($sql,
|
||||
$paramMap,
|
||||
'execute',
|
||||
$paramMap,
|
||||
Application_Common_Database::EXECUTE,
|
||||
PDO::FETCH_ASSOC,
|
||||
$con);
|
||||
|
||||
|
|
|
@ -212,6 +212,41 @@ function validateTimeRange() {
|
|||
};
|
||||
}
|
||||
|
||||
// validate uploaded images
|
||||
function validateImage(img, el) {
|
||||
// remove any existing error messages
|
||||
if ($("#img-err")) { $("#img-err").remove(); }
|
||||
|
||||
if (img.size > 2048000) { // 2MB - pull this from somewhere instead?
|
||||
// hack way of inserting an error message
|
||||
var err = $.i18n._("Selected file is too large");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" +
|
||||
"<li>" + err + "</li>" +
|
||||
"</ul>");
|
||||
return false;
|
||||
} else if (validateMimeType(img.type) < 0) {
|
||||
var err = $.i18n._("File format is not supported");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" +
|
||||
"<li>" + err + "</li>" +
|
||||
"</ul>");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// validate image mime type
|
||||
function validateMimeType(mime) {
|
||||
var extensions = [
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif'
|
||||
// BMP?
|
||||
];
|
||||
return $.inArray(mime, extensions);
|
||||
}
|
||||
|
||||
function pad(number, length) {
|
||||
return sprintf("%'0"+length+"d", number);
|
||||
}
|
||||
|
|
|
@ -33,10 +33,10 @@ function setSystemFromEmailReadonly() {
|
|||
var enableSystemEmails = $("#enableSystemEmail");
|
||||
var systemFromEmail = $("#systemEmail");
|
||||
if ($(enableSystemEmails).is(':checked')) {
|
||||
systemFromEmail.removeAttr("readonly");
|
||||
systemFromEmail.removeAttr("readonly");
|
||||
} else {
|
||||
systemFromEmail.attr("readonly", "readonly");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setMailServerInputReadonly() {
|
||||
|
@ -114,14 +114,15 @@ function setMsAuthenticationFieldsReadonly(ele) {
|
|||
}
|
||||
|
||||
function removeLogo() {
|
||||
$.post(baseUrl+'Preference/remove-logo', function(json){});
|
||||
location.reload();
|
||||
$.post(baseUrl+'preference/remove-logo', function(json){});
|
||||
// Reload without resubmitting the form
|
||||
location.href = location.href.replace(location.hash,"");
|
||||
}
|
||||
|
||||
function deleteAllFiles() {
|
||||
var resp = confirm($.i18n._("Are you sure you want to delete all the tracks in your library?"))
|
||||
if (resp) {
|
||||
$.post(baseUrl+'Preference/delete-all-files', function(json){});
|
||||
$.post(baseUrl+'preference/delete-all-files', function(json){});
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +154,36 @@ $(document).ready(function() {
|
|||
});
|
||||
});*/
|
||||
|
||||
// when an image is uploaded, preview it to the user
|
||||
var logo = $("#stationLogo"),
|
||||
preview = $("#logo-img");
|
||||
logo.change(function(e) {
|
||||
if (this.files && this.files[0]) {
|
||||
preview.show();
|
||||
var reader = new FileReader(); // browser compatibility?
|
||||
reader.onload = function (e) {
|
||||
console.log("Reader loaded");
|
||||
preview.attr('src', e.target.result);
|
||||
};
|
||||
|
||||
// check image size so we don't crash the page trying to render
|
||||
if (validateImage(this.files[0], logo)) {
|
||||
// read the image data as though it were a data URI
|
||||
reader.readAsDataURL(this.files[0]);
|
||||
} else {
|
||||
// remove the file element data
|
||||
$(this).val('').replaceWith($(this).clone(true));
|
||||
preview.hide();
|
||||
}
|
||||
} else {
|
||||
preview.hide();
|
||||
}
|
||||
});
|
||||
|
||||
if (preview.attr('src').indexOf('images/') > -1) {
|
||||
$("#logo-remove-btn").hide();
|
||||
}
|
||||
|
||||
showErrorSections();
|
||||
|
||||
setMailServerInputReadonly();
|
||||
|
|
|
@ -678,41 +678,6 @@ function setAddShowEvents(form) {
|
|||
}
|
||||
});
|
||||
|
||||
// validate on upload
|
||||
function validateImage(img, el) {
|
||||
// remove any existing error messages
|
||||
if ($("#img-err")) { $("#img-err").remove(); }
|
||||
|
||||
if (img.size > 2048000) { // 2MB - pull this from somewhere instead?
|
||||
// hack way of inserting an error message
|
||||
var err = $.i18n._("Selected file is too large");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" +
|
||||
"<li>" + err + "</li>" +
|
||||
"</ul>");
|
||||
return false;
|
||||
} else if (validateMimeType(img.type) < 0) {
|
||||
var err = $.i18n._("File format is not supported");
|
||||
el.parent().after(
|
||||
"<ul id='img-err' class='errors'>" +
|
||||
"<li>" + err + "</li>" +
|
||||
"</ul>");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Duplicate of the function in ShowImageController
|
||||
function validateMimeType(mime) {
|
||||
var extensions = [
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/gif'
|
||||
// BMP?
|
||||
];
|
||||
return $.inArray(mime, extensions);
|
||||
}
|
||||
|
||||
form.find("#add_show_logo_current_remove").click(function() {
|
||||
if (confirm($.i18n._('Are you sure you want to delete the current logo?'))) {
|
||||
var showId = $("#add_show_id").attr("value");
|
||||
|
|
Loading…
Reference in New Issue