]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - js/common.js
- Move common js utils in common.js
[Github/YOURLS.git] / js / common.js
1 // Change an element text an revert in a smooth pulse. el is an element id like '#copybox h2'\r
2 function html_pulse( el, newtext ){\r
3         var oldtext = $(el).html();\r
4         // Fast pulse to "Copied" and revert\r
5         $(el).fadeTo(\r
6                 "normal",\r
7                 0.01,\r
8                 function(){\r
9                         $(el)\r
10                         .html( newtext )\r
11                         .css('opacity', 1)\r
12                         .fadeTo(\r
13                                 "slow", 1, // this fades from 1 to 1: just a 'sleep(1)' actually\r
14                                 function(){\r
15                                         $(el).fadeTo("normal", 0.01, function(){$(el).html( oldtext ).css('opacity', 1)});\r
16                                 }\r
17                         );\r
18                 }\r
19         );\r
20 \r
21 \r
22 }\r
23 \r
24 // Update feedback message\r
25 function feedback(msg, type) {\r
26         $.notifyBar({\r
27                 html: '<span>'+msg+'</span>',\r
28                 delay: 2000,\r
29                 animationSpeed: "normal",\r
30                 cls: type\r
31         });\r
32         return true;\r
33 }\r
34 \r
35 // Unused for now\r
36 function logout() {\r
37         $.ajax({\r
38                 type: "POST",\r
39                 url: "index_ajax.php",\r
40                 data: {mode:'logout'},\r
41                 success: function() {\r
42                         window.parent.location.href = window.parent.location.href;\r
43                 }\r
44         });\r
45 }\r
46 \r
47 // Begin the spinning animation & disable a button\r
48 function add_loading(el) {\r
49         $(el).attr("disabled", "disabled").addClass('disabled').addClass('loading');\r
50 }\r
51 \r
52 // End spinning animation\r
53 function end_loading(el) {\r
54         $(el).removeClass('loading');\r
55 }\r
56 \r
57 // Un-disable an element\r
58 function end_disable(el) {\r
59         $(el).removeAttr("disabled").removeClass('disabled');\r
60 }\r