2015-05-05 03:00:01 +02:00
|
|
|
<?php
|
|
|
|
|
2015-10-19 00:45:58 +02:00
|
|
|
class HTML {
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-10-19 00:45:58 +02:00
|
|
|
public static function title($args)
|
|
|
|
{
|
|
|
|
$html = '<h2 class="title"><i class="uk-icon-'.$args['icon'].'"></i> '.$args['title'].'</h2>';
|
|
|
|
echo $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function formOpen($args)
|
|
|
|
{
|
|
|
|
$class = empty($args['class']) ? '' : ' '.$args['class'];
|
|
|
|
$id = empty($args['id']) ? '' : 'id="'.$args['id'].'"';
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-10-19 00:45:58 +02:00
|
|
|
$html = '<form class="uk-form'.$class.'" '.$id.' method="post" action="" autocomplete="off">';
|
|
|
|
echo $html;
|
|
|
|
}
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-10-19 00:45:58 +02:00
|
|
|
public static function formClose()
|
2015-05-05 03:00:01 +02:00
|
|
|
{
|
2015-10-19 00:45:58 +02:00
|
|
|
$html = '</form>';
|
2016-01-16 15:01:29 +01:00
|
|
|
|
|
|
|
$script = '<script>
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
// Prevent the form submit when press enter key.
|
|
|
|
$("form").keypress(function(e) {
|
|
|
|
if (e.which == 13) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>';
|
|
|
|
echo $html.$script;
|
2015-10-19 00:45:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// label, name, value, tip
|
|
|
|
public static function formInputText($args)
|
|
|
|
{
|
|
|
|
$id = 'js'.$args['name'];
|
|
|
|
$type = isset($args['type']) ? $args['type'] : 'text';
|
|
|
|
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
|
|
|
|
$placeholder = empty($args['placeholder']) ? '' : 'placeholder="'.$args['placeholder'].'"';
|
2015-11-07 01:23:50 +01:00
|
|
|
$disabled = empty($args['disabled']) ? '' : 'disabled';
|
2015-10-19 00:45:58 +02:00
|
|
|
|
|
|
|
$html = '<div class="uk-form-row">';
|
|
|
|
|
|
|
|
if(!empty($args['label'])) {
|
|
|
|
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '<div class="uk-form-controls">';
|
2015-05-05 03:00:01 +02:00
|
|
|
|
2015-11-07 01:23:50 +01:00
|
|
|
$html .= '<input id="'.$id.'" name="'.$args['name'].'" type="'.$type.'" '.$class.' '.$placeholder.' autocomplete="off" '.$disabled.' value="'.$args['value'].'">';
|
2015-10-19 00:45:58 +02:00
|
|
|
|
|
|
|
if(!empty($args['tip'])) {
|
|
|
|
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
echo $html;
|
|
|
|
}
|
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
public static function tagsAutocomplete($args)
|
2016-01-12 04:36:48 +01:00
|
|
|
{
|
2016-01-16 15:01:29 +01:00
|
|
|
// Tag array for Javascript
|
|
|
|
$tagArray = 'var tagArray = [];';
|
|
|
|
if(!empty($args['value'])) {
|
|
|
|
$tagArray = 'var tagArray = ["'.implode('","', $args['value']).'"]';
|
|
|
|
}
|
|
|
|
$args['value'] = '';
|
|
|
|
|
|
|
|
// Text input
|
2016-01-12 04:36:48 +01:00
|
|
|
self::formInputText($args);
|
|
|
|
|
2016-01-16 15:01:29 +01:00
|
|
|
echo '<div id="jstagList"></div>';
|
|
|
|
|
2016-01-12 04:36:48 +01:00
|
|
|
$script = '<script>
|
2016-01-16 15:01:29 +01:00
|
|
|
|
|
|
|
'.$tagArray.'
|
|
|
|
|
|
|
|
function insertTag(tag)
|
|
|
|
{
|
|
|
|
// Clean the input text
|
|
|
|
$("#jstags").val("");
|
|
|
|
|
|
|
|
if(tag.trim()=="") {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if the tag is already inserted.
|
|
|
|
var found = $.inArray(tag, tagArray);
|
|
|
|
if(found == -1) {
|
|
|
|
tagArray.push(tag);
|
|
|
|
renderTagList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function removeTag(tag)
|
|
|
|
{
|
|
|
|
var found = $.inArray(tag, tagArray);
|
|
|
|
|
|
|
|
if(found => 0) {
|
|
|
|
tagArray.splice(found, 1);
|
|
|
|
renderTagList();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderTagList()
|
|
|
|
{
|
|
|
|
if(tagArray.length == 0) {
|
|
|
|
$("#jstagList").html("");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$("#jstagList").html("<span>"+tagArray.join("</span><span>")+"</span>");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#jstags").autoComplete({
|
|
|
|
minChars: 1,
|
|
|
|
source: function(term, suggest){
|
|
|
|
term = term.toLowerCase();
|
|
|
|
var choices = ['.$args['words'].'];
|
|
|
|
var matches = [];
|
|
|
|
for (i=0; i<choices.length; i++)
|
|
|
|
if (~choices[i].toLowerCase().indexOf(term)) matches.push(choices[i]);
|
|
|
|
suggest(matches);
|
|
|
|
},
|
|
|
|
onSelect: function(e, value, item) {
|
|
|
|
// Insert the tag when select whit the mouse click.
|
|
|
|
insertTag(value);
|
|
|
|
}
|
2016-01-12 04:36:48 +01:00
|
|
|
});
|
2016-01-16 15:01:29 +01:00
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
// When the page is loaded render the tags
|
|
|
|
renderTagList();
|
|
|
|
|
|
|
|
// Remove the tag when click on it.
|
|
|
|
$("body").on("click", "#jstagList > span", function() {
|
|
|
|
value = $(this).html();
|
|
|
|
removeTag(value);
|
|
|
|
});
|
|
|
|
|
|
|
|
// Insert tag when press enter key.
|
|
|
|
$("#jstags").keypress(function(e) {
|
|
|
|
if (e.which == 13) {
|
|
|
|
var value = $(this).val();
|
|
|
|
insertTag(value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// When form submit.
|
|
|
|
$("form").submit(function(e) {
|
|
|
|
var list = tagArray.join(",");
|
|
|
|
$("#jstags").val(list);
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-01-12 04:36:48 +01:00
|
|
|
</script>';
|
|
|
|
|
|
|
|
echo $script;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2015-10-19 00:45:58 +02:00
|
|
|
public static function formInputPassword($args)
|
|
|
|
{
|
|
|
|
$args['type'] = 'password';
|
|
|
|
self::formInputText($args);
|
2015-05-05 03:00:01 +02:00
|
|
|
}
|
2015-10-19 00:45:58 +02:00
|
|
|
|
|
|
|
public static function formTextarea($args)
|
|
|
|
{
|
|
|
|
$id = 'js'.$args['name'];
|
|
|
|
$type = isset($args['type']) ? $args['type'] : 'text';
|
|
|
|
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
|
|
|
|
$placeholder = empty($args['placeholder']) ? '' : 'placeholder="'.$args['placeholder'].'"';
|
|
|
|
$rows = empty($args['rows']) ? '' : 'rows="'.$args['rows'].'"';
|
|
|
|
|
|
|
|
$html = '<div class="uk-form-row">';
|
|
|
|
|
|
|
|
if(!empty($args['label'])) {
|
|
|
|
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '<div class="uk-form-controls">';
|
|
|
|
|
|
|
|
$html .= '<textarea id="'.$id.'" name="'.$args['name'].'" '.$class.' '.$placeholder.' '.$rows.'>'.$args['value'].'</textarea>';
|
|
|
|
|
|
|
|
if(!empty($args['tip'])) {
|
|
|
|
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
echo $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function formSelect($args)
|
|
|
|
{
|
|
|
|
$id = 'js'.$args['name'];
|
|
|
|
$type = isset($args['type']) ? $args['type'] : 'text';
|
|
|
|
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
|
|
|
|
|
|
|
|
$html = '<div class="uk-form-row">';
|
|
|
|
$html .= '<label for="'.$id.'" class="uk-form-label">'.$args['label'].'</label>';
|
|
|
|
$html .= '<div class="uk-form-controls">';
|
|
|
|
$html .= '<select id="'.$id.'" name="'.$args['name'].'" '.$class.'>';
|
|
|
|
foreach($args['options'] as $key=>$value) {
|
|
|
|
$html .= '<option value="'.$key.'"'.( ($args['selected']==$key)?' selected="selected"':'').'>'.$value.'</option>';
|
|
|
|
}
|
|
|
|
$html .= '</select>';
|
|
|
|
$html .= '<p class="uk-form-help-block">'.$args['tip'].'</p>';
|
|
|
|
$html .= '</div>';
|
|
|
|
$html .= '</div>';
|
|
|
|
|
|
|
|
echo $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function formInputHidden($args)
|
|
|
|
{
|
|
|
|
$id = 'js'.$args['name'];
|
|
|
|
|
|
|
|
$html = '<input type="hidden" id="'.$id.'" name="'.$args['name'].'" value="'.$args['value'].'">';
|
|
|
|
echo $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function legend($args)
|
|
|
|
{
|
2015-11-30 01:45:30 +01:00
|
|
|
$class = empty($args['class']) ? '' : 'class="'.$args['class'].'"';
|
|
|
|
|
|
|
|
$html = '<legend '.$class.'>'.$args['value'].'</legend>';
|
2015-10-19 00:45:58 +02:00
|
|
|
echo $html;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function formButtonSubmit($args)
|
|
|
|
{
|
|
|
|
$html = '';
|
|
|
|
}
|
|
|
|
|
2015-12-28 23:28:42 +01:00
|
|
|
public static function bluditQuickImages()
|
|
|
|
{
|
2016-01-08 21:12:17 +01:00
|
|
|
global $L;
|
2015-12-28 23:28:42 +01:00
|
|
|
|
|
|
|
$html = '<!-- BLUDIT QUICK IMAGES -->';
|
|
|
|
$html .= '
|
|
|
|
<div id="bludit-quick-images">
|
2016-01-16 15:01:29 +01:00
|
|
|
<div id="bludit-quick-images-thumbnails" onmousedown="return false">
|
2015-12-28 23:28:42 +01:00
|
|
|
';
|
|
|
|
|
|
|
|
$thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true);
|
|
|
|
array_splice($thumbnailList, THUMBNAILS_AMOUNT);
|
|
|
|
foreach($thumbnailList as $file) {
|
|
|
|
$filename = basename($file);
|
2016-01-03 22:04:54 +01:00
|
|
|
$html .= '<img class="bludit-thumbnail" data-filename="'.$filename.'" src="'.HTML_PATH_UPLOADS_THUMBNAILS.$filename.'" alt="Thumbnail">';
|
2015-12-28 23:28:42 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '
|
|
|
|
</div>
|
2016-01-03 22:04:54 +01:00
|
|
|
';
|
|
|
|
|
|
|
|
if(empty($thumbnailList)) {
|
2016-01-17 22:11:20 +01:00
|
|
|
$html .= '<div class="empty-images uk-block uk-text-center uk-block-muted">'.$L->g('There are no images').'</div>';
|
2016-01-03 22:04:54 +01:00
|
|
|
}
|
2015-12-28 23:28:42 +01:00
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
$html .= '
|
2016-01-08 21:12:17 +01:00
|
|
|
<a data-uk-modal href="#bludit-images-v8" class="moreImages uk-button">'.$L->g('More images').'</a>
|
2015-12-28 23:28:42 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
$script = '
|
|
|
|
<script>
|
|
|
|
|
|
|
|
// Add thumbnail to Quick Images
|
|
|
|
function addQuickImages(filename)
|
|
|
|
{
|
|
|
|
var imageSrc = HTML_PATH_UPLOADS_THUMBNAILS + filename;
|
|
|
|
|
|
|
|
// Remove element if there are more than 6 thumbnails
|
|
|
|
if ($("#bludit-quick-images-thumbnails > img").length > 5) {
|
|
|
|
$("img:last-child", "#bludit-quick-images-thumbnails").remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the new thumbnail to Quick images
|
|
|
|
$("#bludit-quick-images-thumbnails").prepend("<img class=\"bludit-thumbnail\" data-filename=\""+filename+"\" src=\""+imageSrc+"\" alt=\"Thumbnail\">");
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
|
|
';
|
|
|
|
|
|
|
|
echo $html.$script;
|
2015-12-28 23:28:42 +01:00
|
|
|
}
|
|
|
|
|
2015-12-31 01:35:28 +01:00
|
|
|
public static function bluditCoverImage($coverImage="")
|
2015-12-28 23:28:42 +01:00
|
|
|
{
|
|
|
|
global $L;
|
|
|
|
|
2015-12-31 01:35:28 +01:00
|
|
|
$style = '';
|
|
|
|
if(!empty($coverImage)) {
|
|
|
|
$style = 'background-image: url('.HTML_PATH_UPLOADS_THUMBNAILS.$coverImage.')';
|
|
|
|
}
|
|
|
|
|
2015-12-28 23:28:42 +01:00
|
|
|
$html = '<!-- BLUDIT COVER IMAGE -->';
|
|
|
|
$html .= '
|
|
|
|
<div id="bludit-cover-image">
|
2015-12-31 01:35:28 +01:00
|
|
|
<div id="cover-image-thumbnail" class="uk-form-file uk-placeholder uk-text-center" style="'.$style.'">
|
|
|
|
|
|
|
|
<input type="hidden" name="coverImage" id="cover-image-upload-filename" value="'.$coverImage.'">
|
2015-12-28 23:28:42 +01:00
|
|
|
|
2015-12-31 01:35:28 +01:00
|
|
|
<div id="cover-image-upload" '.( empty($coverImage)?'':'style="display: none;"' ).'>
|
2015-12-28 23:28:42 +01:00
|
|
|
<div><i class="uk-icon-picture-o"></i> '.$L->g('Cover image').'</div>
|
2015-12-31 01:35:28 +01:00
|
|
|
<div style="font-size:0.8em;">'.$L->g('Drag and drop or click here').'<input id="cover-image-file-select" type="file"></div>
|
2015-12-28 23:28:42 +01:00
|
|
|
</div>
|
|
|
|
|
2015-12-31 01:35:28 +01:00
|
|
|
<div id="cover-image-delete" '.( empty($coverImage)?'':'style="display: block;"' ).'>
|
2015-12-28 23:28:42 +01:00
|
|
|
<div><i class="uk-icon-trash-o"></i></div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="cover-image-progressbar" class="uk-progress">
|
|
|
|
<div class="uk-progress-bar" style="width: 0%;">0%</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
|
|
|
|
$script = '
|
|
|
|
<script>
|
2016-01-03 22:04:54 +01:00
|
|
|
|
|
|
|
function addCoverImage(filename)
|
|
|
|
{
|
|
|
|
var imageSrc = HTML_PATH_UPLOADS_THUMBNAILS + filename;
|
|
|
|
|
|
|
|
// Cover image background
|
|
|
|
$("#cover-image-thumbnail").attr("style","background-image: url("+imageSrc+")");
|
|
|
|
|
|
|
|
// Form attribute
|
|
|
|
$("#cover-image-upload-filename").attr("value", filename);
|
|
|
|
}
|
|
|
|
|
2015-12-28 23:28:42 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
$("#cover-image-delete").on("click", function() {
|
|
|
|
$("#cover-image-thumbnail").attr("style","");
|
2015-12-31 01:35:28 +01:00
|
|
|
$("#cover-image-upload-filename").attr("value","");
|
2015-12-28 23:28:42 +01:00
|
|
|
$("#cover-image-delete").hide();
|
|
|
|
$("#cover-image-upload").show();
|
|
|
|
});
|
|
|
|
|
|
|
|
var settings =
|
|
|
|
{
|
|
|
|
type: "json",
|
|
|
|
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
|
|
|
|
allow : "*.(jpg|jpeg|gif|png)",
|
|
|
|
params: {"type":"cover-image"},
|
|
|
|
|
|
|
|
loadstart: function() {
|
|
|
|
$("#cover-image-progressbar").find(".uk-progress-bar").css("width", "0%").text("0%");
|
2015-12-31 01:35:28 +01:00
|
|
|
$("#cover-image-progressbar").show();
|
2015-12-28 23:28:42 +01:00
|
|
|
$("#cover-image-delete").hide();
|
|
|
|
$("#cover-image-upload").hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
progress: function(percent) {
|
|
|
|
percent = Math.ceil(percent);
|
|
|
|
$("#cover-image-progressbar").find(".uk-progress-bar").css("width", percent+"%").text(percent+"%");
|
|
|
|
},
|
|
|
|
|
|
|
|
allcomplete: function(response) {
|
|
|
|
$("#cover-image-progressbar").find(".uk-progress-bar").css("width", "100%").text("100%");
|
|
|
|
$("#cover-image-progressbar").hide();
|
|
|
|
$("#cover-image-delete").show();
|
2016-01-03 22:04:54 +01:00
|
|
|
$(".empty-images").hide();
|
|
|
|
|
|
|
|
// Add Cover Image
|
|
|
|
addCoverImage(response.filename);
|
2015-12-28 23:28:42 +01:00
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
// Add thumbnail to Quick Images
|
|
|
|
addQuickImages(response.filename);
|
2015-12-31 01:35:28 +01:00
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
// Add thumbnail to Bludit Images V8
|
|
|
|
addBluditImagev8(response.filename);
|
2015-12-28 23:28:42 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
notallowed: function(file, settings) {
|
|
|
|
alert("'.$L->g('Supported image file types').' "+settings.allow);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
UIkit.uploadSelect($("#cover-image-file-select"), settings);
|
|
|
|
UIkit.uploadDrop($("#cover-image-thumbnail"), settings);
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
';
|
|
|
|
echo $html.$script;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function bluditImagesV8()
|
|
|
|
{
|
|
|
|
global $L;
|
|
|
|
|
|
|
|
$html = '<!-- BLUDIT IMAGES V8 -->';
|
|
|
|
$html .= '
|
|
|
|
<div id="bludit-images-v8" class="uk-modal">
|
|
|
|
<div class="uk-modal-dialog">
|
|
|
|
|
|
|
|
<div id="bludit-images-v8-upload" class="uk-form-file uk-placeholder uk-text-center">
|
|
|
|
|
|
|
|
<div id="bludit-images-v8-drag-drop">
|
|
|
|
<div><i class="uk-icon-picture-o"></i> '.$L->g('Upload image').'</div>
|
2015-12-31 01:35:28 +01:00
|
|
|
<div style="font-size:0.8em;">'.$L->g('Drag and drop or click here').'<input id="bludit-images-v8-file-select" type="file"></div>
|
2015-12-28 23:28:42 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="bludit-images-v8-progressbar" class="uk-progress">
|
|
|
|
<div class="uk-progress-bar" style="width: 0%;">0%</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div id="bludit-images-v8-thumbnails">
|
|
|
|
';
|
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
$thumbnailList = Filesystem::listFiles(PATH_UPLOADS_THUMBNAILS,'*','*',true);
|
|
|
|
foreach($thumbnailList as $file) {
|
|
|
|
$filename = basename($file);
|
|
|
|
$html .= '<img class="bludit-thumbnail" src="'.HTML_PATH_UPLOADS_THUMBNAILS.$filename.'" data-filename="'.$filename.'" alt="Thumbnail">';
|
|
|
|
}
|
2015-12-28 23:28:42 +01:00
|
|
|
|
|
|
|
$html .= '
|
|
|
|
</div>
|
2016-01-03 22:04:54 +01:00
|
|
|
';
|
2015-12-28 23:28:42 +01:00
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
if(empty($thumbnailList)) {
|
2016-01-17 22:11:20 +01:00
|
|
|
$html .= '<div class="empty-images uk-block uk-text-center uk-block-muted">'.$L->g('There are no images').'</div>';
|
2016-01-03 22:04:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '
|
2015-12-28 23:28:42 +01:00
|
|
|
<div class="uk-modal-footer">
|
2016-01-08 21:12:17 +01:00
|
|
|
'.$L->g('Double click on the image to add it').' <a href="" class="uk-modal-close">'.$L->g('Click here to cancel').'</a>
|
2015-12-28 23:28:42 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
';
|
|
|
|
|
|
|
|
$script = '
|
|
|
|
<script>
|
2016-01-03 22:04:54 +01:00
|
|
|
|
|
|
|
// Add thumbnail to Bludit Images v8
|
|
|
|
function addBluditImagev8(filename)
|
|
|
|
{
|
|
|
|
var imageSrc = HTML_PATH_UPLOADS_THUMBNAILS + filename;
|
|
|
|
|
|
|
|
// Add the new thumbnail to Bludit Images v8
|
|
|
|
$("#bludit-images-v8-thumbnails").prepend("<img class=\"bludit-thumbnail\" data-filename=\""+filename+"\" src=\""+imageSrc+"\" alt=\"Thumbnail\">");
|
|
|
|
}
|
|
|
|
|
2015-12-28 23:28:42 +01:00
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
// Add border when select an thumbnail
|
|
|
|
$("body").on("click", "img.bludit-thumbnail", function() {
|
|
|
|
$(".bludit-thumbnail").css("border", "1px solid #ddd");
|
|
|
|
$(this).css("border", "solid 3px orange");
|
|
|
|
});
|
|
|
|
|
|
|
|
// Hide the modal when double click on thumbnail.
|
|
|
|
$("body").on("dblclick", "img.bludit-thumbnail", function() {
|
|
|
|
var modal = UIkit.modal("#bludit-images-v8");
|
|
|
|
if ( modal.isActive() ) {
|
|
|
|
modal.hide();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
// Event for double click for insert the image is in each editor plugin
|
|
|
|
// ..
|
|
|
|
|
|
|
|
var settings =
|
|
|
|
{
|
|
|
|
type: "json",
|
|
|
|
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
|
2016-01-29 13:31:56 +01:00
|
|
|
allow : "*.(jpg|jpeg|gif|png|svg)",
|
2015-12-28 23:28:42 +01:00
|
|
|
params: {"type":"bludit-images-v8"},
|
|
|
|
|
|
|
|
loadstart: function() {
|
|
|
|
$("#bludit-images-v8-progressbar").find(".uk-progress-bar").css("width", "0%").text("0%");
|
2015-12-31 01:35:28 +01:00
|
|
|
$("#bludit-images-v8-drag-drop").hide();
|
|
|
|
$("#bludit-images-v8-progressbar").show();
|
2015-12-28 23:28:42 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
progress: function(percent) {
|
|
|
|
percent = Math.ceil(percent);
|
|
|
|
$("#bludit-images-v8-progressbar").find(".uk-progress-bar").css("width", percent+"%").text(percent+"%");
|
|
|
|
},
|
|
|
|
|
|
|
|
allcomplete: function(response) {
|
|
|
|
$("#bludit-images-v8-progressbar").find(".uk-progress-bar").css("width", "100%").text("100%");
|
|
|
|
$("#bludit-images-v8-progressbar").hide();
|
2015-12-31 01:35:28 +01:00
|
|
|
$("#bludit-images-v8-drag-drop").show();
|
2016-01-03 22:04:54 +01:00
|
|
|
$(".empty-images").hide();
|
2015-12-28 23:28:42 +01:00
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
// Add thumbnail to Bludit Images V8
|
|
|
|
addBluditImagev8(response.filename);
|
2015-12-28 23:28:42 +01:00
|
|
|
|
2016-01-03 22:04:54 +01:00
|
|
|
// Add thumbnail to Quick Images
|
|
|
|
addQuickImages(response.filename);
|
2015-12-28 23:28:42 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
notallowed: function(file, settings) {
|
|
|
|
alert("'.$L->g('Supported image file types').' "+settings.allow);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
UIkit.uploadSelect($("#bludit-images-v8-file-select"), settings);
|
|
|
|
UIkit.uploadDrop($("#bludit-images-v8-upload"), settings);
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
';
|
|
|
|
echo $html.$script;
|
|
|
|
}
|
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
public static function profileUploader($username)
|
2015-11-04 01:28:11 +01:00
|
|
|
{
|
|
|
|
global $L;
|
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
$html = '<!-- BLUDIT PROFILE UPLOADER -->';
|
|
|
|
|
|
|
|
$html .= '
|
|
|
|
<div id="bludit-profile-picture">
|
|
|
|
|
|
|
|
<div id="bludit-profile-picture-image">';
|
|
|
|
|
|
|
|
if(file_exists(PATH_UPLOADS_PROFILES.$username.'.png')) {
|
|
|
|
$html .= '<img class="uk-border-rounded" src="'.HTML_PATH_UPLOADS_PROFILES.$username.'.png" alt="Profile picture">';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
$html .= '<div class="uk-block uk-border-rounded uk-block-muted uk-block-large">'.$L->g('Profile picture').'</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
$html .= '
|
|
|
|
</div>
|
2015-11-04 01:28:11 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
<div id="bludit-profile-picture-progressbar" class="uk-progress">
|
2015-11-04 01:28:11 +01:00
|
|
|
<div class="uk-progress-bar" style="width: 0%;">0%</div>
|
2016-01-02 23:51:12 +01:00
|
|
|
</div>
|
2015-11-04 01:28:11 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
<div id="bludit-profile-picture-drag-drop" class="uk-form-file uk-placeholder uk-text-center">
|
|
|
|
<div>'.$L->g('Upload image').'</div>
|
|
|
|
<div style="font-size:0.8em;">'.$L->g('Drag and drop or click here').'<input id="bludit-profile-picture-file-select" type="file"></div>
|
|
|
|
</div>
|
2015-11-04 01:28:11 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
</div>
|
|
|
|
';
|
2015-11-04 01:28:11 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
$script = '
|
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
2015-11-04 01:28:11 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
var settings =
|
2015-11-15 22:37:34 +01:00
|
|
|
{
|
2016-01-02 23:51:12 +01:00
|
|
|
type: "json",
|
|
|
|
action: HTML_PATH_ADMIN_ROOT+"ajax/uploader",
|
|
|
|
allow : "*.(jpg|jpeg|gif|png)",
|
|
|
|
params: {"type":"profilePicture", "username":"'.$username.'"},
|
2015-11-15 22:37:34 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
loadstart: function() {
|
|
|
|
$("#bludit-profile-picture-progressbar").find(".uk-progress-bar").css("width", "0%").text("0%");
|
|
|
|
$("#bludit-profile-picture-progressbar").show();
|
|
|
|
},
|
2015-11-15 22:37:34 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
progress: function(percent) {
|
|
|
|
percent = Math.ceil(percent);
|
|
|
|
$("#bludit-profile-picture-progressbar").find(".uk-progress-bar").css("width", percent+"%").text(percent+"%");
|
|
|
|
},
|
2015-11-15 22:37:34 +01:00
|
|
|
|
2016-01-02 23:51:12 +01:00
|
|
|
allcomplete: function(response) {
|
|
|
|
$("#bludit-profile-picture-progressbar").find(".uk-progress-bar").css("width", "100%").text("100%");
|
|
|
|
$("#bludit-profile-picture-progressbar").hide();
|
|
|
|
|
|
|
|
$("#bludit-profile-picture-image").html("<img class=\"uk-border-rounded\" src=\"'.HTML_PATH_UPLOADS_PROFILES.$username.'.png?time='.time().'\">");
|
|
|
|
},
|
|
|
|
|
|
|
|
notallowed: function(file, settings) {
|
|
|
|
alert("'.$L->g('Supported image file types').' "+settings.allow);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
UIkit.uploadSelect($("#bludit-profile-picture-file-select"), settings);
|
|
|
|
UIkit.uploadDrop($("#bludit-profile-picture-drag-drop"), settings);
|
|
|
|
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
';
|
|
|
|
|
|
|
|
echo $html.$script;
|
2015-11-15 22:37:34 +01:00
|
|
|
}
|
|
|
|
|
2015-12-02 02:32:55 +01:00
|
|
|
}
|