123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251 |
-
-
-
- var myMessages = ['info','warning','error','success'];
-
- function hideAllMessages()
- {
- var messagesHeights = new Array();
-
- for (i=0; i<myMessages.length; i++)
- {
- messagesHeights[i] = $('.' + myMessages[i]).outerHeight();
- $('.' + myMessages[i]).css('top', -messagesHeights[i]);
- }
- }
-
- $(document).ready(function(){
-
-
- hideAllMessages();
-
- $('.message').animate({top:"0"}, 500);
-
-
- $('.message a.message-close').click(function(){
- $(this).parent('.message').animate({top: -$(this).outerHeight()-50}, 700);
- return false;
- });
-
- });
-
- function findKeyWithValue(arrayt, value)
- {
- for(i in arrayt)
- {
- if (arrayt[i] == value)
- {
- return i;
- }
- }
- return "";
- }
-
- function json_to_array(json_string)
- {
- if (json_string.length)
- {
- return eval("(" + json_string + ")");
- }
- return new Array();
- }
-
- function strpos (haystack, needle, offset) {
-
-
-
-
-
-
-
-
- var i = (haystack + '').indexOf(needle, (offset || 0));
- return i === -1 ? false : i;
- }
-
-
- function array2json(arr) {
- var parts = [];
- var is_list = (Object.prototype.toString.apply(arr) === '[object Array]');
-
- for(var key in arr) {
- var value = arr[key];
- if(typeof value == "object") {
- if(is_list) parts.push(array2json(value));
- else parts[key] = array2json(value);
- } else {
- var str = "";
- if(!is_list) str = '"' + key + '":';
-
-
- if(typeof value == "number") str += value;
- else if(value === false) str += 'false';
- else if(value === true) str += 'true';
- else str += '"' + value + '"';
-
-
- parts.push(str);
- }
- }
- var json = parts.join(",");
-
- if(is_list) return '[' + json + ']';
- return '{' + json + '}';
- }
-
- function isInteger(s) {
- return (s.toString().search(/^-?[0-9]+$/) == 0);
- }
-
- function inArray(array, p_val) {
- var l = array.length;
- for(var i = 0; i < l; i++) {
- if(array[i] == p_val) {
- return true;
- }
- }
- return false;
- }
-
- if(typeof(String.prototype.trim) === "undefined")
- {
- String.prototype.trim = function()
- {
- return String(this).replace(/^\s+|\s+$/g, '');
- };
- }
-
- function str_replace (search, replace, subject, count) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- j = 0,
- temp = '',
- repl = '',
- sl = 0, fl = 0,
- f = [].concat(search),
- r = [].concat(replace),
- s = subject,
- ra = Object.prototype.toString.call(r) === '[object Array]', sa = Object.prototype.toString.call(s) === '[object Array]';
- s = [].concat(s);
- if (count) {
- this.window[count] = 0;
- }
- for (i = 0, sl = s.length; i < sl; i++) {
- if (s[i] === '') {
- continue;
- }for (j = 0, fl = f.length; j < fl; j++) {
- temp = s[i] + '';
- repl = ra ? (r[j] !== undefined ? r[j] : '') : r[0];
- s[i] = (temp).split(f[j]).join(repl);
- if (count && s[i] !== temp) {this.window[count] += (temp.length - s[i].length) / f[j].length;
- }
- }
- }
- return sa ? s : s[0];
- }
-
- function explode (delimiter, string, limit) {
-
-
-
-
-
-
-
-
-
-
-
- var emptyArray = {0: ''
- };
-
-
- if (arguments.length < 2 || typeof arguments[0] == 'undefined' || typeof arguments[1] == 'undefined') {return null;
- }
-
- if (delimiter === '' || delimiter === false || delimiter === null) {
- return false;}
-
- if (typeof delimiter == 'function' || typeof delimiter == 'object' || typeof string == 'function' || typeof string == 'object') {
- return emptyArray;
- }
- if (delimiter === true) {
- delimiter = '1';
- }
- if (!limit) {
- return string.toString().split(delimiter.toString());
- }
-
- var splitted = string.toString().split(delimiter.toString());var partA = splitted.splice(0, limit - 1);
- var partB = splitted.join(delimiter.toString());
- partA.push(partB);
- return partA;
- }
-
-
- function remove_tags(form_name)
- {
- tagsAddeds[form_name] = new Array();
- $('form[name="'+form_name+'"] ul.tagbox li.tag').remove();
- $('form[name="'+form_name+'"] input.tagBox_tags_ids').val('');
- $('div#tags_prompt_'+form_name+' ul.tagbox li.input input[type="text"]')
- .val(string_tag_prompt_input_help)
- ;
- }
-
- $(document).ready(function(){
-
-
- function onBlur() {
- document.body.className = 'blurred';
- }
-
- function onFocus(){
- document.body.className = 'focused';
- }
-
- if (false) {
- document.onfocusin = onFocus;
- document.onfocusout = onBlur;
- } else {
- window.onfocus = onFocus;
- window.onblur = onBlur;
- }
-
-
-
- $('.tags_prompt input.clear, a.filter_clear_url').live("click", function(){
- $('img.elements_more_loader').show();
- $('ul.elements').html('');
- form = $(this).parent('div').parent('form');
- remove_tags(form.attr('name'));
- form.submit();
- });
-
-
- $('.tags_prompt input.mytags').live("click", function(){
-
- $('img.elements_more_loader').show();
- $('ul.elements').html('');
-
- form = $(this).parent('div').parent('form');
-
- $.getJSON(url_get_favorites_tags, function(response) {
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- remove_tags(form.attr('name'));
-
-
- inputTag = $("div#tags_prompt_"+form.attr('name')+" input.form-default-value-processed");
- for (i in response.tags)
- {
- $('input#tags_selected_tag_'+form.attr('name')).val(i);
- inputTag.val(response.tags[i]);
-
-
- inputTag.trigger("selectTag");
- }
-
- form.submit();
-
-
- });
- });
-
-
- $('ul.element_tags li a.element_tag').live('click', function(){
-
- if ($('ul#favorite_tags').length)
- {
- id = str_replace('#', '', $(this).attr('href'));
- link = $('ul#favorite_tags li a[href="#'+id+'"]');
- list_tag_clicked(link, true);
- }
-
- if ($('form[name="search"]').length)
- {
- $('img.elements_more_loader').show();
- $('ul.elements').html('');
- form = $('form[name="search"]');
- id = str_replace('#', '', $(this).attr('href'));
- remove_tags('search');
- inputTag = $("div#tags_prompt_search input.form-default-value-processed");
- $('input#tags_selected_tag_search').val(id);
- inputTag.val($(this).html());
- inputTag.trigger("selectTag");
- form.submit();
- }
- });
-
-
-
-
- $('a.element_embed_open_link').live("click", function(){
-
- li = $(this).parent('td').parent('tr').parent().parent().parent('li.element');
-
- li.find('a.element_embed_close_link').show();
- li.find('a.element_embed_open_link_text').hide();
- li.find('div.element_embed').show();
-
- return false;
- });
-
- $('a.element_name_embed_open_link').live("click", function(){
-
- li = $(this).parent('span').parent('td').parent('tr').parent().parent().parent('li.element');
-
- li.find('a.element_embed_close_link').show();
- li.find('a.element_embed_open_link_text').hide();
- li.find('div.element_embed').show();
-
- return false;
- });
-
-
- $('a.element_embed_close_link').live("click", function(){
-
- li = $(this).parent('td').parent('tr').parent().parent().parent('li.element');
-
- li.find('div.element_embed').hide();
- li.find('a.element_embed_open_link_text').show();
- $(this).hide();
-
- return false;
- });
-
-
- $('li.element a.a_thumbnail, li.element img.open, li.element img.play').live({
- mouseenter:
- function()
- {
- td = $(this).parent('td');
- a = td.find('a.a_thumbnail');
- if (a.hasClass('embed'))
- {
- td.find('img.play').show();
- }
- else
- {
- td.find('img.open').show();
- }
- },
- mouseleave:
- function()
- {
- td = $(this).parent('td');
- a = td.find('a.a_thumbnail');
- if (a.hasClass('embed'))
- {
- td.find('img.play').hide();
- }
- else
- {
- td.find('img.open').hide();
- }
- }
- }
- );
-
-
- $('a.favorite_link').live("click", function(){
- link = $(this);
-
-
- img = link.find('img');
- if (!link.hasClass('loading'))
- {
- if (img.attr('src') == '/bundles/muzichcore/img/favorite_bw.png')
- {
- img.attr('src', '/bundles/muzichcore/img/favorite.png');
- }
- else
- {
- img.attr('src', '/bundles/muzichcore/img/favorite_bw.png');
- }
- }
-
- link.addClass('loading');
-
- $.getJSON($(this).attr('href'), function(response) {
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- img = link.find('img');
- link.attr('href', response.link_new_url);
- img.attr('src', response.img_new_src);
- img.attr('title', response.img_new_title);
- link.removeClass('loading');
- });
- return false;
- });
-
-
- $('ul.elements li.element').live({
- mouseenter:
- function()
- {
- $(this).find('a.element_edit_link').show();
- $(this).find('a.element_remove_link').show();
- },
- mouseleave:
- function()
- {
- if (!$(this).find('a.element_edit_link').hasClass('mustBeDisplayed'))
- {
- $(this).find('a.element_edit_link').hide();
- }
- if (!$(this).find('a.element_remove_link').hasClass('mustBeDisplayed'))
- {
- $(this).find('a.element_remove_link').hide();
- }
- }
- }
- );
-
-
- last_id = null;
- $('a.elements_more').click(function(){
- link = $(this);
- last_element = $('ul.elements li.element:last-child');
- id_last = str_replace('element_', '', last_element.attr('id'));
- invertcolor = 0;
- if (last_element.hasClass('even'))
- {
- invertcolor = 1;
- }
- $('img.elements_more_loader').show();
- $.getJSON(link.attr('href')+'/'+id_last+'/'+invertcolor, function(response) {
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- if (response.count)
- {
- $('ul.elements').append(response.html);
- $('img.elements_more_loader').hide();
- }
-
- if (response.end || response.count < 1)
- {
- $('img.elements_more_loader').hide();
- $('ul.elements').after('<div class="no_elements"><p class="no-elements">'+
- response.message+'</p></div>');
- link.hide();
- }
- });
- return false;
- });
-
- tag_box_input_value = $('ul.tagbox input[type="text"]').val();
-
-
- $('form[name="search"] input[type="submit"]').click(function(){
- $('ul.elements').html('');
- $('div.no_elements').hide();
- $('img.elements_more_loader').show();
- });
-
- $('form[name="search"]').ajaxForm(function(response) {
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- $('ul.elements').html(response.html);
-
- if (response.count)
- {
- $('img.elements_more_loader').hide();
- $('span.elements_more').show();
- $('a.elements_more').show();
- }
-
- if (response.count < 1)
- {
- $('img.elements_more_loader').hide();
- $('ul.elements').after('<div class="no_elements"><p class="no-elements">'+
- response.message+'</p></div>');
- $('a.elements_more').hide()
- ;
- }
-
- $('ul.tagbox input[type="text"]').val($('ul.tagbox input[type="text"]').val());
-
- });
-
-
- $('a.element_remove_link').jConfirmAction({
- question : "Vraiment supprimer ?",
- yesAnswer : "Oui",
- cancelAnswer : "Non",
- onYes: function(link){
-
- li = link.parent('td').parent('tr').parent().parent().parent('li.element');
- li.find('img.element_loader').show();
- $.getJSON(link.attr('href'), function(response){
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- if (response.status == 'success')
- {
- li.remove();
- }
- else
- {
- li.find('img.element_loader').hide();
- }
- });
-
- return false;
- },
- onOpen: function(link){
- li = link.parent('td').parent('tr').parent().parent().parent('li.element');
- li.find('a.element_edit_link').addClass('mustBeDisplayed');
- li.find('a.element_remove_link').addClass('mustBeDisplayed');
- },
- onClose: function(link){
- li = link.parent('td').parent('tr').parent().parent().parent('li.element');
- li.find('a.element_edit_link').removeClass('mustBeDisplayed');
- li.find('a.element_remove_link').removeClass('mustBeDisplayed');
- li.find('a.element_edit_link').hide();
- li.find('a.element_remove_link').hide();
- }
- });
-
- elements_edited = new Array();
-
- $('a.element_edit_link').live('click', function(){
-
- link = $(this);
- li = link.parent('td').parent('tr').parent().parent().parent('li.element');
-
- elements_edited[li.attr('id')] = li.html();
- div_loader = li.find('div.loader');
- li.html(div_loader);
- li.find('img.element_loader').show();
-
- $.getJSON($(this).attr('href'), function(response) {
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
-
- li.html(response.html);
-
- li.find('ul.tagbox li.input input[type="text"]').formDefaults();
-
- var options = new Array();
- options.form_name = response.form_name;
- options.tag_init = response.tags;
-
- ajax_query_timestamp = null;
-
- $("#tags_prompt_list_"+response.form_name).tagBox(options);
-
-
- $('form[name="'+response.form_name+'"] input[type="submit"]').live('click', function(){
- li.prepend(div_loader);
- li.find('img.element_loader').show();
- });
- $('form[name="'+response.form_name+'"]').ajaxForm(function(response){
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- if (response.status == 'success')
- {
- li.html(response.html);
- delete(elements_edited[li.attr('id')]);
- }
- else if (response.status == 'error')
- {
- li.find('img.element_loader').hide();
- li.find('ul.error_list').remove();
- ul_errors = $('<ul>').addClass('error_list');
-
- for (i in response.errors)
- {
- ul_errors.append($('<li>').append(response.errors[i]));
- }
-
- li.prepend(ul_errors);
- }
- });
-
- });
- return false;
- });
-
-
- $('form.edit_element input.cancel_edit').live('click', function(){
- var li = $(this).parent('form').parent('li');
- li.html(elements_edited[li.attr('id')]);
- delete(elements_edited[li.attr('id')]);
- });
-
-
-
- ajax_query_timestamp = null;
- tag_text_help = $('input.tag_text_help').val();
-
-
-
- $('html').click(function() {
- if ($("div.search_tag_list").is(':visible'))
- {
- $("div.search_tag_list").hide();
- }
- });
-
- $("div.search_tag_list, div.search_tag_list a.more").live('click', function(event){
- event.stopPropagation();
- $("div.search_tag_list").show();
- });
-
- function autocomplete_tag(input, form_name)
- {
-
- if ((input.val().length > 0) && (input.val() != string_tag_prompt_input_help))
- {
-
-
- inputTag = input;
-
-
- divtags = $("#search_tag_"+form_name);
-
-
- if (!divtags.is(':visible'))
- {
-
- position = input.position();
- divtags.css('left', Math.round(position.left) + 5);
- divtags.css('top', Math.round(position.top) + 28);
-
- divtags.show();
- }
-
- $('#tag_loader_'+form_name).show();
-
- search_tag_list = divtags.find('ul.search_tag_list');
-
- search_tag_list.find('li').remove();
- search_tag_list.hide();
-
- span_info = divtags.find('span.info');
- span_info.show();
-
- span_info.text("Recherche des tags correspondants à \""+input.val()+"\" ...");
-
-
- divtags.find('a.more').hide();
-
-
- ajax_query_timestamp = new Date().getTime();
-
-
- $.getJSON(url_search_tag+'/'+input.val()+'/'+ajax_query_timestamp, function(data) {
- if (data.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
-
-
- if (data.timestamp == ajax_query_timestamp)
- {
- status = data.status;
- tags = data.data;
-
-
- if (status == 'error')
- {
-
- span_info.text(data.error);
- }
-
- else if (status == 'success')
- {
- if (tags.length > 0)
- {
- more = false;
-
- for (i in tags)
- {
- var tag_name = tags[i]['name'];
- var tag_id = tags[i]['id'];
- var t_string = tag_name
-
-
- r_string = $.trim(input.val());
- var re = new RegExp(r_string, "i");
- t_string = t_string.replace(re,"<strong>" + r_string + "</strong>");
-
-
- li_tag =
- $('<li>').append(
- $('<a>').attr('href','#'+tag_id+'#'+tag_name)
-
- .click(function(e){
-
- name = $(this).attr('href').substr(1,$(this).attr('href').length);
- name = name.substr(strpos(name, '#')+1, name.length);
-
- id = $(this).attr('href').substr(1,$(this).attr('href').length);
- id = str_replace(name, '', id);
- id = str_replace('#', '', id);
-
- $('input#tags_selected_tag_'+form_name).val(id);
- inputTag.val(name);
-
- inputTag.trigger("selectTag");
-
- divtags.hide();
- inputTag.val(tag_text_help);
- return false;
- })
- .append(t_string)
- );
-
-
- if (i > 30)
- {
- more = true;
-
- li_tag.hide();
- }
-
-
- search_tag_list.append(li_tag);
- }
-
- if (more)
- {
- divtags.find('a.more').show();
- }
-
- span_info.show();
- span_info.text(data.message);
-
- search_tag_list.show();
- }
- else
- {
- span_info.show();
- span_info.text(data.message);
- search_tag_list.show();
-
-
-
-
-
- }
-
-
- if (!data.same_found)
- {
-
- link_add_tag = null;
-
- li_tag =
- $('<li>').addClass('new').append(
- $('<a>').attr('href','#new#'+$.trim(input.val()))
-
- .click(function(e){
-
-
- $('body').append($('<div>').attr('id', 'fade'));
-
- $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();
-
-
- link_add_tag = $(this);
-
-
- popup = $('<div>')
- .attr('id', 'add_tag')
- .addClass('popin_block')
- .css('width', '400px')
-
- .append($('<div>').addClass('tag')
- .append($('<ul>')
- .append($('<li>').addClass('button')
- .append($(this).text()))))
- .append($('<p>').append(string_tag_add_text))
- .append($('<p>').append(string_tag_add_argument))
- .append($('<textarea>').attr('name', 'argument'))
- .append($('<div>').addClass('inputs')
- .append($('<input>')
- .attr('type', 'button')
- .attr('value', string_tag_add_inputs_cancel)
- .addClass('button')
- .click(function(){
- $('#fade').fadeOut(1000, function(){$('#fade').remove();});
- $('#add_tag').remove();
-
- return false;
- })
- )
- .append($('<input>')
- .attr('type', 'button')
- .attr('value', string_tag_add_inputs_submit)
- .addClass('button')
- .click(function(){
-
- var arguments = $('#add_tag textarea').val();
-
- $('#fade').fadeOut(400, function(){$('#fade').remove();});
- $('#add_tag').remove();
-
-
- name = link_add_tag.attr('href').substr(1,link_add_tag.attr('href').length);
- name = name.substr(strpos(name, '#')+1, name.length);
-
- link_add_tag.parent('li').parent('ul').parent('div').find('img.tag_loader').show();
-
- var url;
- if (arguments)
- {
- url = url_add_tag+'/'+name+'/'+arguments;
- }
- else
- {
- url = url_add_tag+'/'+name;
- }
-
-
- $.getJSON(url, function(response){
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- tag_id = response.tag_id;
- tag_name = response.tag_name;
-
- $('input#tags_selected_tag_'+form_name).val(tag_id);
- inputTag.val(tag_name);
-
- inputTag.trigger("selectTag");
-
- divtags.hide();
- inputTag.val(tag_text_help);
-
- link_add_tag.parent('li').parent('ul').parent('div').find('img.tag_loader').hide();
- });
-
- return false;
- })
- )
- )
- ;
-
-
-
- $('body').prepend(popup);
-
-
- var popMargTop = (popup.height() + 50) / 2;
- var popMargLeft = (popup.width() + 50) / 2;
-
-
- $(popup).css({
- 'margin-top' : -popMargTop,
- 'margin-left' : -popMargLeft
- });
-
- return false;
-
- })
- .append($.trim(input.val()))
- );
- search_tag_list.append(li_tag);
- }
-
- }
-
-
- $('#tag_loader_'+form_name).hide();
- }
- });
-
- }
- }
-
-
- last_keypress = 0;
-
- function check_timelaps_and_search(input, form_name, time_id, timed, info)
- {
- if (!timed)
- {
-
-
- last_keypress = new Date().getTime();
- var this_time_id = last_keypress;
- }
- else
- {
-
- var this_time_id = time_id;
- }
-
-
- if (time_id != last_keypress && timed)
- {
-
- }
- else
- {
-
- if ((new Date().getTime() - last_keypress) < 600 || timed == false)
- {
-
-
-
- setTimeout(function(){check_timelaps_and_search(input, form_name, this_time_id, true, info)}, 700);
- }
- else
- {
-
- autocomplete_tag(input, form_name);
- }
- }
- }
-
-
- $("div.tags_prompt ul.tagbox li.input input").live('keypress', function(e){
-
- var form_name = $(this).parent('li').parent('ul.tagbox')
- .parent('div.tags_prompt').parent('form').attr('name')
- ;
- var code = (e.keyCode ? e.keyCode : e.which);
-
- if ((e.which !== 0 && e.charCode !== 0) || (code == 8 || code == 46))
- {
- check_timelaps_and_search($(this), form_name, new Date().getTime(), false, $(this).val());
- }
-
- });
-
-
- $('div.search_tag_list a.more').live('click', function(){
- jQuery.each( $(this).parent('div').find('ul.search_tag_list li') , function(){
- $(this).show();
- });
- $(this).hide();
- return false;
- });
-
- $('ul.tagbox li.input input[type="text"]').val(tag_text_help);
- $('ul.tagbox li.input input[type="text"]').formDefaults();
-
-
-
-
- $('a.group_remove_link').jConfirmAction({
- question : "Supprimer ce groupe ?",
- yesAnswer : "Oui",
- cancelAnswer : "Non",
- onYes: function(link){
- window.location = link.attr('href');
- return false;
- },
- onOpen: function(){},
- onClose: function(){}
- });
-
-
- $('div.select_network a').live('click', function(){
- divSelect = $(this).parent('div');
- if ($(this).hasClass('all_network'))
- {
- divSelect.find('a.all_network').addClass('active');
- divSelect.find('a.my_network').removeClass('active');
- divSelect.find('select').val('network_public');
- }
- else
- {
- divSelect.find('a.my_network').addClass('active');
- divSelect.find('a.all_network').removeClass('active');
- divSelect.find('select').val('network_personal');
- }
- });
-
-
- $('form[name="add"] input[type="submit"]').live('click', function(){
- $('form[name="add"]').find('img.tag_loader').show();
- });
- $('form[name="add"]').ajaxForm(function(response) {
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- $('form[name="add"] img.tag_loader').hide();
- if (response.status == 'success')
- {
- $('form[name="add"]').find('ul.error_list').remove();
- $('ul.elements').prepend(response.html);
- $('form[name="add"] input[type="text"]').val('');
- $('div#element_add_box').slideUp();
- $('a#element_add_link').show();
- if ($('form[name="search"]').length)
- {
- $('form[name="search"]').slideDown();
- }
- remove_tags('add');
- recolorize_element_list();
- }
- else if (response.status == 'error')
- {
- $('form[name="add"]').find('ul.error_list').remove();
- ul_errors = $('<ul>').addClass('error_list');
-
- for (i in response.errors)
- {
- ul_errors.append($('<li>').append(response.errors[i]));
- }
-
- $('form[name="add"]').prepend(ul_errors);
- }
-
- return false;
- });
-
-
-
-
-
-
- function refresh_elements_with_tags_selected(link)
- {
-
-
-
- $('ul.elements').html('');
- $('div.no_elements').hide();
- $('img.elements_more_loader').show();
- $.getJSON($('input#get_elements_url').val()+'/'+array2json(tags_ids), function(response){
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- $('ul.elements').html(response.html);
-
- if (response.count)
- {
- $('img.elements_more_loader').hide();
- $('span.elements_more').show();
- $('a.elements_more').show();
- }
- });
-
- return false;
- }
-
- function list_tag_clicked(link, erease)
- {
- if (erease)
- {
- $('ul#favorite_tags a.tag').removeClass('active');
- }
-
-
- if (link.hasClass('active'))
- {
- link.removeClass('active');
- }
- else
- {
- link.addClass('active');
- }
-
-
- tags_ids = new Array();
- $('ul#favorite_tags a.tag.active').each(function(index){
- id = str_replace('#', '', link.attr('href'));
- tags_ids[id] = id;
- });
-
-
- a_more = $('a.elements_more');
- a_more.attr('href', $('input#more_elements_url').val()+'/'+array2json(tags_ids));
-
- return check_timelaps_and_find_with_tags(link, new Date().getTime(), false);
- }
-
- $('ul#favorite_tags a.tag').click(function(){
- list_tag_clicked($(this));
- });
-
- last_keypress = 0;
- function check_timelaps_and_find_with_tags(link, time_id, timed)
- {
- if (!timed)
- {
-
-
- last_keypress = new Date().getTime();
- var this_time_id = last_keypress;
- }
- else
- {
-
- var this_time_id = time_id;
- }
-
-
- if (time_id != last_keypress && timed)
- {
-
- }
- else
- {
-
- if ((new Date().getTime() - last_keypress) < 800 || timed == false)
- {
-
-
-
- setTimeout(function(){check_timelaps_and_find_with_tags(link, this_time_id, true)}, 900);
- }
- else
- {
-
- return refresh_elements_with_tags_selected(link);
- }
- }
-
- return null;
- }
-
-
-
-
- function check_new_elements()
- {
- var url = url_element_new_count
- +'/'
- +str_replace('element_', '', $('ul.elements li:first').attr('id'))
- ;
- $.getJSON(url, function(response){
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- if (response.status == 'success' && response.count)
- {
- $('div.display_more_elements').show();
- $('div.display_more_elements span').html(response.message);
- }
-
- setTimeout(check_new_elements, 300000);
- });
- }
-
- if ($('div.display_more_elements').length)
- {
- setTimeout(check_new_elements, 300000);
- }
-
- $('a.show_new_elements').live('click', function(){
- var url = url_element_new_get
- +'/'
- +str_replace('element_', '', $('ul.elements li:first').attr('id'))
- ;
- $('img.elements_new_loader').show();
- $.getJSON(url, function(response){
-
- if (response.status == 'mustbeconnected')
- {
- $(location).attr('href', url_index);
- }
-
- if (response.status == 'success')
- {
- if (response.count)
- {
- $('div.display_more_elements').show();
- $('div.display_more_elements span').html(response.message);
- }
- else
- {
- $('div.display_more_elements').hide();
- }
-
- $('ul.elements').prepend(response.html);
- recolorize_element_list();
- }
-
- $('img.elements_new_loader').hide();
- });
- });
-
- function recolorize_element_list()
- {
- $('ul.elements li.element').each(function(index){
- if ((index & 1) == 1)
- {
- $(this).removeClass('even');
- $(this).removeClass('odd');
- $(this).addClass('odd');
- }
- else
- {
- $(this).removeClass('odd');
- $(this).removeClass('even');
- $(this).addClass('even');
- }
- });
- }
-
- });
|