filer: replace "file as" prompt with combobox opened in fancybox

This commit is contained in:
Fabio Comuni 2012-03-28 10:49:34 +02:00
parent 7aec2fd68d
commit 0a2675d8b6
6 changed files with 145 additions and 29 deletions

View file

@ -16,8 +16,20 @@ function filer_content(&$a) {
logger('filer: tag ' . $term . ' item ' . $item_id); logger('filer: tag ' . $term . ' item ' . $item_id);
if($item_id && strlen($term)) if($item_id && strlen($term)){
// file item
file_tag_save_file(local_user(),$item_id,$term); file_tag_save_file(local_user(),$item_id,$term);
} else {
// return filer dialog
$filetags = get_pconfig(local_user(),'system','filetags');
$filetags = explode("][", trim($filetags,"[]"));
$tpl = get_markup_template("filer_dialog.tpl");
$o = replace_macros($tpl, array(
'$field' => array('term', t("File as:"), '', '', $filetags, t('- select -')),
'$submit' => t('Save'),
));
echo $o;
}
killme(); killme();
} }

4
view/filer_dialog.tpl Normal file
View file

@ -0,0 +1,4 @@
{{ inc field_combobox.tpl }}{{ endinc }}
<div class="settings-submit-wrapper" >
<input id="filer_save" type="button" class="settings-submit" value="$submit" />
</div>

View file

@ -264,7 +264,21 @@ function enableOnUser(){
} }
function itemFiler(id) { function itemFiler(id) {
reply = prompt("$fileas");
var bordercolor = $("input").css("border-color");
$.get('filer/', function(data){
$.fancybox(data);
$("#id_term").keypress(function(){
$(this).css("border-color",bordercolor);
})
$("#select_term").change(function(){
$("#id_term").css("border-color",bordercolor);
})
$("#filer_save").click(function(e){
e.preventDefault();
reply = $("#id_term").val();
if(reply && reply.length) { if(reply && reply.length) {
commentBusy = true; commentBusy = true;
$('body').css('cursor', 'wait'); $('body').css('cursor', 'wait');
@ -272,7 +286,14 @@ function enableOnUser(){
if(timer) clearTimeout(timer); if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,3000); timer = setTimeout(NavUpdate,3000);
liking = 1; liking = 1;
$.fancybox.close();
} else {
$("#id_term").css("border-color","#FF0000");
} }
return false;
});
});
} }
function jotClearLocation() { function jotClearLocation() {

View file

@ -264,7 +264,21 @@ function enableOnUser(){
} }
function itemFiler(id) { function itemFiler(id) {
reply = prompt("$fileas");
var bordercolor = $("input").css("border-color");
$.get('filer/', function(data){
$.fancybox(data);
$("#id_term").keypress(function(){
$(this).css("border-color",bordercolor);
})
$("#select_term").change(function(){
$("#id_term").css("border-color",bordercolor);
})
$("#filer_save").click(function(e){
e.preventDefault();
reply = $("#id_term").val();
if(reply && reply.length) { if(reply && reply.length) {
commentBusy = true; commentBusy = true;
$('body').css('cursor', 'wait'); $('body').css('cursor', 'wait');
@ -272,9 +286,17 @@ function enableOnUser(){
if(timer) clearTimeout(timer); if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,3000); timer = setTimeout(NavUpdate,3000);
liking = 1; liking = 1;
$.fancybox.close();
} else {
$("#id_term").css("border-color","#FF0000");
} }
return false;
});
});
} }
function jotClearLocation() { function jotClearLocation() {
$('#jot-coord').val(''); $('#jot-coord').val('');
$('#profile-nolocation-wrapper').hide(); $('#profile-nolocation-wrapper').hide();

View file

@ -264,7 +264,21 @@ function enableOnUser(){
} }
function itemFiler(id) { function itemFiler(id) {
reply = prompt("$fileas");
var bordercolor = $("input").css("border-color");
$.get('filer/', function(data){
$.fancybox(data);
$("#id_term").keypress(function(){
$(this).css("border-color",bordercolor);
})
$("#select_term").change(function(){
$("#id_term").css("border-color",bordercolor);
})
$("#filer_save").click(function(e){
e.preventDefault();
reply = $("#id_term").val();
if(reply && reply.length) { if(reply && reply.length) {
commentBusy = true; commentBusy = true;
$('body').css('cursor', 'wait'); $('body').css('cursor', 'wait');
@ -272,9 +286,17 @@ function enableOnUser(){
if(timer) clearTimeout(timer); if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,3000); timer = setTimeout(NavUpdate,3000);
liking = 1; liking = 1;
$.fancybox.close();
} else {
$("#id_term").css("border-color","#FF0000");
} }
return false;
});
});
} }
function jotClearLocation() { function jotClearLocation() {
$('#jot-coord').val(''); $('#jot-coord').val('');
$('#profile-nolocation-wrapper').hide(); $('#profile-nolocation-wrapper').hide();

View file

@ -305,6 +305,41 @@ function initEditor(cb) {
} }
} }
function itemFiler(id) {
var bordercolor = $("input").css("border-color");
$.get('filer/', function(data){
$.fancybox(data);
$("#id_term").keypress(function(){
$(this).css("border-color",bordercolor);
})
$("#select_term").change(function(){
$("#id_term").css("border-color",bordercolor);
})
$("#filer_save").click(function(e){
e.preventDefault();
reply = $("#id_term").val();
if(reply && reply.length) {
commentBusy = true;
$('body').css('cursor', 'wait');
$.get('filer/' + id + '?term=' + reply);
if(timer) clearTimeout(timer);
timer = setTimeout(NavUpdate,3000);
liking = 1;
$.fancybox.close();
} else {
$("#id_term").css("border-color","#FF0000");
}
return false;
});
});
}
function jotClearLocation() { function jotClearLocation() {
$('#jot-coord').val(''); $('#jot-coord').val('');
$('#profile-nolocation-wrapper').hide(); $('#profile-nolocation-wrapper').hide();