|
25 | 25 | proto = $.fn;
|
26 | 26 |
|
27 | 27 | $.Deferred.prototype.toObservable = function () {
|
| 28 | + /// <summary>Converts a jQuery Deferred object to an Observable sequence.</summary> |
| 29 | + /// <returns>An Observable sequenced defined from the jQuery Deferred object.</returns> |
28 | 30 | var subject = new asyncSubject();
|
29 |
| - parent.done(function () { |
| 31 | + this.done(function () { |
30 | 32 | subject.onNext(slice.call(arguments));
|
31 | 33 | subject.onCompleted();
|
32 | 34 | }).fail(function () {
|
|
36 | 38 | };
|
37 | 39 |
|
38 | 40 | observableProto.toDeferred = function () {
|
| 41 | + /// <summary>Converts an existing Observable sequence to a jQuery Deferred object.</summary> |
| 42 | + /// <returns>A jQuery Deferred object</returns> |
39 | 43 | var deferred = $.Deferred();
|
40 | 44 | this.subscribe(function (value) {
|
41 | 45 | deferred.resolve(value);
|
|
159 | 163 | return this.bindAsObservable('scroll', eventData);
|
160 | 164 | };
|
161 | 165 | proto.selectAsObservable = function(eventData) {
|
| 166 | + /// <summary> |
| 167 | + /// Bind an event handler to the "select" JavaScript event, or trigger that event on an element as an Observable sequence. |
| 168 | + /// 1 - selectAsObservable() |
| 169 | + /// 2 - selectAsObservable(eventData) |
| 170 | + /// </summary> |
| 171 | + /// <param name="data" type="Object"> |
| 172 | + /// A map of data that will be passed to the event handler. |
| 173 | + /// </param> |
| 174 | + /// <returns>An Observable sequence</returns> |
162 | 175 | return this.bindAsObservable('select', eventData);
|
163 | 176 | };
|
164 | 177 | proto.submitAsObservable = function(eventData) {
|
| 178 | + /// <summary> |
| 179 | + /// Bind an event handler to the "submit" JavaScript event, or trigger that event on an element as an Observable sequence. |
| 180 | + /// 1 - submitAsObservable() |
| 181 | + /// 2 - submitAsObservable(eventData) |
| 182 | + /// </summary> |
| 183 | + /// <param name="data" type="Object"> |
| 184 | + /// A map of data that will be passed to the event handler. |
| 185 | + /// </param> |
| 186 | + /// <returns>An Observable sequence</returns> |
165 | 187 | return this.bindAsObservable('submit', eventData);
|
166 | 188 | };
|
167 | 189 | proto.unloadAsObservable = function(eventData) {
|
| 190 | + /// <summary> |
| 191 | + /// Bind an event handler to the "unload" JavaScript event as an Observable sequence. |
| 192 | + /// 1 - unloadAsObservable() |
| 193 | + /// 2 - unloadAsObservable(eventData) |
| 194 | + /// </summary> |
| 195 | + /// <param name="data" type="Object"> |
| 196 | + /// A map of data that will be passed to the event handler. |
| 197 | + /// </param> |
| 198 | + /// <returns>An Observable sequence</returns> |
168 | 199 | return this.bindAsObservable('unload', eventData);
|
169 | 200 | };
|
170 |
| - proto.oneAsObservable = function(eventType, eventData) { |
| 201 | + proto.oneAsObservable = function(types, selector, data) { |
| 202 | + /// <summary> |
| 203 | + /// Attach a handler to an event for the elements as an Observable sequence.. The Observer onNext handler is executed at most once per element. |
| 204 | + /// 1 - oneAsObservable(events, data) |
| 205 | + /// 2 - oneAsObservable(events, selector, data) |
| 206 | + /// </summary> |
| 207 | + /// <param name="types" type="String"> |
| 208 | + /// One or more space-separated event types and optional namespaces, such as "click" or "keydown.myPlugin". |
| 209 | + /// </param> |
| 210 | + /// <param name="selector" type="String"> |
| 211 | + /// A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element. |
| 212 | + /// </param> |
| 213 | + /// <param name="data" type="Anything"> |
| 214 | + /// Data to be passed to the handler in event.data when an event is triggered. |
| 215 | + /// </param> |
| 216 | + /// <returns>An Observable sequence</returns> |
171 | 217 | var parent = this;
|
172 | 218 | return observableCreateWithDisposable(function(observer) {
|
173 | 219 | var handler = function(eventObject) {
|
174 |
| - parent.unbind(eventType, handler); |
| 220 | + parent.off(types, selector, data, handler); |
175 | 221 | observer.onNext(eventObject);
|
176 | 222 | observer.onCompleted();
|
177 | 223 | };
|
178 |
| - parent.bind(eventType, eventData, handler); |
| 224 | + parent.on(types, selector, data, handler); |
179 | 225 | return dispoableEmpty;
|
180 | 226 | });
|
181 | 227 | };
|
182 | 228 | proto.readyAsObservable = function() {
|
| 229 | + /// <summary> |
| 230 | + /// Specify a function to execute when the DOM is fully loaded as an Observable sequence. |
| 231 | + /// </summary> |
| 232 | + /// <returns>An Observable sequence</returns> |
183 | 233 | var parent = this;
|
184 | 234 | return observableCreateWithDisposable(function(observer) {
|
185 | 235 | var handler = function(eventObject) {
|
|
189 | 239 | return dispoableEmpty;
|
190 | 240 | });
|
191 | 241 | };
|
192 |
| - proto.hideAsObservable = function(duration) { |
| 242 | + proto.hideAsObservable = function(duration, easing) { |
| 243 | + /// <summary> |
| 244 | + /// Hide the matched elements as an Observable sequence. |
| 245 | + /// 1 - hideAsObservable() |
| 246 | + /// 2 - hideAsObservable(duration) |
| 247 | + /// 3 - hideAsObservable(duration, easing) |
| 248 | + /// </summary> |
| 249 | + /// <param name="speed" type="Number"> |
| 250 | + /// A string or number determining how long the animation will run. |
| 251 | + /// </param> |
| 252 | + /// <param name="easing" type="String"> |
| 253 | + /// A string indicating which easing function to use for the transition. |
| 254 | + /// </param> |
| 255 | + /// <returns>An Observable sequence</returns> |
193 | 256 | var subject = new asyncSubject();
|
194 |
| - this.hide(duration, function() { |
| 257 | + this.hide(duration, easing, function() { |
195 | 258 | subject.onNext(this);
|
196 | 259 | subject.onCompleted();
|
197 | 260 | });
|
198 | 261 | return subject;
|
199 | 262 | };
|
200 |
| - proto.showAsObservable = function(duration) { |
| 263 | + proto.showAsObservable = function(duration, easing) { |
| 264 | + /// <summary> |
| 265 | + /// Display the matched elements as an Observable sequence. |
| 266 | + /// 1 - showAsObservable() |
| 267 | + /// 2 - showAsObservable(duration) |
| 268 | + /// 3 - showAsObservable(duration, easing) |
| 269 | + /// </summary> |
| 270 | + /// <param name="speed" type="Number"> |
| 271 | + /// A string or number determining how long the animation will run. |
| 272 | + /// </param> |
| 273 | + /// <param name="easing" type="String"> |
| 274 | + /// A string indicating which easing function to use for the transition. |
| 275 | + /// </param> |
| 276 | + /// <returns>An Observable sequence</returns> |
201 | 277 | var subject = new asyncSubject();
|
202 | 278 | this.show(duration, function() {
|
203 | 279 | subject.onNext(this);
|
|
206 | 282 | return subject;
|
207 | 283 | };
|
208 | 284 | proto.animateAsObservable = function(properties, duration, easing) {
|
| 285 | + /// <summary> |
| 286 | + /// Perform a custom animation of a set of CSS properties as an Observable sequence. |
| 287 | + /// 1 - animate(properties, duration, easing) |
| 288 | + /// </summary> |
| 289 | + /// <param name="prop" type="Object"> |
| 290 | + /// A map of CSS properties that the animation will move toward. |
| 291 | + /// </param> |
| 292 | + /// <param name="speed" type="Number"> |
| 293 | + /// A string or number determining how long the animation will run. |
| 294 | + /// </param> |
| 295 | + /// <param name="easing" type="String"> |
| 296 | + /// A string indicating which easing function to use for the transition. |
| 297 | + /// </param> |
| 298 | + /// <returns>An Observable sequence</returns> |
209 | 299 | var subject = new asyncSubject();
|
210 | 300 | this.animate(properties, duration, easing, function() {
|
211 | 301 | subject.onNext(this);
|
212 | 302 | subject.onCompleted();
|
213 | 303 | });
|
214 | 304 | return subject;
|
215 | 305 | };
|
216 |
| - proto.fadeInAsObservable = function(duration) { |
| 306 | + proto.fadeInAsObservable = function(duration, easing) { |
| 307 | + /// <summary> |
| 308 | + /// Display the matched elements by fading them to opaque as an Observable sequence. |
| 309 | + /// 1 - fadeInAsObservable(duration) |
| 310 | + /// 2 - fadeInAsObservable(duration, easing) |
| 311 | + /// </summary> |
| 312 | + /// <param name="speed" type="Number"> |
| 313 | + /// A string or number determining how long the animation will run. |
| 314 | + /// </param> |
| 315 | + /// <param name="easing" type="String"> |
| 316 | + /// A string indicating which easing function to use for the transition. |
| 317 | + /// </param> |
| 318 | + /// <returns>An Observable sequence</returns> |
217 | 319 | var subject = new asyncSubject();
|
218 |
| - this.fadeIn(duration, function() { |
| 320 | + this.fadeIn(duration, easing, function() { |
219 | 321 | subject.onNext(this);
|
220 | 322 | subject.onCompleted();
|
221 | 323 | });
|
222 | 324 | return subject;
|
223 | 325 | };
|
224 |
| - proto.fadeToAsObservable = function(duration, opacity) { |
| 326 | + proto.fadeToAsObservable = function(duration, opacity, easing) { |
| 327 | + /// <summary> |
| 328 | + /// Adjust the opacity of the matched elements as an Observable sequence. |
| 329 | + /// 1 - fadeToAsObservable(duration, opacity) |
| 330 | + /// 2 - fadeToAsObservable(duration, opacity, easing) |
| 331 | + /// </summary> |
| 332 | + /// <param name="speed" type="Number"> |
| 333 | + /// A string or number determining how long the animation will run. |
| 334 | + /// </param> |
| 335 | + /// <param name="to" type="Number"> |
| 336 | + /// A number between 0 and 1 denoting the target opacity. |
| 337 | + /// </param> |
| 338 | + /// <param name="easing" type="String"> |
| 339 | + /// A string indicating which easing function to use for the transition. |
| 340 | + /// </param> |
| 341 | + /// <returns>An Observable sequence</returns> |
225 | 342 | var subject = new asyncSubject();
|
226 |
| - this.fadeTo(duration, opacity, function() { |
| 343 | + this.fadeTo(duration, opacity, easing, function() { |
227 | 344 | subject.onNext(this);
|
228 | 345 | subject.onCompleted();
|
229 | 346 | });
|
230 | 347 | return subject;
|
231 | 348 | };
|
232 |
| - proto.fadeOutAsObservable = function(duration) { |
| 349 | + proto.fadeOutAsObservable = function(duration, easing) { |
| 350 | + /// <summary> |
| 351 | + /// Hide the matched elements by fading them to transparent. |
| 352 | + /// 1 - fadeOutAsObservable(duration) |
| 353 | + /// 2 - fadeOutAsObservable(duration, easing) |
| 354 | + /// </summary> |
| 355 | + /// <param name="speed" type="Number"> |
| 356 | + /// A string or number determining how long the animation will run. |
| 357 | + /// </param> |
| 358 | + /// <param name="easing" type="String"> |
| 359 | + /// A string indicating which easing function to use for the transition. |
| 360 | + /// </param> |
| 361 | + /// <returns>An Observable sequence</returns> |
233 | 362 | var subject = new asyncSubject();
|
234 |
| - this.fadeOut(duration, function() { |
| 363 | + this.fadeOut(duration, easing, function() { |
235 | 364 | subject.onNext(this);
|
236 | 365 | subject.onCompleted();
|
237 | 366 | });
|
238 | 367 | return subject;
|
239 | 368 | };
|
240 | 369 | proto.fadeToggleAsObservable = function(duration, easing) {
|
| 370 | + /// <summary> |
| 371 | + /// Display or hide the matched elements by animating their opacity as an Observable sequence. |
| 372 | + /// </summary> |
| 373 | + /// <param name="speed" type="Number"> |
| 374 | + /// A string or number determining how long the animation will run. |
| 375 | + /// </param> |
| 376 | + /// <param name="easing" type="String"> |
| 377 | + /// A string indicating which easing function to use for the transition. |
| 378 | + /// </param> |
| 379 | + /// <returns>An Observable sequence</returns> |
241 | 380 | var subject = new asyncSubject();
|
242 | 381 | this.fadeToggle(duration, easing, function() {
|
243 | 382 | subject.onNext(this);
|
|
0 commit comments