PluginProbe
CSS & JavaScript Toolbox / 6.0.9
CSS & JavaScript Toolbox v6.0.9
trunk 0.3 0.8 10 10.1 11 11.2 11.3 11.4 11.5 11.6 11.7 11.8 11.9 11.9.1 12 12.0 12.0.1 12.0.3 12.0.4 12.0.5 12.0.6 12.0.7 6.0 6.0.11 All 60 releases
css-javascript-toolbox / framework / js / ui / jquery.link-progress / jquery.link-progress.js

jquery.link-progress.js in CSS & JavaScript Toolbox 6.0.9, at framework/js/ui/jquery.link-progress/jquery.link-progress.js

119 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 *
3 */
4
5 /**
6 *
7 */
8 (function($) {
9
10 /**
11 * put your comment there...
12 *
13 * @type Object
14 */
15 var defaultConfig = {
16 loading : true,
17 cssClass : 'link-loading'
18 };
19
20 /**
21 * put your comment there...
22 *
23 * @param
24 */
25 $.fn.CJTLoading = function(params) {
26 // Implement jQuery Chain.
27 return this.each(
28 function() {
29 // If the Plugin is not yet enabled on the current link, enable it.
30 if (this.CJTLoader == undefined) {
31
32 /**
33 *
34 */
35 this.CJTLoader = {
36
37 /**
38 * put your comment there...
39 *
40 * @type Object
41 */
42 config : {},
43
44 /**
45 * put your comment there...
46 *
47 * @type DOMElement
48 */
49 jNode : $(this),
50
51 /**
52 * Hold parameters about the current in loading
53 * progress object (e.g ubinded event handlers, etc...).
54 *
55 * @type Object
56 */
57 stack : {},
58
59 /**
60 * put your comment there...
61 *
62 */
63 changeState : function() {
64 // Get reference to HTML node for the link element.
65 var node = this.jNode.get(0);
66 var stack = this.stack;
67 // Change configs.
68 this.setConfig();
69 // Enable loading.
70 if (this.config.loading) {
71 // Store link text & Remove link text.
72 stack.originalWidth = this.jNode.css('width');
73 stack.text = this.jNode.text();
74 // Clear link text.
75 this.jNode.text('');
76 // Reset to the original width.
77 this.jNode.css({width : stack.originalWidth})
78 // Add loading class.
79 this.jNode.addClass(this.config.cssClass);
80 // Make link inactive by deattaching original handler (defined by the caller),
81 // plus prevent default behavior!
82 this.jNode.unbind('click', this.config.ceHandler);
83 this.jNode.bind('click.CJTLoading', function(event) {
84 event.preventDefault();
85 }
86 );
87 }
88 else { // Disable loading and destroy object.
89 // Remove loading class.
90 this.JNode.removeClass(this.config.cssClass);
91 // Set text back.
92 this.jNode.text(stack.text);
93 // Remove custom width.
94 this.jNode.css({width : ''});
95 // Bind original handler back to the click event!
96 this.jNode.bind('click', this.config.ceHandler)
97 // Unbind prevent default handler defined by this class
98 .unbind('click.CJTLoading');
99 // Destroy jQuery Plugin for that object.
100 node.CJTLoader = undefined;
101 }
102 },
103
104 /**
105 *
106 */
107 setConfig : function() {
108 this.config = $.extend(defaultConfig, params);
109 }
110
111 };
112 }
113 // Initialize Plugin for first time.
114 this.CJTLoader.changeState();
115 }
116 )
117 } // End JPlugin.
118
119 })(jQuery);