Requires

Provides

One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements.

License:
MIT-style license.
  1. 18
  2. 19
  3. 20
  4. 21
  5. 22
  6. 23
  7. 24
  8. 25
  9. 26
  10. 27
  11. 28
  12. 29
  13. 30
  14. 31
  15. 32
  16. 33
  17. 34
  18. 35
  19. 36
  20. 37
  21. 38
  22. 39
  23. 40
  24. 41
  25. 42
  26. 43
  27. 44
  28. 45
  29. 46
  30. 47
  31. 48
  32. 49
  33. 50
  34. 51
  35. 52
  36. 53
  37. 54
  38. 55
  39. 56
  40. 57
  41. 58
  42. 59
  43. 60
  44. 61
  45. 62
  46. 63
  47. 64
  48. 65
  49. 66
  50. 67
  51. 68
  52. 69
  53. 70
  54. 71
var Element = function(tag, props){ var konstructor = Element.Constructors[tag]; if (konstructor) return konstructor(props); if (typeof tag != 'string') return document.id(tag).set(props); if (!props) props = {}; if (!(/^[\w-]+$/).test(tag)){ var parsed = Slick.parse(tag).expressions[0][0]; tag = (parsed.tag == '*') ? 'div' : parsed.tag; if (parsed.id && props.id == null) props.id = parsed.id; var attributes = parsed.attributes; if (attributes) for (var i = 0, l = attributes.length; i < l; i++){ var attr = attributes[i]; if (attr.value != null && attr.operator == '=' && props[attr.key] == null) props[attr.key] = attr.value; } if (parsed.classList && props['class'] == null) props['class'] = parsed.classList.join(' '); } return document.newElement(tag, props); }; if (Browser.Element) Element.prototype = Browser.Element.prototype; new Type('Element', Element).mirror(function(name){ if (Array.prototype[name]) return; var obj = {}; obj[name] = function(){ var results = [], args = arguments, elements = true; for (var i = 0, l = this.length; i < l; i++){ var element = this[i], result = results[i] = element[name].apply(element, args); elements = (elements && typeOf(result) == 'element'); } return (elements) ? new Elements(results) : results; }; Elements.implement(obj); }); if (!Browser.Element){ Element.parent = Object; Element.Prototype = {'$family': Function.from('element').hide()}; Element.mirror(function(name, method){ Element.Prototype[name] = method; }); } Element.Constructors = {};

<1.2compat>

  1. 75
Element.Constructors = new Hash;

</1.2compat>

  1. 79
  2. 80
  3. 81
  4. 82
  5. 83
  6. 84
  7. 85
  8. 86
  9. 87
  10. 88
  11. 89
  12. 90
  13. 91
  14. 92
  15. 93
  16. 94
  17. 95
  18. 96
  19. 97
  20. 98
  21. 99
  22. 100
  23. 101
  24. 102
  25. 103
  26. 104
  27. 105
  28. 106
  29. 107
  30. 108
  31. 109
  32. 110
  33. 111
  34. 112
  35. 113
  36. 114
  37. 115
  38. 116
  39. 117
  40. 118
  41. 119
  42. 120
  43. 121
  44. 122
  45. 123
  46. 124
  47. 125
  48. 126
  49. 127
  50. 128
  51. 129
  52. 130
  53. 131
  54. 132
  55. 133
  56. 134
  57. 135
  58. 136
  59. 137
  60. 138
  61. 139
  62. 140
  63. 141
  64. 142
  65. 143
  66. 144
  67. 145
  68. 146
  69. 147
  70. 148
  71. 149
  72. 150
  73. 151
  74. 152
  75. 153
  76. 154
  77. 155
  78. 156
  79. 157
  80. 158
  81. 159
  82. 160
  83. 161
  84. 162
  85. 163
  86. 164
  87. 165
  88. 166
