• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript subjquery.tQuery函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中thrust/dom/subjquery.tQuery函数的典型用法代码示例。如果您正苦于以下问题:TypeScript tQuery函数的具体用法?TypeScript tQuery怎么用?TypeScript tQuery使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了tQuery函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: it

            it('Mixed event bindings and types', () =>
            {
                // Mixed event bindings and types
                counter = 0;
                mixfn = (e, trig) =>
                {
                    counter += (e.data || 0) + (trig || 1);
                };
                tQuery("#onandoff")
                    .on(" click  clack cluck ", "em", 2, mixfn)
                    .on("cluck", "b", 7, mixfn)
                    .on("cluck", mixfn)
                    .trigger("what!")
                    .each(() =>
                    {
                        expect(counter).toBe(0);
                    })
                    .find("em")
                        .one("cluck", 3, mixfn)
                        .trigger("cluck", 8)			// 3+8 2+8 + 0+8 = 29
                        .off()
                        .trigger("cluck", 9)			// 2+9 + 0+9 = 20
                    .end()
                    .each(() =>
                    {
                        expect(counter).toBe(49);
                    })
                    .off("cluck", () => { })		// shouldn't remove anything
                    .trigger("cluck", 2)				// 0+2 = 2
                    .each(() =>
                    {
                        expect(counter).toBe(51);
                    })
                    .find("b")
                        .on("click", 95, mixfn)
                        .on("clack", "p", 97, mixfn)
                        .one("cluck", 3, mixfn)
                        .trigger("quack", 19)			// 0
                        .off("click clack cluck")
                    .end()
                    .each(() =>
                    {
                        expect(counter).toBe(51);
                    })
                    .trigger("cluck", 3)				// 0+3 = 3
                    .off("clack", "em", mixfn)
                    .find("em")
                        .trigger("clack")				// 0
                    .end()
                    .each(() =>
                    {
                        expect(counter).toBe(54);
                    })
                    .off("click cluck");

                $onandoff.remove();
            });
开发者ID:david-driscoll,项目名称:thrust,代码行数:57,代码来源:event.ts


示例2: it

        it('changes namespaces', () =>
        {
            expect(parentContext.namespace).toBe(namespace);

            var childOfParentContext = parentContext.find('div');
            expect(childOfParentContext.namespace).toBe(namespace);

            var customContext = tQuery(childOfParentContext, undefined, childNamespace);
            expect(customContext.namespace).toBe(childNamespace);

            var childOfCustomContext = customContext.children();
            expect(childOfCustomContext.namespace).toBe(childNamespace);
        });
开发者ID:david-driscoll,项目名称:thrust,代码行数:13,代码来源:tquery.ts


示例3: beforeEach

 beforeEach(() =>
 {
     $divs = tQuery('<div><div></div><div></div></div><div></div><div></div><div></div><div><div></div><div></div></div>').appendTo(document.body);
     parentContext = tQuery(document.body, null, namespace);
 });
开发者ID:david-driscoll,项目名称:thrust,代码行数:5,代码来源:tquery.ts


示例4: xit

            xit("special bind/delegate name mapping", () =>
            {
                var spy1 = jasmine.createSpy('spy1');
                tQuery.event.special["slap"] = {
                    bindType: "click",
                    delegateType: "swing",
                    handle: spy1
                };

                var comeback = jasmine.createSpy('comeback');

                tQuery("<div><button id=\"mammy\">Are We Not Men?</button></div>")
                    .on("slap", "button", tQuery.noop)
                    .on("swing", "button", comeback)
                    .find("button")
                        .on("slap", tQuery.noop)
                        .on("click", comeback)
                        .trigger("click")		// bindType-slap and click
                        .off("slap")
                        .trigger("click")		// click
                        .off("click")
                        .trigger("swing")		// delegateType-slap and swing
                    .end()
                    .off("slap swing", "button")
                    .find("button")			// everything should be gone
                        .trigger("slap")
                        .trigger("click")
                        .trigger("swing")
                    .end()
                    .remove();
                delete tQuery.event.special["slap"];

                expect(spy1).toHaveBeenCalled();
                expect(spy1.callCount).toBe(3);
                expect(comeback).toHaveBeenCalled();
                expect(comeback.callCount).toBe(3);

                var spy2 = jasmine.createSpy('spy2');
                tQuery.event.special["gutfeeling"] = {
                    bindType: "click",
                    delegateType: "click",
                    handle: function (event) {
                        spy2.apply(this, arguments);
                        // Need to call the handler since .one() uses it to unbind
                        return event.handleObj.handler.call(this, event);
                    }
                };

                // Ensure a special event isn't removed by its mapped type
                tQuery("<p>Gut Feeling</p>")
                    .on("click", tQuery.noop)
                    .on("gutfeeling", tQuery.noop)
                    .off("click")
                    .trigger("gutfeeling")
                    .remove();

                // Ensure special events are removed when only a namespace is provided
                tQuery("<p>Gut Feeling</p>")
                    .on("gutfeeling.Devo", tQuery.noop)
                    .off(".Devo")
                    .trigger("gutfeeling")
                    .remove();

                // Ensure .one() events are removed after their maiden voyage
                tQuery("<p>Gut Feeling</p>")
                    .one("gutfeeling", tQuery.noop)
                    .trigger("gutfeeling")	// This one should
                    .trigger("gutfeeling")	// This one should not
                    .remove();

                expect(spy2).toHaveBeenCalled();
                expect(spy2.callCount).toBe(2);

                delete tQuery.event.special["gutfeeling"];
            });
