reuse edit_image.js
remove outdated code and insert code to update form field value for checkbox
This commit is contained in:
@@ -1,45 +1,36 @@
|
|||||||
/*
|
function updateCheckBox(selector, value){
|
||||||
function hideImageDetails(id,filename){
|
$(selector).attr('value', value)
|
||||||
try{$('#img_editor').dialog('close');}catch(e){}
|
if (value==1){
|
||||||
|
$(selector).prop( "checked", true );
|
||||||
$("#"+id).load('image.cgi?show='+filename+'&template=image_single.html');
|
} else {
|
||||||
return false;
|
$(selector).prop( "checked", false );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveImage(id, filename) {
|
function updatePublicCheckbox(elem){
|
||||||
var url='image.cgi?save_image='+filename;
|
console.log(elem.prop('checked'))
|
||||||
if (url!='') $.post(
|
if (elem.prop('checked')){
|
||||||
url,
|
console.log( 'set public' );
|
||||||
$("#save_img_"+id).serialize(),
|
updateCheckBox(elem, 1);
|
||||||
function(data){
|
}else{
|
||||||
hideImageDetails('img_'+id, filename);
|
console.log( 'unset public' );
|
||||||
|
updateCheckBox(elem, 0);
|
||||||
}
|
}
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteImage(id, filename) {
|
|
||||||
$("#"+id).load('image.cgi?delete_image='+filename);
|
|
||||||
hideImageDetails('img_'+id, filename);
|
|
||||||
$("#"+id).hide('drop');
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function showImageUrl(id){
|
$(document).ready(
|
||||||
var el=document.getElementById(id);
|
function(){
|
||||||
var input_id=id+'_input';
|
var publicCheckbox=$("#img_editor input[name='public']");
|
||||||
var text='<input id="'+input_id+'" value="{{thumbs/'+id+'|title}}" title="3fach-Klick zum Markieren!">';
|
|
||||||
if (el.innerHTML==text){
|
updatePublicCheckbox( publicCheckbox );
|
||||||
el.innerHTML='';
|
publicCheckbox.change(
|
||||||
}else{
|
function(){
|
||||||
el.innerHTML=text;
|
updatePublicCheckbox($(this));
|
||||||
var input=document.getElementById(input_id);
|
}
|
||||||
input.focus();
|
)
|
||||||
input.select();
|
console.log("image handler initialized");
|
||||||
input.createTextRange().execCommand("Copy");
|
pageLeaveHandler();
|
||||||
}
|
}
|
||||||
return false;
|
);
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ function setActiveImage(elem){
|
|||||||
// open dialog to show or edit image properties
|
// open dialog to show or edit image properties
|
||||||
function updateImageEditor(elem, filename, target, project_id, studio_id, series_id, event_id, pid){
|
function updateImageEditor(elem, filename, target, project_id, studio_id, series_id, event_id, pid){
|
||||||
var url='image.cgi?show='+filename;
|
var url='image.cgi?show='+filename;
|
||||||
url += '&template=image_edit.html';
|
url += '&template=edit_image.html';
|
||||||
url += '&target=' + target;
|
url += '&target=' + target;
|
||||||
url += '&project_id='+project_id;
|
url += '&project_id='+project_id;
|
||||||
url += '&studio_id='+studio_id;
|
url += '&studio_id='+studio_id;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
<div>
|
<script src="js/edit_image.js" type="text/javascript"></script>
|
||||||
|
|
||||||
|
<div class="editor">
|
||||||
<TMPL_IF action>
|
<TMPL_IF action>
|
||||||
<TMPL_IF error>
|
<TMPL_IF error>
|
||||||
<div class="error">failed</div>
|
<div class="error">failed</div>
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
<!--
|
|
||||||
<link type="text/css" href="css/admin.css" rel="stylesheet"/>
|
|
||||||
<link type="text/css" href="css/image_manager.css" rel="stylesheet"/>
|
|
||||||
-->
|
|
||||||
|
|
||||||
<script>
|
|
||||||
function updateCheckBox(selector, value){
|
|
||||||
$(selector).attr('value', value)
|
|
||||||
if (value==1){
|
|
||||||
$(selector).prop( "checked", true );
|
|
||||||
} else {
|
|
||||||
$(selector).prop( "checked", false );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function updatePublicCheckbox(elem){
|
|
||||||
console.log(elem.prop('checked'))
|
|
||||||
if (elem.prop('checked')){
|
|
||||||
console.log( 'set public' );
|
|
||||||
updateCheckBox(elem, 1);
|
|
||||||
}else{
|
|
||||||
console.log( 'unset public' );
|
|
||||||
updateCheckBox(elem, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(
|
|
||||||
function(){
|
|
||||||
var publicCheckbox=$("#img_editor input[name='public']");
|
|
||||||
|
|
||||||
updatePublicCheckbox( publicCheckbox );
|
|
||||||
publicCheckbox.change(
|
|
||||||
function(){
|
|
||||||
updatePublicCheckbox($(this));
|
|
||||||
}
|
|
||||||
)
|
|
||||||
console.log("image handler initialized");
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<TMPL_IF no_results>
|
|
||||||
found no image
|
|
||||||
</TMPL_IF>
|
|
||||||
|
|
||||||
<TMPL_LOOP images>
|
|
||||||
<TMPL_IF filename>
|
|
||||||
<div id="imageEditor">
|
|
||||||
<button onclick="assignImage('<TMPL_VAR filename escape=0>', '<TMPL_VAR .target>', '<TMPL_VAR .project_id>', '<TMPL_VAR .studio_id>', '<TMPL_VAR .series_id>', '<TMPL_VAR .event_id>', '<TMPL_VAR .pid>'); return false"><TMPL_VAR .loc.select_image></button/>
|
|
||||||
|
|
||||||
<div class="panel-body">
|
|
||||||
|
|
||||||
<form id="save_img_<TMPL_VAR id>"
|
|
||||||
method="post"
|
|
||||||
action="image.cgi"
|
|
||||||
onsubmit="saveImage('<TMPL_VAR id>','<TMPL_VAR filename>');return false;"
|
|
||||||
>
|
|
||||||
|
|
||||||
<input type="hidden" name="project_id" value="<TMPL_VAR .project_id>">
|
|
||||||
<input type="hidden" name="studio_id" value="<TMPL_VAR .studio_id>">
|
|
||||||
|
|
||||||
<label><TMPL_VAR .loc.label_name></label><br>
|
|
||||||
<input value="<TMPL_VAR name escape=0>" name="update_name" class="field" placeholder="<TMPL_VAR .loc.label_name>"><br>
|
|
||||||
|
|
||||||
<label><TMPL_VAR .loc.label_description></label><br>
|
|
||||||
<textarea class="field" name="update_description" cols="50" rows=5 placeholder="<TMPL_VAR .loc.label_description>"><TMPL_VAR description escape=0></textarea><br>
|
|
||||||
|
|
||||||
<label><TMPL_VAR .loc.label_author>/<TMPL_VAR .loc.label_licence></label><br>
|
|
||||||
<input name="licence" value="<TMPL_VAR licence>" class="field<TMPL_IF missing_licence> error</TMPL_IF>" placeholder="<TMPL_VAR .loc.label_licence_missing>"/><br>
|
|
||||||
|
|
||||||
<label><TMPL_VAR .loc.label_public></label>
|
|
||||||
<input type="checkbox" name="public" <TMPL_IF public>checked="checked" value="1"<TMPL_ELSE>value="0"</TMPL_IF> /><br>
|
|
||||||
|
|
||||||
<TMPL_IF name="update_image">
|
|
||||||
<input type="hidden" name="save_image" value="<TMPL_VAR filename escape=0>" />
|
|
||||||
<button onclick="this.submit"><TMPL_VAR .loc.button_save></button/>
|
|
||||||
</TMPL_IF>
|
|
||||||
|
|
||||||
<TMPL_IF name="delete_image">
|
|
||||||
<button onclick="askDeleteImage('img_<TMPL_VAR id escape=0>','<TMPL_VAR filename escape=0>');return false;"><TMPL_VAR .loc.button_delete></button>
|
|
||||||
</TMPL_IF>
|
|
||||||
|
|
||||||
<div id="status" ></div>
|
|
||||||
<TMPL_VAR .loc.label_created_at> <TMPL_VAR created_at> <TMPL_VAR .loc.label_created_by> <TMPL_VAR created_by><br>
|
|
||||||
<TMPL_VAR .loc.label_modified_at> <TMPL_VAR modified_at> <TMPL_VAR .loc.label_modified_by> <TMPL_VAR modified_by><br>
|
|
||||||
<TMPL_VAR .loc.label_link>: {{<TMPL_VAR filename escape=0>|<TMPL_VAR name>}}<br>
|
|
||||||
|
|
||||||
</form>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</TMPL_IF>
|
|
||||||
</TMPL_LOOP>
|
|
||||||
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user