var IFrame = new Type('IFrame', function(){ var params = Array.link(arguments, { properties: Type.isObject, iframe: function(obj){ return (obj != null); } }); var props = params.properties || {}, iframe; if (params.iframe) iframe = document.id(params.iframe); var onload = props.onload || function(){}; delete props.onload; props.id = props.name = [props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + String.uniqueID()].pick(); iframe = new Element(iframe || 'iframe', props); var onLoad = function(){ onload.call(iframe.contentWindow); }; if (window.frames[props.id]) onLoad(); else iframe.addListener('load', onLoad); return iframe; }); var Elements = this.Elements = function(nodes){ if (nodes && nodes.length){ var uniques = {}, node; for (var i = 0; node = nodes[i++];){ var uid = Slick.uidOf(node); if (!uniques[uid]){ uniques[uid] = true; this.push(node); } } } }; Elements.prototype = {length: 0}; Elements.parent = Array; new Type('Elements', Elements).implement({ filter: function(filter, bind){ if (!filter) return this; return new Elements(Array.filter(this, (typeOf(filter) == 'string') ? function(item){ return item.match(filter); } : filter, bind)); }.protect(), push: function(){ var length = this.length; for (var i = 0, l = arguments.length; i < l; i++){ var item = document.id(arguments[i]); if (item) this[length++] = item; } return (this.length = length); }.protect(), unshift: function(){ var items = []; for (var i = 0, l = arguments.length; i < l; i++){ var item = document.id(arguments[i]); if (item) items.push(item); } return Array.prototype.unshift.apply(this, items); }.protect(), concat: function(){ var newElements = new Elements(this); for (var i = 0, l = arguments.length; i < l; i++){ var item = arguments[i]; if (Type.isEnumerable(item)) newElements.append(item); else newElements.push(item); } return newElements; }.protect(), append: function(collection){ for (var i = 0, l = collection.length; i < l; i++) this.push(collection[i]); return this; }.protect(), empty: function(){ while (this.length) delete this[--this.length]; return this; }.protect() });

<1.2compat>

  1. 170
Elements.alias('extend', 'append');

</1.2compat>

  1. 174
