File tree Expand file tree Collapse file tree 1 file changed +41
-20
lines changed Expand file tree Collapse file tree 1 file changed +41
-20
lines changed Original file line number Diff line number Diff line change 126126 // Fields
127127
128128 // Cache the jQuery selector
129- var $_ajax = null;
129+ var _$ajax = null;
130130
131131 // Methods (private)
132132
133- // Called on Ajax done
134- function ajaxDone(data) {
133+ /**
134+ * Called on Ajax done
135+ *
136+ * @return {undefined}
137+ */
138+ function _ajaxDone(data) {
135139 // The 'data' parameter is an array of objects that can be iterated over
136- window.alert(JSON.stringify(data, null, 2));
140+ window.alert(window. JSON.stringify(data, null, 2));
137141 }
138142
139- // Called on Ajax fail
140- function ajaxFail() {
143+ /**
144+ * Called on Ajax fail
145+ *
146+ * @return {undefined}
147+ */
148+ function _ajaxFail() {
141149 window.alert('Oh no! A problem with the Ajax request!');
142150 }
143151
144- // On Ajax request
145- function ajaxEvent($this) {
152+ /**
153+ * On Ajax request
154+ *
155+ * @param {HTMLElement} $this Current element selected
156+ * @return {undefined}
157+ */
158+ function _ajaxEvent($this) {
146159 $.ajax({
147160 // URL from the link that was 'clicked' on
148161 url: $this.attr('href')
149162 })
150- .done(ajaxDone )
151- .fail(ajaxFail );
163+ .done(_ajaxDone )
164+ .fail(_ajaxFail );
152165 }
153166
154- // Bind event(s)
155- function bind() {
167+ /**
168+ * Bind events
169+ *
170+ * @return {undefined}
171+ */
172+ function _bindEvents() {
156173 // Namespace the 'click' event
157- $_ajax .on('click.app.rest.module', function (event) {
174+ _$ajax .on('click.app.rest.module', function (event) {
158175 event.preventDefault();
159176
160177 // Pass this to the Ajax event function
161- ajaxEvent ($(this));
178+ _ajaxEvent ($(this));
162179 });
163180 }
164181
165- // Cache the DOM node(s)
166- function cacheDom() {
167- $_ajax = $('#ajax');
182+ /**
183+ * Cache the DOM node(s)
184+ *
185+ * @return {undefined}
186+ */
187+ function _cacheDom() {
188+ _$ajax = $('#ajax');
168189 }
169190
170191 // Public API
171192 return {
172193 init: function () {
173194 // Cache the DOM and bind event(s)
174- cacheDom ();
175- bind ();
195+ _cacheDom ();
196+ _bindEvents ();
176197 }
177198 };
178- })(window, jQuery);
199+ })(window, window. jQuery);
179200
180201 // DOM ready event
181202 $(function () {
You can’t perform that action at this time.
0 commit comments