reuse edit_image.js
remove outdated code and insert code to update form field value for checkbox
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
<div>
|
||||
<script src="js/edit_image.js" type="text/javascript"></script>
|
||||
|
||||
<div class="editor">
|
||||
<TMPL_IF action>
|
||||
<TMPL_IF error>
|
||||
<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