(function(){

FF, IE

  1. 177
  2. 178
  3. 179
  4. 180
  5. 181
  6. 182
  7. 183
  8. 184
  9. 185
  10. 186
  11. 187
  12. 188
  13. 189
var splice = Array.prototype.splice, object = {'0': 0, '1': 1, length: 2}; splice.call(object, 1, 1); if (object[1] == 1) Elements.implement('splice', function(){ var length = this.length; splice.apply(this, arguments); while (length >= this.length) delete this[length--]; return this; }.protect()); Elements.implement(Array.prototype); Array.mirror(Elements);

  1. 192
  2. 193
  3. 194
  4. 195
  5. 196
  6. 197
  7. 198
  8. 199
  9. 200
var createElementAcceptsHTML; try { var x = document.createElement('<input name=x>'); createElementAcceptsHTML = (x.name == 'x'); } catch(e){} var escapeQuotes = function(html){ return ('' + html).replace(/&/g, '&amp;').replace(/"/g, '&quot;'); };

  1. 203
  2. 204
  3. 205
  4. 206
Document.implement({ newElement: function(tag, props){ if (props && props.checked != null) props.defaultChecked = props.checked;

  1. 208
  2. 209
  3. 210
  4. 211
  5. 212
  6. 213
  7. 214
  8. 215
if (createElementAcceptsHTML && props){ tag = '<' + tag; if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"'; if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"'; tag += '>'; delete props.name; delete props.type; }

  1. 217
  2. 218
  3. 219
  4. 220
  5. 221
  6. 222
  7. 223
  8. 224
  9. 225
  10. 226
  11. 227
  12. 228
  13. 229
  14. 230
  15. 231
  16. 232
  17. 233
  18. 234
  19. 235
  20. 236
  21. 237
  22. 238
  23. 239
  24. 240
  25. 241
  26. 242
  27. 243
  28. 244
  29. 245
  30. 246
  31. 247
  32. 248
  33. 249
  34. 250
  35. 251
  36. 252
  37. 253
  38. 254
  39. 255
  40. 256
  41. 257
  42. 258
  43. 259
  44. 260
  45. 261
  46. 262
  47. 263
  48. 264
  49. 265
  50. 266
  51. 267
  52. 268
  53. 269
  54. 270
  55. 271
  56. 272
  57. 273
  58. 274
  59. 275
  60. 276
  61. 277
  62. 278
  63. 279
  64. 280
  65. 281
  66. 282
  67. 283
  68. 284
  69. 285
  70. 286
  71. 287
  72. 288
  73. 289
  74. 290
  75. 291
  76. 292
  77. 293
  78. 294
  79. 295
  80. 296
  81. 297
  82. 298
  83. 299
  84. 300
  85. 301
  86. 302
return this.id(this.createElement(tag)).set(props); } }); })(); Document.implement({ newTextNode: function(text){ return this.createTextNode(text); }, getDocument: function(){ return this; }, getWindow: function(){ return this.window; }, id: (function(){ var types = { string: function(id, nocash, doc){ id = Slick.find(doc, '#' + id.replace(/(\W)/g, '\\$1')); return (id) ? types.element(id, nocash) : null; }, element: function(el, nocash){ $uid(el); if (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagName)){ Object.append(el, Element.Prototype); } return el; }, object: function(obj, nocash, doc){ if (obj.toElement) return types.element(obj.toElement(doc), nocash); return null; } }; types.textnode = types.whitespace = types.window = types.document = function(zero){ return zero; }; return function(el, nocash, doc){ if (el && el.$family && el.uid) return el; var type = typeOf(el); return (types[type]) ? types[type](el, nocash, doc || document) : null; }; })() }); if (window.$ == null) Window.implement('$', function(el, nc){ return document.id(el, nc, this.document); }); Window.implement({ getDocument: function(){ return this.document; }, getWindow: function(){ return this; } }); [Document, Element].invoke('implement', { getElements: function(expression){ return Slick.search(this, expression, new Elements); }, getElement: function(expression){ return document.id(Slick.find(this, expression)); } });

<1.2compat>

  1. 306
  2. 307
  3. 308
  4. 309
  5. 310
  6. 311
  7. 312
  8. 313
  9. 314
  10. 315
  11. 316
  12. 317
  13. 318
  14. 319
  15. 320
  16. 321
  17. 322
  18. 323
  19. 324
  20. 325
  21. 326
  22. 327
  23. 328
  24. 329
  25. 330
  26. 331
  27. 332
  28. 333
  29. 334
  30. 335
  31. 336
  32. 337
  33. 338
  34. 339
  35. 340
  36. 341
  37. 342
  38. 343
  39. 344
  40. 345
  41. 346
  42. 347
(function(search, find, match){ this.Selectors = {}; var pseudos = this.Selectors.Pseudo = new Hash(); var addSlickPseudos = function(){ for (var name in pseudos) if (pseudos.hasOwnProperty(name)){ Slick.definePseudo(name, pseudos[name]); delete pseudos[name]; } }; Slick.search = function(context, expression, append){ addSlickPseudos(); return search.call(this, context, expression, append); }; Slick.find = function(context, expression){ addSlickPseudos(); return find.call(this, context, expression); }; Slick.match = function(node, selector){ addSlickPseudos(); return match.call(this, node, selector); }; })(Slick.search, Slick.find, Slick.match); if (window.$$ == null) Window.implement('$$', function(selector){ var elements = new Elements; if (arguments.length == 1 && typeof selector == 'string') return Slick.search(this.document, selector, elements); var args = Array.flatten(arguments); for (var i = 0, l = args.length; i < l; i++){ var item = args[i]; switch (typeOf(item)){ case 'element': elements.push(item); break; case 'string': Slick.search(this.document, item, elements); } } return elements; });

</1.2compat>

  1. 351
  2. 352
  3. 353
  4. 354
  5. 355
  6. 356
  7. 357
  8. 358
  9. 359
  10. 360
  11. 361
  12. 362
  13. 363
  14. 364
  15. 365
  16. 366
  17. 367
  18. 368
  19. 369
  20. 370
  21. 371
  22. 372
  23. 373
  24. 374
  25. 375
  26. 376
  27. 377
  28. 378
  29. 379
  30. 380
  31. 381
  32. 382
  33. 383
  34. 384
  35. 385
  36. 386
  37. 387
  38. 388
  39. 389
  40. 390
  41. 391
  42. 392
  43. 393
  44. 394
  45. 395
  46. 396
  47. 397
  48. 398
  49. 399
  50. 400
  51. 401
  52. 402
  53. 403
  54. 404
  55. 405
  56. 406
  57. 407
  58. 408
  59. 409
  60. 410
  61. 411
  62. 412
  63. 413
  64. 414
  65. 415
  66. 416
  67. 417
  68. 418
  69. 419
  70. 420
  71. 421
  72. 422
  73. 423
  74. 424
  75. 425
  76. 426
if (window.$$ == null) Window.implement('$$', function(selector){ if (arguments.length == 1){ if (typeof selector == 'string') return Slick.search(this.document, selector, new Elements); else if (Type.isEnumerable(selector)) return new Elements(selector); } return new Elements(arguments); }); (function(){ var collected = {}, storage = {}; var formProps = {input: 'checked', option: 'selected', textarea: 'value'}; var get = function(uid){ return (storage[uid] || (storage[uid] = {})); }; var clean = function(item){ if (item.removeEvents) item.removeEvents(); if (item.clearAttributes) item.clearAttributes(); var uid = item.uid; if (uid != null){ delete collected[uid]; delete storage[uid]; } return item; }; var camels = ['defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap' ]; var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readOnly', 'multiple', 'selected', 'noresize', 'defer' ]; var attributes = { 'html': 'innerHTML', 'class': 'className', 'for': 'htmlFor', 'text': (function(){ var temp = document.createElement('div'); return (temp.innerText == null) ? 'textContent' : 'innerText'; })() }; var readOnly = ['type']; var expandos = ['value', 'defaultValue']; var uriAttrs = /^(?:href|src|usemap)$/i; bools = bools.associate(bools); camels = camels.associate(camels.map(String.toLowerCase)); readOnly = readOnly.associate(readOnly); Object.append(attributes, expandos.associate(expandos)); var inserters = { before: function(context, element){ var parent = element.parentNode; if (parent) parent.insertBefore(context, element); }, after: function(context, element){ var parent = element.parentNode; if (parent) parent.insertBefore(context, element.nextSibling); }, bottom: function(context, element){ element.appendChild(context); }, top: function(context, element){ element.insertBefore(context, element.firstChild); } }; inserters.inside = inserters.bottom;

<1.2compat>

  1. 430
  2. 431
  3. 432
  4. 433
  5. 434
  6. 435
  7. 436
  8. 437
  9. 438
  10. 439
  11. 440
  12. 441
  13. 442
  14. 443
  15. 444
  16. 445
  17. 446
  18. 447
  19. 448
Object.each(inserters, function(inserter, where){ where = where.capitalize(); var methods = {}; methods['inject' + where] = function(el){ inserter(this, document.id(el, true)); return this; }; methods['grab' + where] = function(el){ inserter(document.id(el, true), this); return this; }; Element.implement(methods); });

</1.2compat>

  1. 452
  2. 453
  3. 454
  4. 455
  5. 456
  6. 457
  7. 458
  8. 459
  9. 460
  10. 461
  11. 462
  12. 463
  13. 464
  14. 465
  15. 466
  16. 467
  17. 468
  18. 469
  19. 470
  20. 471
  21. 472
  22. 473
  23. 474
  24. 475
  25. 476
  26. 477
  27. 478
  28. 479
  29. 480
  30. 481
  31. 482
  32. 483
  33. 484
  34. 485
  35. 486
  36. 487
  37. 488
  38. 489
  39. 490
  40. 491
  41. 492
  42. 493
  43. 494
  44. 495
  45. 496
  46. 497
  47. 498
  48. 499
  49. 500
  50. 501
  51. 502
  52. 503
  53. 504
  54. 505
  55. 506
  56. 507
  57. 508
  58. 509
  59. 510
  60. 511
  61. 512
  62. 513
  63. 514
  64. 515
  65. 516
  66. 517
  67. 518
  68. 519
  69. 520
  70. 521
  71. 522
  72. 523
  73. 524
  74. 525
  75. 526
  76. 527
  77. 528
  78. 529
  79. 530
  80. 531
  81. 532
  82. 533
  83. 534
  84. 535
  85. 536
  86. 537
  87. 538
  88. 539
  89. 540
  90. 541
  91. 542
  92. 543
  93. 544
  94. 545
  95. 546
  96. 547
  97. 548
  98. 549
  99. 550
  100. 551
  101. 552
  102. 553
  103. 554
  104. 555
  105. 556
  106. 557
  107. 558
  108. 559
  109. 560
  110. 561
  111. 562
  112. 563
  113. 564
  114. 565
  115. 566
  116. 567
  117. 568
  118. 569
  119. 570
  120. 571
  121. 572
  122. 573
  123. 574
  124. 575
  125. 576
  126. 577
  127. 578
  128. 579
  129. 580
  130. 581
  131. 582
  132. 583
  133. 584
  134. 585
  135. 586
  136. 587
  137. 588
  138. 589
  139. 590
  140. 591
  141. 592
  142. 593
  143. 594
  144. 595
  145. 596
  146. 597
  147. 598
  148. 599
  149. 600
  150. 601
  151. 602
  152. 603
  153. 604
  154. 605
  155. 606
  156. 607
  157. 608
  158. 609
  159. 610
  160. 611
  161. 612
  162. 613
  163. 614
  164. 615
  165. 616
  166. 617
  167. 618
  168. 619
  169. 620
  170. 621
  171. 622
  172. 623
  173. 624
  174. 625
  175. 626
  176. 627
  177. 628
  178. 629
  179. 630
  180. 631
  181. 632
  182. 633
  183. 634
  184. 635
  185. 636
  186. 637
  187. 638
  188. 639
  189. 640
  190. 641
  191. 642
  192. 643
  193. 644
  194. 645
  195. 646
var injectCombinator = function(expression, combinator){ if (!expression) return combinator; expression = Slick.parse(expression); var expressions = expression.expressions; for (var i = expressions.length; i--;) expressions[i][0].combinator = combinator; return expression; }; Element.implement({ set: function(prop, value){ var property = Element.Properties[prop]; (property && property.set) ? property.set.call(this, value) : this.setProperty(prop, value); }.overloadSetter(), get: function(prop){ var property = Element.Properties[prop]; return (property && property.get) ? property.get.apply(this) : this.getProperty(prop); }.overloadGetter(), erase: function(prop){ var property = Element.Properties[prop]; (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop); return this; }, setProperty: function(attribute, value){ attribute = camels[attribute] || attribute; if (value == null) return this.removeProperty(attribute); var key = attributes[attribute]; (key) ? this[key] = value : (bools[attribute]) ? this[attribute] = !!value : this.setAttribute(attribute, '' + value); return this; }, setProperties: function(attributes){ for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]); return this; }, getProperty: function(attribute){ attribute = camels[attribute] || attribute; var key = attributes[attribute] || readOnly[attribute]; return (key) ? this[key] : (bools[attribute]) ? !!this[attribute] : (uriAttrs.test(attribute) ? this.getAttribute(attribute, 2) : (key = this.getAttributeNode(attribute)) ? key.nodeValue : null) || null; }, getProperties: function(){ var args = Array.from(arguments); return args.map(this.getProperty, this).associate(args); }, removeProperty: function(attribute){ attribute = camels[attribute] || attribute; var key = attributes[attribute]; (key) ? this[key] = '' : (bools[attribute]) ? this[attribute] = false : this.removeAttribute(attribute); return this; }, removeProperties: function(){ Array.each(arguments, this.removeProperty, this); return this; }, hasClass: function(className){ return this.className.clean().contains(className, ' '); }, addClass: function(className){ if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean(); return this; }, removeClass: function(className){ this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1'); return this; }, toggleClass: function(className, force){ if (force == null) force = !this.hasClass(className); return (force) ? this.addClass(className) : this.removeClass(className); }, adopt: function(){ var parent = this, fragment, elements = Array.flatten(arguments), length = elements.length; if (length > 1) parent = fragment = document.createDocumentFragment(); for (var i = 0; i < length; i++){ var element = document.id(elements[i], true); if (element) parent.appendChild(element); } if (fragment) this.appendChild(fragment); return this; }, appendText: function(text, where){ return this.grab(this.getDocument().newTextNode(text), where); }, grab: function(el, where){ inserters[where || 'bottom'](document.id(el, true), this); return this; }, inject: function(el, where){ inserters[where || 'bottom'](this, document.id(el, true)); return this; }, replaces: function(el){ el = document.id(el, true); el.parentNode.replaceChild(this, el); return this; }, wraps: function(el, where){ el = document.id(el, true); return this.replaces(el).grab(el, where); }, getPrevious: function(expression){ return document.id(Slick.find(this, injectCombinator(expression, '!~'))); }, getAllPrevious: function(expression){ return Slick.search(this, injectCombinator(expression, '!~'), new Elements); }, getNext: function(expression){ return document.id(Slick.find(this, injectCombinator(expression, '~'))); }, getAllNext: function(expression){ return Slick.search(this, injectCombinator(expression, '~'), new Elements); }, getFirst: function(expression){ return document.id(Slick.search(this, injectCombinator(expression, '>'))[0]); }, getLast: function(expression){ return document.id(Slick.search(this, injectCombinator(expression, '>')).getLast()); }, getParent: function(expression){ return document.id(Slick.find(this, injectCombinator(expression, '!'))); }, getParents: function(expression){ return Slick.search(this, injectCombinator(expression, '!'), new Elements); }, getSiblings: function(expression){ return Slick.search(this, injectCombinator(expression, '~~'), new Elements); }, getChildren: function(expression){ return Slick.search(this, injectCombinator(expression, '>'), new Elements); }, getWindow: function(){ return this.ownerDocument.window; }, getDocument: function(){ return this.ownerDocument; }, getElementById: function(id){ return document.id(Slick.find(this, '#' + ('' + id).replace(/(\W)/g, '\\$1'))); }, getSelected: function(){ this.selectedIndex; // Safari 3.2.1 return new Elements(Array.from(this.options).filter(function(option){ return option.selected; })); }, toQueryString: function(){ var queryString = []; this.getElements('input, select, textarea').each(function(el){ var type = el.type; if (!el.name || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return; var value = (el.get('tag') == 'select') ? el.getSelected().map(function(opt){

IE

  1. 648
  2. 649
  3. 650
  4. 651
  5. 652
  6. 653
  7. 654
  8. 655
  9. 656
  10. 657
  11. 658
  12. 659
  13. 660
  14. 661
  15. 662
  16. 663
  17. 664
  18. 665
  19. 666
  20. 667
  21. 668
  22. 669
  23. 670
  24. 671
  25. 672
  26. 673
  27. 674
  28. 675
  29. 676
  30. 677
  31. 678
  32. 679
  33. 680
  34. 681
  35. 682
  36. 683
  37. 684
  38. 685
  39. 686
  40. 687
  41. 688
  42. 689
  43. 690
  44. 691
  45. 692
  46. 693
  47. 694
  48. 695
  49. 696
  50. 697
  51. 698
  52. 699
  53. 700
  54. 701
  55. 702
  56. 703
  57. 704
  58. 705
  59. 706
  60. 707
  61. 708
  62. 709
  63. 710
  64. 711
  65. 712
  66. 713
  67. 714
  68. 715
  69. 716
  70. 717
  71. 718
return document.id(opt).get('value'); }) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value'); Array.from(value).each(function(val){ if (typeof val != 'undefined') queryString.push(encodeURIComponent(el.name) + '=' + encodeURIComponent(val)); }); }); return queryString.join('&'); }, destroy: function(){ var children = clean(this).getElementsByTagName('*'); Array.each(children, clean); Element.dispose(this); return null; }, empty: function(){ Array.from(this.childNodes).each(Element.dispose); return this; }, dispose: function(){ return (this.parentNode) ? this.parentNode.removeChild(this) : this; }, match: function(expression){ return !expression || Slick.match(this, expression); } }); var cleanClone = function(node, element, keepid){ if (!keepid) node.removeAttribute('id'); if (Browser.ie){ node.clearAttributes(); node.mergeAttributes(element); node.removeAttribute('uid'); if (node.options){ var no = node.options, eo = element.options; for (var i = no.length; i--;) no[i].selected = eo[i].selected; } } var prop = formProps[element.tagName.toLowerCase()]; if (prop && element[prop]) node[prop] = element[prop]; }; Element.implement('clone', function(contents, keepid){ contents = contents !== false; var clone = this.cloneNode(contents); if (contents){ var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*'); for (var i = ce.length; i--;) cleanClone(ce[i], te[i], keepid); } cleanClone(clone, this, keepid); if (Browser.ie){ var co = clone.getElementsByTagName('object'), to = this.getElementsByTagName('object'); for (var i = co.length; i--;) co[i].outerHTML = to[i].outerHTML; } return document.id(clone); }); var contains = {contains: function(element){ return Slick.contains(this, element); }}; if (!document.contains) Document.implement(contains); if (!document.createElement('div').contains) Element.implement(contains);

