Skip to content

Instantly share code, notes, and snippets.

@cyokodog
Last active October 13, 2015 01:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cyokodog/4116852 to your computer and use it in GitHub Desktop.
Save cyokodog/4116852 to your computer and use it in GitHub Desktop.
jQuery Title De Loading

#jQuery Title De Loading

TITLE 要素でローディング中を表現する jQuery プラグイン。

使い方

//ローディング中
$.titleDeLoading(true);

$.ajax({
	url : 'http://hoge.com/',
	success : function(){

		//ローディング終了
		$.titleDeLoading(false);

	}
});
(function($){
$.titleDeLoading = function(show){
var o = $.titleDeLoading, s = o.status, t = $('title');
s.orgTitle = s.orgTitle || t.text();
if(show){
(function(text){
var callee = arguments.callee;
t.html(text);
s.timer = setTimeout(function(){
callee((text.length < s.textMaxLength ? text : '')
+ s.loadingText);
},s.delay);
})(s.loadingText);
}
else{
clearTimeout(s.timer);
t.html(s.orgTitle);
}
}
$.titleDeLoading.status = {
loadingText : '.',
delay : 300,
textMaxLength : 6
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment