/* This file is part of Ext JS 3.4 Copyright (c) 2011-2013 Sencha Inc Contact: http://www.sencha.com/contact GNU General Public License Usage This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. Build date: 2013-04-03 15:07:25 */ Ext.data.JsonP.Ext_DomHelper({"alternateClassNames":[],"aliases":{},"enum":null,"parentMixins":[],"tagname":"class","subclasses":[],"extends":null,"uses":[],"html":"
Files
The DomHelper class provides a layer of abstraction from DOM and transparently supports creating\nelements via DOM or using HTML fragments. It also has the ability to create HTML fragment templates\nfrom your DOM building code.
\n\n\n\n\nDomHelper element specification object
\n\n\nA specification object is used when creating elements. Attributes of this object\nare assumed to be element attributes, except for 4 special attributes:\n
Insertion methods
\n\n\nCommonly used insertion methods:\n
Example
\n\n\nThis is an example, where an unordered list with 3 children items is appended to an existing\nelement with id 'my-div':
\n \n
var dh = Ext.DomHelper; // create shorthand alias\n// specification object\nvar spec = {\n id: 'my-ul',\n tag: 'ul',\n cls: 'my-list',\n // append children after creating\n children: [ // may also specify 'cn' instead of 'children'\n {tag: 'li', id: 'item0', html: 'List Item 0'},\n {tag: 'li', id: 'item1', html: 'List Item 1'},\n {tag: 'li', id: 'item2', html: 'List Item 2'}\n ]\n};\nvar list = dh.append(\n 'my-div', // the context element 'my-div' can either be the id or the actual node\n spec // the specification object\n);\n
\n\n\nElement creation specification parameters in this class may also be passed as an Array of\nspecification objects. This can be used to insert multiple sibling nodes into an existing\ncontainer very efficiently. For example, to add more list items to the example above:\n
dh.append('my-ul', [\n {tag: 'li', id: 'item3', html: 'List Item 3'},\n {tag: 'li', id: 'item4', html: 'List Item 4'}\n]);\n
\n\n\n\n\nTemplating
\n\n\nThe real power is in the built-in templating. Instead of creating or appending any elements,\ncreateTemplate returns a Template object which can be used over and over to\ninsert new elements. Revisiting the example above, we could utilize templating this time:\n
// create the node\nvar list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});\n// get template\nvar tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});\n\nfor(var i = 0; i < 5, i++){\n tpl.append(list, [i]); // use template to append to the actual node\n}\n
\nAn example using a template:\n
var html = '{2}';\n\nvar tpl = new Ext.DomHelper.createTemplate(html);\ntpl.append('blog-roll', ['link1', 'http://www.jackslocum.com/', \"Jack's Site\"]);\ntpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', \"Dustin's Site\"]);\n
\n\nThe same example using named parameters:\n
var html = '{text}';\n\nvar tpl = new Ext.DomHelper.createTemplate(html);\ntpl.append('blog-roll', {\n id: 'link1',\n url: 'http://www.jackslocum.com/',\n text: \"Jack's Site\"\n});\ntpl.append('blog-roll', {\n id: 'link2',\n url: 'http://www.dustindiaz.com/',\n text: \"Dustin's Site\"\n});\n
\n\nCompiling Templates
\nTemplates are applied using regular expressions. The performance is great, but if\nyou are adding a bunch of DOM elements using the same template, you can increase\nperformance even further by "compiling" the template.\nThe way \"compile()\" works is the template is parsed and\nbroken up at the different variable points and a dynamic function is created and eval'ed.\nThe generated function performs string concatenation of these parts and the passed\nvariables instead of using regular expressions.\n
var html = '{text}';\n\nvar tpl = new Ext.DomHelper.createTemplate(html);\ntpl.compile();\n\n//... use template like normal\n
\n\nPerformance Boost
\nDomHelper will transparently create HTML fragments when it can. Using HTML fragments instead\nof DOM can significantly boost performance.
\nElement creation specification parameters may also be strings. If useDom is false,\nthen the string is used as innerHTML. If useDom is true, a string specification\nresults in the creation of a text node. Usage:
\nExt.DomHelper.useDom = true; // force it to use DOM; reduces performance\n
\n\nSince we're using the g flag on the regex, we need to set the lastIndex.\nThis automatically happens on some implementations, but not others, see:\nhttp://stackoverflow.com/questions/2645273/javascript-regular-expression-literal-persists-between-function-calls\nhttp://blog.stevenlevithan.com/archives/fixing-javascript-regexp
\nDefaults to: 0
True to force the use of DOM instead of html fragments
\nDefaults to: false
Creates new DOM element(s) and appends them to el.
\nThe context element
\nThe DOM object spec (and children) or raw HTML blob
\ntrue to return a Ext.Element
\nThe new node
\nCreates new DOM element(s) without inserting them to the document.
\nThe DOM object spec (and children) or raw HTML blob
\nThe new uninserted node
\nCreates a new Ext.Template from the DOM object spec.
\nThe DOM object spec (and children)
\nThe new template
\nCreates new DOM element(s) and inserts them after el.
\nThe context element
\nThe DOM object spec (and children)
\ntrue to return a Ext.Element
\nThe new node
\nCreates new DOM element(s) and inserts them before el.
\nThe context element
\nThe DOM object spec (and children) or raw HTML blob
\ntrue to return a Ext.Element
\nThe new node
\nCreates new DOM element(s) and inserts them as the first child of el.
\nThe context element
\nThe DOM object spec (and children) or raw HTML blob
\ntrue to return a Ext.Element
\nThe new node
\nReturns the markup for the passed Element(s) config.
\nThe DOM object spec (and children)
\nCreates new DOM element(s) and overwrites the contents of el with them.
\nThe context element
\nThe DOM object spec (and children) or raw HTML blob
\ntrue to return a Ext.Element
\nThe new node
\n