<1.2compat>

  1. 722
  2. 723
  3. 724
Element.implement('hasChild', function(element){ return this !== element && this.contains(element); });

</1.2compat>

  1. 728
  2. 729
  3. 730
  4. 731
  5. 732
  6. 733
  7. 734
  8. 735
  9. 736
  10. 737
  11. 738
  12. 739
  13. 740
  14. 741
  15. 742
  16. 743
  17. 744
  18. 745
  19. 746
  20. 747
  21. 748
  22. 749
  23. 750
  24. 751
  25. 752
  26. 753
  27. 754
  28. 755
  29. 756
  30. 757
  31. 758
  32. 759
  33. 760
  34. 761
  35. 762
  36. 763
  37. 764
  38. 765
  39. 766
  40. 767
  41. 768
  42. 769
[Element, Window, Document].invoke('implement', { addListener: function(type, fn){ if (type == 'unload'){ var old = fn, self = this; fn = function(){ self.removeListener('unload', fn); old(); }; } else { collected[$uid(this)] = this; } if (this.addEventListener) this.addEventListener(type, fn, !!arguments[2]); else this.attachEvent('on' + type, fn); return this; }, removeListener: function(type, fn){ if (this.removeEventListener) this.removeEventListener(type, fn, !!arguments[2]); else this.detachEvent('on' + type, fn); return this; }, retrieve: function(property, dflt){ var storage = get($uid(this)), prop = storage[property]; if (dflt != null && prop == null) prop = storage[property] = dflt; return prop != null ? prop : null; }, store: function(property, value){ var storage = get($uid(this)); storage[property] = value; return this; }, eliminate: function(property){ var storage = get($uid(this)); delete storage[property]; return this; } });

