overrider.min.js
2.94 KB
Joomla.overrider={states:{refreshing:!1,refreshed:!1,counter:0,searchstring:"",searchtype:"value"}},Joomla.overrider.refreshCache=function(){var a=jQuery.noConflict(),b=this;this.states.refreshing=!0,a("#refresh-status").slideDown().css("display","block"),a.ajax({type:"POST",url:"index.php?option=com_languages&task=strings.refresh&format=json",dataType:"json"}).done(function(c){c.error&&c.message&&alert(c.message),c.messages&&Joomla.renderMessages(c.messages),a("#refresh-status").slideUp().hide(),b.states.refreshing=!1}).fail(function(b){alert(Joomla.JText._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),a("#refresh-status").slideUp().hide()})},Joomla.overrider.searchStrings=function(a){var b=jQuery.noConflict(),c=this;if(!this.states.refreshing){if(a||(this.states.searchstring=b("#jform_searchstring").val(),this.states.searchtype=null!==b("#jform_searchtype")?b("#jform_searchtype").val():"value"),!this.states.searchstring)return void b("#jform_searchstring").addClass("invalid");if(a)b("#more-results").addClass("overrider-spinner");else{b("#more-results").hide();var d=b("#results-container div.language-results");d.remove(),b("#results-container").addClass("overrider-spinner").slideDown().css("display","block")}b.ajax({type:"POST",url:"index.php?option=com_languages&task=strings.search&format=json",data:"searchstring="+c.states.searchstring+"&searchtype="+c.states.searchtype+"&more="+a,dataType:"json"}).done(function(a){a.error&&a.message&&alert(a.message),a.messages&&Joomla.renderMessages(a.messages),a.data&&(a.data.results&&c.insertResults(a.data.results),a.data.more?(c.states.more=a.data.more,b("#more-results").slideDown().css("display","block")):b("#more-results").hide()),b("#results-container").removeClass("overrider-spinner"),b("#more-results").removeClass("overrider-spinner")}).fail(function(a){alert(Joomla.JText._("COM_LANGUAGES_VIEW_OVERRIDE_REQUEST_ERROR")),b("#results-container").removeClass("overrider-spinner"),b("#more-results").removeClass("overrider-spinner")})}},Joomla.overrider.insertResults=function(a){var b=jQuery.noConflict(),c=this;this.states.counter=this.states.counter+1;var d=b("<div>",{id:"language-results"+c.states.counter,class:"language-results",style:"display:none;"});if(b.each(a,function(a,e){var f=b("<div>",{class:"result row"+a%2,onclick:"Joomla.overrider.selectString("+c.states.counter+a+");"}),g=b("<div>",{id:"override_key"+c.states.counter+a,class:"result-key",html:e.constant,title:e.file}),h=b("<div>",{id:"override_string"+c.states.counter+a,class:"result-string",html:e.string});g.appendTo(f),h.appendTo(f),f.appendTo(d)}),!a.length){var e=b("<div>",{html:Joomla.JText._("COM_LANGUAGES_VIEW_OVERRIDE_NO_RESULTS")});e.appendTo(d)}b("#more-results").before(d),b("#language-results"+this.states.counter).slideDown().css("display","block")},Joomla.overrider.selectString=function(a){var b=jQuery.noConflict();b("#jform_key").val(b("#override_key"+a).html()),b("#jform_override").val(b("#override_string"+a).html()),b(window).scrollTop(0)};