tag status done

1.0
Javier Álvarez Medina 14 years ago
parent f98b4b0248
commit ecef65df5a

@ -8,6 +8,7 @@ javascripts:
- admin/public_tables.js
- table:
- plugins/jquery.livequery.min.js
- plugins/tag-it.js
- plugins/cDBtable.js
- admin/table_elements.js
- admin/table.js

@ -100,7 +100,48 @@
// End table status binding
//Change tags
$('div.inner_subheader div.left').append(
'<span class="tags_window">'+
'<ul id="tags_list"></ul>'+
'<a href="#save_tags">Save</a>'+
'</span>');
$('span.tags a.add').click(function(){
var values = [];
$('span.tags p').each(function(index,element){
values.push($(element).text());
});
$("#tags_list").tagit(
//{availableTags: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby", "python", "c", "scala", "groovy", "haskell", "perl"]}
{values: values}
);
$('span.tags_window').show();
});
$('span.tags_window a').click(function(){
var old_values = [];
$("span.tags p").each(function(index,element){
old_values.push($(element).text());
});
var new_values = '';
$("span.tags p").remove();
$("li.tagit-choice").each(function(index,element){
var value = (($.trim($(element).text())).slice(0, -2));
$('<p>'+value+'</p>').insertBefore('a.add');
new_values+=value+',';
});
$('span.tags_window').hide();
changesRequest('/update','tags',new_values,old_values);
});
//Advanced options
$('div.inner_subheader div.right').append(
'<span class="advanced_options">'+
'<a href="#close_advanced_options" class="advanced">advanced<span></span></a>'+
@ -128,6 +169,7 @@
$('body').unbind('click');
}
});
//End advanced options
});
@ -167,6 +209,11 @@
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'tags': $('div.performing_op p').removeClass('loading').addClass('success').text('Tags changed');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default:
}
$('div.performing_op').delay(2000).fadeOut(function(){resetLoader()});
@ -192,6 +239,15 @@
$('section.subheader h2 a').text(old_value);
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
case 'tags': $('div.performing_op p').removeClass('loading').addClass('error').text('Impossible to change the tags. Try again later.');
var width_text = $('div.performing_op p').width();
$('div.performing_op').css('margin-left','-'+(width_text/2)+'px');
$("span.tags p").remove();
$.each(old_value,function(index,element){
$('<p>'+element+'</p>').insertBefore('a.add');
});
break;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
default:
}
$('div.performing_op').delay(2000).fadeOut(function(){resetLoader()});

@ -0,0 +1,110 @@
(function($) {
$.fn.tagit = function(options) {
var defaults = {
availableTags: [],
values: [],
getValues: []
}
var el = this;
const BACKSPACE = 8;
const ENTER = 13;
const SPACE = 32;
const COMMA = 44;
// add the tagit CSS class.
el.addClass("tagit");
// create the input field.
var html_input_field = "<li class=\"tagit-new\"><input class=\"tagit-input\" type=\"text\" /></li>\n";
el.html (html_input_field);
tag_input = el.children(".tagit-new").children(".tagit-input");
for (var i = 0; i < options.values.length; i++) {
create_choice(jQuery.trim(options.values[i]));
}
$(this).click(function(e){
if (e.target.tagName == 'A') {
// Removes a tag when the little 'x' is clicked.
// Event is binded to the UL, otherwise a new tag (LI > A) wouldn't have this event attached to it.
$(e.target).parent().remove();
}
else {
// Sets the focus() to the input field, if the user clicks anywhere inside the UL.
// This is needed because the input field needs to be of a small size.
tag_input.focus();
}
});
tag_input.keypress(function(event){
if (event.which == BACKSPACE) {
if (tag_input.val() == "") {
// When backspace is pressed, the last tag is deleted.
$(el).children(".tagit-choice:last").remove();
}
}
// Comma/Space/Enter are all valid delimiters for new tags.
else if (event.which == COMMA || event.which == SPACE || event.which == ENTER) {
event.preventDefault();
var typed = tag_input.val();
typed = typed.replace(/,+$/,"");
typed = typed.trim();
if (typed != "") {
if (is_new (typed)) {
create_choice (typed);
}
// Cleaning the input.
tag_input.val("");
}
}
});
// tag_input.autocomplete({
// source: options.availableTags,
// select: function(event,ui){
// if (is_new (ui.item.value)) {
// create_choice (ui.item.value);
// }
// // Cleaning the input.
// tag_input.val("");
//
// // Preventing the tag input to be update with the chosen value.
// return false;
// }
// });
function is_new (value){
var is_new = true;
this.tag_input.parents("ul").children(".tagit-choice").each(function(i){
n = $(this).children("input").val();
if (value == n) {
is_new = false;
}
})
return is_new;
}
function create_choice (value){
var el = "";
el = "<li class=\"tagit-choice\">\n";
el += value + "\n";
el += "<a class=\"close\">x</a>\n";
el += "<input type=\"hidden\" style=\"display:none;\" value=\""+value+"\" name=\"item[tags][]\">\n";
el += "</li>\n";
var li_search_tags = this.tag_input.parent();
$(el).insertBefore (li_search_tags);
this.tag_input.val("");
}
};
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
};
})(jQuery);