IE purge

  1. 772
  2. 773
  3. 774
  4. 775
  5. 776
  6. 777
  7. 778
  8. 779
if (window.attachEvent && !window.addEventListener) window.addListener('unload', function(){ Object.each(collected, clean); if (window.CollectGarbage) CollectGarbage(); }); })(); Element.Properties = {};

<1.2compat>

  1. 783
Element.Properties = new Hash;

</1.2compat>

  1. 787
  2. 788
  3. 789
  4. 790
  5. 791
  6. 792
  7. 793
  8. 794
  9. 795
  10. 796
  11. 797
  12. 798
  13. 799
  14. 800
  15. 801
  16. 802
  17. 803
  18. 804
  19. 805
  20. 806
  21. 807
  22. 808
  23. 809
  24. 810
  25. 811
  26. 812
  27. 813
  28. 814
  29. 815
  30. 816
  31. 817
  32. 818
  33. 819
  34. 820
  35. 821
  36. 822
  37. 823
  38. 824
  39. 825
  40. 826
  41. 827
  42. 828
  43. 829
  44. 830
  45. 831
  46. 832
  47. 833
  48. 834
  49. 835
  50. 836
  51. 837
  52. 838
  53. 839
  54. 840
  55. 841
  56. 842
  57. 843
  58. 844
  59. 845
  60. 846
  61. 847
  62. 848
  63. 849
  64. 850
  65. 851
  66. 852
  67. 853
  68. 854
  69. 855
