mootools

Javascript Dynamic Grouping

痴心易碎 提交于 2019-12-06 12:41:49
问题 I am trying to create a table, with some grouping headers. All is well when i have 1 group, but how do i create dynamic groups? This is what i have so far (for 1 group): var groupby = ''; arrdata.each(function(element){ if (groupby != element.groupby) { groupby = element.groupby; tbody.push(groupby) } tbody.push(element) }) How do i make it create dynamic groups? 回答1: You could group them into an Object first: Array.prototype.groupBy = function(keyName) { var res = {}; this.forEach(function(x

How to change CSS styling depends on the browser

China☆狼群 提交于 2019-12-06 11:25:28
I know there's a browser detection in mootools. Therefore, I want to know how to change the CSS styling depends on browser? -v- if ( Browser.chrome ) { document.id('foo').addClass('bar'); } For more see Mootools documentation for Browser Perhaps the following CSS Hacks will serve: http://www.cssblog.es/hacks-css-mediante-selectores/ Regards! for a personal reminder, I posted this small example on jsfiddle : http://www.jsfiddle.net/ghazal/XUXAP/ Maybe it'll help you Cheers. 2 ways: Server Side Detect user agent string and serve the associated style sheet during page generation. Conditional

Mootools class variable scope

瘦欲@ 提交于 2019-12-06 09:31:01
Take this class: var MyClass = new Class({ Implements: [Events, Options], initialize: function() { this.a = 1; }, myMethod: function() { var mc = new differentClass({ events: { onClick: function() { console.log(this.a); // undefined (should be 1, 2, 3 etc) this.a ++; } } }); } }); How do I keep the value of this.a ? I am basically trying to draw a line (using canvas) from the last point to the co-ordinates just clicked. [EDIT] I dont want to bind this as it's bad apparently and it will over-ride the differentClass options. several patterns are available. decorator via .bind() var mc = new

Ajax login form - browsers won't save password

陌路散爱 提交于 2019-12-06 08:33:48
问题 I have Ajax login form, which is checking whether given credentials are correct and redirects to another page. The login form itself is built by a HXR call - it isn't built in the login page code. The problem is that I can't get browsers to prompt for remembering passwords. Once I've got the Firefox to prompt but since the form is being built by XHR call, the Firefox didn't paste the values into the form. PS. I am using mootools (Form.send) and usual window.location when login was successful.

如何使用JavaScript复制到剪贴板?

早过忘川 提交于 2019-12-06 06:48:31
将文本复制到剪贴板的最佳方法是什么? (多浏览器) 我试过了: function copyToClipboard(text) { if (window.clipboardData) { // Internet Explorer window.clipboardData.setData("Text", text); } else { unsafeWindow.netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); const clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"].getService(Components.interfaces.nsIClipboardHelper); clipboardHelper.copyString(text); } } 但是在Internet Explorer中,它会给出语法错误。 在Firefox中,它说 unsafeWindow is not defined 。 一个没有闪光灯的好技巧: Trello如何访问用户的剪贴板? #1楼 我发现以下解决方案: 在按下按键时,处理程序会创建“ pre”标签。 我们将内容设置为复制到此标签

mootools: I want to implement architecture similar to Big pipe in Facebook

随声附和 提交于 2019-12-06 06:38:12
问题 I am developing an application in mootools. I have used Reqeust class to implement pipelining it. I want to develop a superior method to handle client server requests. I referred the following article to understand how big pipe works in facebook. http://www.facebook.com/notes/facebook-engineering/bigpipe-pipelining-web-pages-for-high-performance/389414033919 In facebook, a javascript function is called on arrival of any server response to update data user screen. (see the screenshot) http:/

Jquery Vs Mootools which is having good performance? why?

百般思念 提交于 2019-12-06 06:14:06
Can any one reply me which of the javascript frameworks are better to implement on my project? jQuery or Mootools? It's a matter of what coding style do you prefer and can help you in the long term. Just because other people use jQuery doesn't make it any easier for me to learn the way that it's coded. This is a must for you to read before you go any further: http://jqueryvsmootools.com/ MooTools has the better API and once you actually use it, you'll see how the design choices make sense. Try them both, but you'll stay for the extendability of MooTools In the last performance comparison I

Giving inline-block elements with variable content the same height?

让人想犯罪 __ 提交于 2019-12-06 05:50:51
问题 I have 4 inline-block elements with fixed width but variable content, and I want all of these elements to have the same height - that of the largest element. Please see This jsfiddle. How should I achieve this? If its not possible to do it using only css, what is the right way to do it using javascript? 回答1: probably better to make it modular and reusable, in mootools, you can prototype a HTML collection: Elements.implement({ setEqualHeight: function(height) { height = height || Math.max

Javascript scrollbar class and mousewheel speed in different browsers

时光怂恿深爱的人放手 提交于 2019-12-06 02:52:38
I'm getting many reports that the mousewheel behaves differently in different browsers when using this scrollbar class. In some browsers (like Firefox) it's extremely slow while in others (mostly newer versions of Safari on Snow Leopard) it's perfect. Any ideas what's going on here and how to fix it? I'm using the Mootools library. One line to pay attention to here is the wheel: (Browser.firefox) ? 20 : 1 line. This is where you set the speed or steps for the mousewheel. Here it is set up in a jsFiddle: http://jsfiddle.net/brandondurham/6SUyM/ var ScrollBar = new Class({ Implements: [Events,

MooTools教程(5):事件处理

和自甴很熟 提交于 2019-12-06 00:57:03
今天我们开始第五讲,在上一讲( 《Mootools 1.2教程(4)——函数》 )中,我们学习了在MooTools 1.2中建立和使用函数的几种不同方式。下一步就是理解事件了。和选择器类似,事件也是建立互动界面的一个重要部分。一旦你掌握了一个元素,你需要去决定什么行为来触发什么效果。先把效果留着以后在讲,我们首先看一看中间步骤和一些常见的事件。 左键单击事件 左键单击事件是web开发中最常见的事件。超链接识别点击事件,然后把你带到另外一个URL地址。MooTools能够识别其他DOM元素上的点击事件,在设计和功能上给了你极大的灵活性。给一个元素添加一个点击事件的第一步: // 通过$('id_name') 取得一个元素 // 用.addEvent添加事件 // ('click')定义了事件的类型 $('id_name').addEvent('click', function(){ // 在这里添加点击事件发生时你要执行的任何代码 alert('this element now recognizes the click event'); }); 你也可以把这个函数从.addEvent();独立出来来完成相同的事情: var clickFunction = function(){ // 在这里添加事件发生时你要执行的任何代码 alert('this element now