@ -90,6 +90,24 @@ section.subheader span.title_window input[type="submit"] {float:right; width:50p
section.subheader span.title_window input[type="submit"]:hover {background-image:-moz-linear-gradient(100% 100% 90deg, #CACBCE, #FFFFFF); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#CACBCE), to(#FFFFFF)); cursor:pointer;}
/*Tags list*/
section.subheader span.tags_window {position:absolute; display:none; left:0; top:35px; min-width:327px; max-width:600px; min-height:28px; padding:0; border:1px solid #000000; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; background:#131723; -moz-box-shadow: 0 0 50px 1px #222222;
-webkit-box-shadow: 0 0 50px 1px #222222; box-shadow: 0 0 50px 1px #222222;}
section.subheader span.tags_window ul {float:left; min-width:262px; min-height:25px; margin:6px 5px 0 5px; padding:1px 0 0 3px; background:white; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px;}
section.subheader span.tags_window ul#tags_list li {display: block; float:left; margin:2px 5px 2px 0; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px;}
section.subheader span.tags_window ul#tags_list li.tagit-choice {padding:2px 4px 2px; font:normal 12px Arial; background-color:#DEE7F8; border:1px solid #CAD8F3; }
section.subheader span.tags_window ul#tags_list li.tagit-choice:hover {background-color:#bbcef1; border-color:#6d95e0;}
section.subheader span.tags_window ul#tags_list li.tagit-new {padding:0px 4px 1px 0;}
section.subheader span.tags_window ul#tags_list li.tagit-choice input { display:block; float:left; margin:2px 5px 2px 0;}
section.subheader span.tags_window ul#tags_list li.tagit-choice a.close {float:none; width:auto; padding:2px 0 2px 3px!important; font:bold 12px Arial; color:#777777; cursor:pointer; text-decoration:none; text-shadow:none; border:none; background:none;}
section.subheader span.tags_window ul#tags_list li.tagit-choice a.close:hover {color:#333333;}
section.subheader span.tags_window ul#tags_list input[type="text"] {width:120px; margin:0; padding:0; background-color:#FFFFFF; color:#333333; border:none; font:normal 12px Arial;}
section.subheader span.tags_window ul#tags_list input[type="text"]:focus {outline:none;}
section.subheader span.tags_window a {float:right; width:46px; height:14px; margin:5px 5px 5px 0; padding:6px 0; font:bold 12px Arial; color:#333333; text-align:center; border:1px solid #000000; text-decoration:none; text-shadow:0 1px white;
-webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; background-image:-moz-linear-gradient(100% 100% 90deg, #FFFFFF, #CACBCE); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#FFFFFF), to(#CACBCE));}
section.subheader span.tags_window a:hover {background-image:-moz-linear-gradient(100% 100% 90deg, #CACBCE, #FFFFFF); background-image:-webkit-gradient(linear, 0% 0%, 0% 100%, from(#CACBCE), to(#FFFFFF)); cursor:pointer;}
/*MAP*/
div#map {position:absolute; display:none; top:161px; left:0; right:0; bottom:0; background:white;}
Loading…
Cancel
Save