Element.Properties.style = { set: function(style){ this.style.cssText = style; }, get: function(){ return this.style.cssText; }, erase: function(){ this.style.cssText = ''; } }; Element.Properties.tag = { get: function(){ return this.tagName.toLowerCase(); } }; (function(maxLength){ if (maxLength != null) Element.Properties.maxlength = Element.Properties.maxLength = { get: function(){ var maxlength = this.getAttribute('maxLength'); return maxlength == maxLength ? null : maxlength; } }; })(document.createElement('input').getAttribute('maxLength')); Element.Properties.html = (function(){ var tableTest = Function.attempt(function(){ var table = document.createElement('table'); table.innerHTML = '<tr><td></td></tr>'; }); var wrapper = document.createElement('div'); var translations = { table: [1, '<table>', '</table>'], select: [1, '<select>', '</select>'], tbody: [2, '<table><tbody>', '</tbody></table>'], tr: [3, '<table><tbody><tr>', '</tr></tbody></table>'] }; translations.thead = translations.tfoot = translations.tbody; var html = { set: function(){ var html = Array.flatten(arguments).join(''); var wrap = (!tableTest && translations[this.get('tag')]); if (wrap){ var first = wrapper; first.innerHTML = wrap[1] + html + wrap[2]; for (var i = wrap[0]; i--;) first = first.firstChild; this.empty().adopt(first.childNodes); } else { this.innerHTML = html; } } }; html.erase = html.set; return html; })();