PluginProbe
CSS & JavaScript Toolbox / 9.3
CSS & JavaScript Toolbox v9.3
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 9.3, at framework/js/ui/jquery.link-progress/jquery.link-progress.js

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