mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-23 18:03:17 +00:00
Merge branch 4.0
This commit is contained in:
@@ -37,6 +37,11 @@
|
||||
{{ "video tool" | trans }}
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#rangeExtractor">
|
||||
{{ "video range extractor" | trans }}
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -124,7 +129,9 @@
|
||||
{% set height = technical_info[dataH].value %}
|
||||
|
||||
{% if width and height %}
|
||||
{% set ratio = (width / height)|number_format(2, '.') %}
|
||||
{% set rawRatio = (width / height)|number_format(3, '.') %}
|
||||
{% set rawRatioLength = rawRatio|length %}
|
||||
{% set ratio = rawRatio|slice(0,rawRatioLength-1) %}
|
||||
{% else %}
|
||||
{% set ratio = '' %}
|
||||
{% endif %}
|
||||
@@ -171,6 +178,33 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="rangeExtractor" class="">
|
||||
<div class="main_title">
|
||||
<img src='/assets/prod/images/ThumbExtractor/camera_title.png'/>
|
||||
{{ "video range extractor" | trans }}
|
||||
</div>
|
||||
<div class="video-range-editor-container"></div>
|
||||
<div class="video-data-container">
|
||||
<dl class="dl-horizontal">
|
||||
<dt>Ratio</dt><dd>{{ ratio }}</dd>
|
||||
<dt>Type</dt><dd>{{ record.get_mime() }}</dd>
|
||||
{% if record.exif[constant('media_subdef::TC_DATA_FRAMERATE')] is defined %}
|
||||
<dt>{{ 'Images par secondes' | trans }}</dt>
|
||||
<dd>{{ record.exif[constant('media_subdef::TC_DATA_FRAMERATE')] | round(2) }} ips</dd>
|
||||
{% endif %}
|
||||
{% if record.exif[constant('media_subdef::TC_DATA_AUDIOCODEC')] is defined %}
|
||||
<dt>{{ 'Codec Audio' | trans }}</dt>
|
||||
<dd>{{ record.exif[constant('media_subdef::TC_DATA_AUDIOCODEC')] }}</dd>
|
||||
{% endif %}
|
||||
<dt>{{ 'Size' | trans }}</dt><dd>{% set width = record.exif[constant('media_subdef::TC_DATA_WIDTH')]|default
|
||||
(null) %}
|
||||
{% set height = record.exif[constant('media_subdef::TC_DATA_HEIGHT')]|default(null) %}
|
||||
{% if width is not none and height is not none %}
|
||||
{{ width ~ " x " ~ height }}
|
||||
{% endif %}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
@@ -348,302 +382,55 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var toolsConfig = {
|
||||
selectionLength: {{ selectionLength }},
|
||||
databaseId: {% if selectionLength == 1%}{{record.get_base_id}}{% else %}0{% endif %},
|
||||
recordId: {% if selectionLength == 1%}{{record.get_record_id}}{% else %}0{% endif %},
|
||||
translations: {
|
||||
alertTitle: '{{ "alert" | trans }}',
|
||||
noImgSelected: '{{ "no image selected" | trans }}',
|
||||
processing: '{{ "processing" | trans }}',
|
||||
thumbnailTitle: '{{ 'thumbnail validation' | trans }}'
|
||||
},
|
||||
videoEditorConfig: {% if videoEditorConfig is not null %}{{ videoEditorConfig|json_encode()|raw }}{% else %}{}{% endif %},
|
||||
records: [
|
||||
|
||||
$(document).ready(function(){
|
||||
var $scope = $("#prod-tool-box");
|
||||
var tabs = $("#tool-tabs", $scope).tabs();
|
||||
var width = 0;
|
||||
|
||||
$(".iframe_submiter", $scope).bind("click", function(){
|
||||
var form = $(this).closest("form");
|
||||
form.submit();
|
||||
form.find('.load').empty().html(language.loading + ' ...');
|
||||
$("#uploadHdsub").contents().find(".content").empty();
|
||||
$("#uploadHdsub").load(function(){
|
||||
form.find('.load').empty();
|
||||
var iframeContent = $("#uploadHdsub").contents().find(".content").html();
|
||||
form.closest('div').find('.resultAction').empty().append(iframeContent);
|
||||
});
|
||||
});
|
||||
|
||||
$(".action_submiter", $scope).bind("click", function(){
|
||||
var $this = $(this);
|
||||
var form = $(this).closest("form");
|
||||
|
||||
$.ajax({
|
||||
url : form.attr("action"),
|
||||
type : form.attr("method"),
|
||||
dataType : 'json',
|
||||
data : form.serializeArray(),
|
||||
beforeSend: function(){
|
||||
$this.prop('disabled', true);
|
||||
},
|
||||
success : function(data){
|
||||
if(!data.success){
|
||||
humane.error(data.message);
|
||||
}else{
|
||||
var dialog = p4.Dialog.get(1);
|
||||
dialog.Close();
|
||||
}
|
||||
},
|
||||
complete: function(){
|
||||
$this.prop('disabled', false);
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".action_cancel", $scope).bind("click", function(){
|
||||
var dialog = p4.Dialog.get(1);
|
||||
dialog.Close();
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
//thumbExtractor
|
||||
|
||||
var ThumbEditor = new this.THUMB_EDITOR("thumb_video", "thumb_canvas", {
|
||||
altCanvas: $('#alt_canvas_container .alt_canvas')
|
||||
});
|
||||
|
||||
if(ThumbEditor.isSupported()) {
|
||||
|
||||
var $sliderWrapper = $("#thumb_wrapper", $scope);
|
||||
|
||||
$sliderWrapper.on('click', 'img', function(){
|
||||
$('.selected', $sliderWrapper).removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
|
||||
var $self = this;
|
||||
var selectedScreenId = $self.getAttribute("id").split("_").pop();
|
||||
var screenshots = ThumbEditor.store.get(selectedScreenId);
|
||||
|
||||
ThumbEditor.copy(screenshots.getDataURI(), screenshots.getAltScreenShots());
|
||||
});
|
||||
|
||||
|
||||
$scope.on('click', '#thumb_delete_button', function(){
|
||||
var img = $sliderWrapper.find(".selected");
|
||||
var id = img.attr("id").split("_").pop();
|
||||
var previous = img.prev();
|
||||
var next = img.next();
|
||||
|
||||
if(previous.length > 0)
|
||||
{% for record in records %}
|
||||
{
|
||||
previous.trigger("click");
|
||||
}
|
||||
else if(next.length > 0)
|
||||
{
|
||||
next.trigger("click");
|
||||
}
|
||||
else
|
||||
{
|
||||
$(this).hide();
|
||||
$("#thumb_info", $scope).show();
|
||||
ThumbEditor.resetCanva();
|
||||
}
|
||||
id: {{ record.get_record_id }},
|
||||
type: "{{ record.get_type() }}",
|
||||
{% if record.get_type() == 'video' %}
|
||||
{% if selectionLength == 1 %}
|
||||
{% set outputFormats = record.getSubdfefByDeviceAndMime(null, ['image/jpeg', 'image/png']) %}
|
||||
{% set previewHtml5 = record.getSubdfefByDeviceAndMime(constant('\\databox_subdef::DEVICE_SCREEN'), ['video/ogg', 'video/mp4', 'video/webm']) %}
|
||||
{% set dataW = constant('media_subdef::TC_DATA_WIDTH') %}
|
||||
{% set dataH = constant('media_subdef::TC_DATA_HEIGHT') %}
|
||||
|
||||
img.remove();
|
||||
ThumbEditor.store.remove(id);
|
||||
});
|
||||
{% set technical_info = record.get_technical_infos %}
|
||||
{% set width = technical_info[dataW].value %}
|
||||
{% set height = technical_info[dataH].value %}
|
||||
|
||||
$scope.on('click', '.close_action_frame', function(){
|
||||
$(this).closest(".action_frame").hide();
|
||||
});
|
||||
{% if width and height %}
|
||||
{% set ratio = (width / height)|number_format(2, '.') %}
|
||||
{% else %}
|
||||
{% set ratio = '' %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
$scope.on('click', '#thumb_camera_button', function(){
|
||||
$("#thumb_info", $scope).hide();
|
||||
$("#thumb_delete_button", $scope).show();
|
||||
|
||||
var screenshot = ThumbEditor.screenshot();
|
||||
var img = $("<img />");
|
||||
$('.selected', $sliderWrapper).removeClass('selected');
|
||||
img.addClass('selected')
|
||||
.attr('id', 'working_'+ screenshot.getId())
|
||||
.attr('src', screenshot.getDataURI())
|
||||
.attr("alt", screenshot.getVideoTime())
|
||||
.appendTo($sliderWrapper);
|
||||
});
|
||||
|
||||
$("#thumb_canvas").on('tool_event', function(){
|
||||
var thumbnail = $('.selected', $sliderWrapper);
|
||||
|
||||
if(thumbnail.length === 0)
|
||||
{
|
||||
console.error('No image selected');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
thumbnail.attr('src', ThumbEditor.getCanvaImage());
|
||||
|
||||
});
|
||||
$scope.on('click', '#thumb_validate_button', function(){
|
||||
var thumbnail = $('.selected', $sliderWrapper);
|
||||
|
||||
if(thumbnail.length === 0)
|
||||
{
|
||||
var dialog = p4.Dialog.Create({
|
||||
size:'Alert',
|
||||
title: '{{ "alert" | trans }}',
|
||||
closeOnEscape:true
|
||||
}, 3);
|
||||
|
||||
var content = $("<div />").css({
|
||||
'text-align':'center',
|
||||
'width': '100%',
|
||||
'font-size':'14px'
|
||||
}).append('{{ "no image selected" | trans }}');
|
||||
dialog.setContent(content);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var buttons = {};
|
||||
|
||||
var record_id = $("input[name=record_id]").val();
|
||||
var sbas_id = $("input[name=sbas_id]").val();
|
||||
|
||||
var selectedScreenId = thumbnail.attr('id').split("_").pop();
|
||||
var screenshots = ThumbEditor.store.get(selectedScreenId);
|
||||
|
||||
|
||||
var screenData = screenshots.getAltScreenShots(),
|
||||
subDefs = [];
|
||||
|
||||
for(var i = 0; i < screenData.length; i++ ) {
|
||||
subDefs.push({
|
||||
name: screenData[i].name,
|
||||
src: screenData[i].dataURI
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function disableConfirmButton(dialog){
|
||||
dialog.getDomElement().closest('.ui-dialog').find(".ui-dialog-buttonpane button").filter(function() {
|
||||
return $(this).text() == language.valider;
|
||||
}).addClass("ui-state-disabled").attr("disabled", true);
|
||||
}
|
||||
|
||||
|
||||
function enableConfirmButton(dialog){
|
||||
dialog.getDomElement().closest('.ui-dialog').find(".ui-dialog-buttonpane button").filter(function() {
|
||||
return $(this).text() == language.valider;
|
||||
}).removeClass("ui-state-disabled").attr("disabled", false);
|
||||
}
|
||||
|
||||
buttons[language.valider] = function(){
|
||||
var dialog = p4.Dialog.get(2);
|
||||
var buttonPanel = dialog.getDomElement().closest('.ui-dialog').find(".ui-dialog-buttonpane");
|
||||
var loadingDiv = buttonPanel.find('.info-div');
|
||||
|
||||
if(loadingDiv.length == 0)
|
||||
{
|
||||
loadingDiv = $("<div />").css({
|
||||
'width' : '120px',
|
||||
'height' : '40px',
|
||||
'float':'left',
|
||||
'line-height' : '40px',
|
||||
'padding-left' : '40px',
|
||||
'text-align' : 'left',
|
||||
'background-position' : 'left center'
|
||||
}).attr('class', 'info-div').prependTo(buttonPanel);
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/tools/thumb-extractor/apply/",
|
||||
data: {
|
||||
sub_def: subDefs,
|
||||
record_id : record_id,
|
||||
sbas_id: sbas_id
|
||||
},
|
||||
beforeSend: function(){
|
||||
disableConfirmButton(dialog);
|
||||
loadingDiv.empty().addClass('loading').append('{{ "processing" | trans }}');
|
||||
},
|
||||
success: function(data){
|
||||
loadingDiv.empty().removeClass('loading');
|
||||
|
||||
if(data.success)
|
||||
{
|
||||
dialog.Close();
|
||||
p4.Dialog.get(1).Close();
|
||||
}
|
||||
else
|
||||
{
|
||||
//var content = $("<div />").css({'color':'#a00'}).append("{{ "an error occured" | trans }} " + data.message);
|
||||
loadingDiv.append(content);
|
||||
enableConfirmButton(dialog);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
//show confirm box, content is loaded here /prod/tools/thumb-extractor/confirm-box/
|
||||
var dialog = p4.Dialog.Create({
|
||||
size:'Small',
|
||||
title:"{{ 'thumbnail validation' | trans }}",
|
||||
cancelButton:true,
|
||||
buttons: buttons
|
||||
}, 2);
|
||||
|
||||
var datas = {
|
||||
image: $('.selected', $sliderWrapper).attr("src"),
|
||||
sbas_id: sbas_id,
|
||||
record_id: record_id
|
||||
};
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/prod/tools/thumb-extractor/confirm-box/",
|
||||
data: datas,
|
||||
success: function(data){
|
||||
|
||||
if(data.error)
|
||||
sources: [
|
||||
{% for subdef in previewHtml5 %}
|
||||
{
|
||||
var content = $("<div />").css({'font-size':'16px', 'text-align':'center'}).append(data.datas);
|
||||
dialog.setContent(content);
|
||||
disableConfirmButton(dialog);
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog.setContent(data.datas);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
//not supported
|
||||
$("#thumbExtractor").empty().append(language.browserFeatureSupport);
|
||||
}
|
||||
ratio: '{{ ratio }}',
|
||||
framerate: {{ record.exif[constant('media_subdef::TC_DATA_FRAMERATE')] | round(2) }},
|
||||
type: "{{ subdef.get_mime() }}",
|
||||
src: "{{ subdef.get_url() }}"
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
}{% if not loop.last %},{% endif %}
|
||||
{% endfor %}
|
||||
]
|
||||
|
||||
{% if selectionLength == 1%}
|
||||
$('#tools-sharing .stateChange_button').bind('click',function(event){
|
||||
var $btn = $(event.currentTarget),
|
||||
state = true;
|
||||
|
||||
// inverse state
|
||||
if( $btn.data('state') == 1) {
|
||||
state = false;
|
||||
}
|
||||
|
||||
// submit changes
|
||||
$.post('tools/sharing-editor/{{record.get_base_id}}/{{record.get_record_id}}/', {
|
||||
name: $btn.data('name'),
|
||||
state: state
|
||||
}).done(function(data) {
|
||||
// self reload tab with current active tab:
|
||||
var activeTab = tabs.tabs('option', 'active');
|
||||
toolREFACTOR($dialog.getOption('contextArgs'), activeTab);
|
||||
}).error(function(err) {
|
||||
alert('forbidden action')
|
||||
});
|
||||
return false;
|
||||
});
|
||||
{% endif %}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user