开发者ID:david-driscoll,项目名称:thrust,代码行数:75,代码来源:event.ts


示例5: describe

        describe("tQuery - .on and .off", function () {
            var counter, mixfn;

            var $onandoff = tQuery("<div id=\"onandoff\"><p>on<b>and</b>off</p><div>worked<em>or</em>borked?</div></div>").appendTo("body");

            it('whippted it good', () =>
            {
                var eventRun = false;
                // Simple case
                tQuery("#onandoff")
                    .on("whip", () =>
                    {
                        eventRun = true;
                    })
                    .trigger("whip")
                    .off();
                expect(eventRun).toBe(true);
            });

            it('Direct events only - direct event bindings with data', () =>
            {
                // Direct events only
                counter = 0;
                tQuery("#onandoff b")
                    .on("click", 5, (e, trig) =>
                    {
                        counter += e.data + (trig || 9);	// twice, 5+9+5+17=36
                    })
                    .one("click", 7, (e, trig) =>
                    {
                        counter += e.data + (trig || 11);	// once, 7+11=18
                    })
                    .trigger('click')
                    .trigger("click", 17)
                    .off("click");
                expect(counter).toBe(54);
            });

            it('Delegated events only - delegated event bindings with data', () =>
            {
                // Delegated events only
                counter = 0;
                tQuery("#onandoff")
                    .on("click", "em", 5, (e, trig) =>
                    {
                        counter += e.data + (trig || 9);	// twice, 5+9+5+17=36
                    })
                    .one("click", "em", 7, (e, trig) =>
                    {
                        counter += e.data + (trig || 11);	// once, 7+11=18
                    })
                    .find("em")
                        .trigger('click')
                        .trigger("click", 17)
                    .end()
                    .off("click", "em");
                expect(counter).toBe(54);
            });

            it('Mixed event bindings and types', () =>
            {
                // Mixed event bindings and types
                counter = 0;
                mixfn = (e, trig) =>
                {
                    counter += (e.data || 0) + (trig || 1);
                };
                tQuery("#onandoff")
                    .on(" click  clack cluck ", "em", 2, mixfn)
                    .on("cluck", "b", 7, mixfn)
                    .on("cluck", mixfn)
                    .trigger("what!")
                    .each(() =>
                    {
                        expect(counter).toBe(0);
                    })
                    .find("em")
                        .one("cluck", 3, mixfn)
                        .trigger("cluck", 8)			// 3+8 2+8 + 0+8 = 29
                        .off()
                        .trigger("cluck", 9)			// 2+9 + 0+9 = 20
                    .end()
                    .each(() =>
                    {
                        expect(counter).toBe(49);
                    })
                    .off("cluck", () => { })		// shouldn't remove anything
                    .trigger("cluck", 2)				// 0+2 = 2
                    .each(() =>
                    {
                        expect(counter).toBe(51);
                    })
                    .find("b")
                        .on("click", 95, mixfn)
                        .on("clack", "p", 97, mixfn)
                        .one("cluck", 3, mixfn)
                        .trigger("quack", 19)			// 0
                        .off("click clack cluck")
                    .end()
                    .each(() =>
//.........这里部分代码省略.........
开发者ID:david-driscoll,项目名称:thrust,代码行数:101,代码来源:event.ts



注:本文中的thrust/dom/subjquery.tQuery函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript thunks.thunk类代码示例发布时间:2022-05-25
下一篇:
TypeScript through2.obj函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap