imba-source 0.14.4 → 0.14.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3d9c8780d2e342f305d0297a6bbbdd964eedfb2b
4
- data.tar.gz: 2a2ffa1ed3f5d26a82f4fd05828c1fd14c0c80e8
3
+ metadata.gz: 85caa5222c9076f0fcd822c866fb413127fe4eb9
4
+ data.tar.gz: 367b837a63be1acaca428c9f1d53434b7380126a
5
5
  SHA512:
6
- metadata.gz: 373468237ae921e434027e6d52d3433b27c8a02daa08991a50282d934372ef1bded2af1fd108d7a7e4ebc649d8707a52a800c4045a7428d5b61423d6fffa925f
7
- data.tar.gz: 81d9e97f947aec2ff441fc63476bcd77b182dbb1189bd64f3f42d2b14fa410e70ff24dbbfd0df04d472ebdcc734c1be36eac0f77d82b09c43d4e6f490660154a
6
+ metadata.gz: 99dc945312447e24d9f88abf3c405f2a4dcf79dd5d8359db9b9dd9c87918f75629943579b3e7e60e0c88bb0e6bc87727a34f4fa8634c6e5332a6d09051f80655
7
+ data.tar.gz: 5d055f981d9e70e7fe289b1e93ba193e34672ec02129152c0f9c1a0fe3d32eec481d8e4d8432dffd19a4e7a012290838eba2ab55984437cb9b6140a443abac7d
@@ -1,5 +1,5 @@
1
1
  module Imba
2
2
  module Source
3
- VERSION = "0.14.4"
3
+ VERSION = "0.14.5"
4
4
  end
5
5
  end
@@ -90,7 +90,7 @@
90
90
  */
91
91
 
92
92
  Imba = {
93
- VERSION: '0.14.4',
93
+ VERSION: '0.14.5',
94
94
  CLIENT: isClient,
95
95
  SERVER: !isClient,
96
96
  DEBUG: false
@@ -190,7 +190,7 @@
190
190
  return;
191
191
  };
192
192
 
193
- return Imba.attr = function (scope,name,opts){
193
+ Imba.attr = function (scope,name,opts){
194
194
  if (scope.defineAttribute) {
195
195
  return scope.defineAttribute(name,opts);
196
196
  };
@@ -206,9 +206,20 @@
206
206
  this.setAttribute(name,value);
207
207
  return this;
208
208
  };
209
-
210
209
  return;
211
210
  };
211
+
212
+ Imba.propDidSet = function (object,property,val,prev){
213
+ var fn = property.watch;
214
+ if (fn instanceof Function) {
215
+ fn.call(object,val,prev,property);
216
+ } else if ((typeof fn=='string'||fn instanceof String) && object[fn]) {
217
+ object[fn](val,prev,property);
218
+ };
219
+ return;
220
+ };
221
+
222
+ return Imba;
212
223
 
213
224
  })();
214
225
 
@@ -645,6 +656,7 @@
645
656
  return (b && b.indexOf) ? b.indexOf(a) : [].indexOf.call(a,b);
646
657
  };
647
658
 
659
+ function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
648
660
  Imba.static = function (items,nr){
649
661
  items.static = nr;
650
662
  return items;
@@ -657,10 +669,21 @@
657
669
 
658
670
  Imba.Tag = function Tag(dom){
659
671
  this.setDom(dom);
672
+ this;
673
+ };
674
+
675
+ Imba.Tag.buildNode = function (){
676
+ var dom = Imba.document().createElement(this._nodeType || 'div');
677
+ if (this._classes) {
678
+ var cls = this._classes.join(" ");
679
+ if (cls) { dom.className = cls };
680
+ };
681
+ return dom;
660
682
  };
661
683
 
662
684
  Imba.Tag.createNode = function (){
663
- throw "Not implemented";
685
+ var proto = (this._protoDom || (this._protoDom = this.buildNode()));
686
+ return proto.cloneNode(false);
664
687
  };
665
688
 
666
689
  Imba.Tag.build = function (){
@@ -692,6 +715,27 @@
692
715
  return this;
693
716
  };
694
717
 
718
+ Imba.Tag.prototype.ref = function (){
719
+ return this._ref;
720
+ };
721
+
722
+ /*
723
+ Set inner html of node
724
+ */
725
+
726
+ Imba.Tag.prototype.setHtml = function (html){
727
+ this._dom.innerHTML = html;
728
+ return this;
729
+ };
730
+
731
+ /*
732
+ Get inner html of node
733
+ */
734
+
735
+ Imba.Tag.prototype.html = function (){
736
+ return this._dom.innerHTML;
737
+ };
738
+
695
739
  /*
696
740
  Method that is called by the compiled tag-chains, for
697
741
  binding events on tags to methods etc.
@@ -716,7 +760,6 @@
716
760
 
717
761
  Imba.Tag.prototype.setId = function (id){
718
762
  this.dom().id = id;
719
- this;
720
763
  return this;
721
764
  };
722
765
 
@@ -782,6 +825,147 @@
782
825
  throw "Not implemented";
783
826
  };
784
827
 
828
+ /*
829
+ Remove specified child from current node.
830
+ @return {self}
831
+ */
832
+
833
+ Imba.Tag.prototype.removeChild = function (child){
834
+ var par = this.dom();
835
+ var el = child instanceof Imba.Tag ? (child.dom()) : (child);
836
+ if (el && el.parentNode == par) { par.removeChild(el) };
837
+ return this;
838
+ };
839
+
840
+ // Benchmark difference
841
+ // def removeChild node
842
+ // dom.removeChild(node.@dom or node) if node
843
+ // self
844
+
845
+ /*
846
+ @deprecated
847
+ Remove specified child from current node.
848
+ */
849
+
850
+ Imba.Tag.prototype.remove = function (child){
851
+ var par = this.dom();
852
+ var el = child && child.dom();
853
+ if (el && el.parentNode == par) { par.removeChild(el) };
854
+ return this;
855
+ };
856
+
857
+ /*
858
+ Append a single item (node or string) to the current node.
859
+ If supplied item is a string it will automatically. This is used
860
+ by Imba internally, but will practically never be used explicitly.
861
+ @return {self}
862
+ */
863
+
864
+ Imba.Tag.prototype.appendChild = function (node){
865
+ if ((typeof node=='string'||node instanceof String)) { node = Imba.document().createTextNode(node) };
866
+ if (node) { this.dom().appendChild(node._dom || node) };
867
+ return this;
868
+ };
869
+
870
+ /*
871
+ Insert a node into the current node (self), before another.
872
+ The relative node must be a child of current node.
873
+ */
874
+
875
+ Imba.Tag.prototype.insertBefore = function (node,rel){
876
+ if ((typeof node=='string'||node instanceof String)) { node = Imba.document().createTextNode(node) };
877
+ if (node && rel) { this.dom().insertBefore((node._dom || node),(rel._dom || rel)) };
878
+ return this;
879
+ };
880
+
881
+ /*
882
+ The .append method inserts the specified content as the last child
883
+ of the target node. If the content is already a child of node it
884
+ will be moved to the end.
885
+
886
+ # example
887
+ var root = <div.root>
888
+ var item = <div.item> "This is an item"
889
+ root.append item # appends item to the end of root
890
+
891
+ root.prepend "some text" # append text
892
+ root.prepend [<ul>,<ul>] # append array
893
+ */
894
+
895
+ Imba.Tag.prototype.append = function (item){
896
+ // possible to append blank
897
+ // possible to simplify on server?
898
+ if (!item) { return this };
899
+
900
+ if (item instanceof Array) {
901
+ for (var i = 0, ary = iter$(item), len = ary.length, member; i < len; i++) {
902
+ member = ary[i];
903
+ member && this.append(member);
904
+ };
905
+ } else if ((typeof item=='string'||item instanceof String) || (typeof item=='number'||item instanceof Number)) {
906
+ var node = Imba.document().createTextNode(item);
907
+ this._dom.appendChild(node);
908
+ if (this._empty) { this._empty = false };
909
+ } else {
910
+ // should delegate to self.appendChild
911
+ this._dom.appendChild(item._dom || item);
912
+ if (this._empty) { this._empty = false };
913
+ };
914
+
915
+ return this;
916
+ };
917
+
918
+ /*
919
+ @deprecated
920
+ */
921
+
922
+ Imba.Tag.prototype.insert = function (node,pars){
923
+ if(!pars||pars.constructor !== Object) pars = {};
924
+ var before = pars.before !== undefined ? pars.before : null;
925
+ var after = pars.after !== undefined ? pars.after : null;
926
+ if (after) { before = after.next() };
927
+ if (node instanceof Array) {
928
+ node = (tag$.$fragment().setContent(node,0).end());
929
+ };
930
+ if (before) {
931
+ this.dom().insertBefore(node.dom(),before.dom());
932
+ } else {
933
+ this.append(node);
934
+ };
935
+ return this;
936
+ };
937
+
938
+ /*
939
+ @todo Should support multiple arguments like append
940
+
941
+ The .prepend method inserts the specified content as the first
942
+ child of the target node. If the content is already a child of
943
+ node it will be moved to the start.
944
+
945
+ node.prepend <div.top> # prepend node
946
+ node.prepend "some text" # prepend text
947
+ node.prepend [<ul>,<ul>] # prepend array
948
+
949
+ */
950
+
951
+ Imba.Tag.prototype.prepend = function (item){
952
+ var first = this._dom.childNodes[0];
953
+ first ? (this.insertBefore(item,first)) : (this.appendChild(item));
954
+ return this;
955
+ };
956
+
957
+
958
+ /*
959
+ Remove node from the dom tree
960
+ @return {self}
961
+ */
962
+
963
+ Imba.Tag.prototype.orphanize = function (){
964
+ var par;
965
+ if (par = this.parent()) { par.removeChild(this) };
966
+ return this;
967
+ };
968
+
785
969
  /*
786
970
  Get text of node. Uses textContent behind the scenes (not innerText)
787
971
  [https://developer.mozilla.org/en-US/docs/Web/API/Node/textContent]()
@@ -821,7 +1005,49 @@
821
1005
  */
822
1006
 
823
1007
  Imba.Tag.prototype.dataset = function (key,val){
824
- throw "Not implemented";
1008
+ if (key instanceof Object) {
1009
+ for (var i = 0, keys = Object.keys(key), l = keys.length; i < l; i++){
1010
+ this.dataset(keys[i],key[keys[i]]);
1011
+ };
1012
+ return this;
1013
+ };
1014
+
1015
+ if (arguments.length == 2) {
1016
+ this.setAttribute(("data-" + key),val);
1017
+ return this;
1018
+ };
1019
+
1020
+ if (key) {
1021
+ return this.getAttribute(("data-" + key));
1022
+ };
1023
+
1024
+ var dataset = this.dom().dataset;
1025
+
1026
+ if (!dataset) {
1027
+ dataset = {};
1028
+ for (var i = 0, ary = iter$(this.dom().attributes), len = ary.length, atr; i < len; i++) {
1029
+ atr = ary[i];
1030
+ if (atr.name.substr(0,5) == 'data-') {
1031
+ dataset[Imba.toCamelCase(atr.name.slice(5))] = atr.value;
1032
+ };
1033
+ };
1034
+ };
1035
+
1036
+ return dataset;
1037
+ };
1038
+
1039
+
1040
+ /*
1041
+ Remove all content inside node
1042
+ */
1043
+
1044
+ Imba.Tag.prototype.empty = function (){
1045
+ while (this._dom.firstChild){
1046
+ this._dom.removeChild(this._dom.firstChild);
1047
+ };
1048
+ this._children = null;
1049
+ this._empty = true;
1050
+ return this;
825
1051
  };
826
1052
 
827
1053
  /*
@@ -909,6 +1135,8 @@
909
1135
  return this;
910
1136
  };
911
1137
 
1138
+
1139
+
912
1140
  /*
913
1141
  List of flags for this node.
914
1142
  */
@@ -917,6 +1145,14 @@
917
1145
  return this._dom.classList;
918
1146
  };
919
1147
 
1148
+ /*
1149
+ @deprecated
1150
+ */
1151
+
1152
+ Imba.Tag.prototype.classes = function (){
1153
+ throw "Imba.Tag#classes is removed. Use Imba.Tag#flags";
1154
+ };
1155
+
920
1156
  /*
921
1157
  Add speficied flag to current node.
922
1158
  If a second argument is supplied, it will be coerced into a Boolean,
@@ -966,6 +1202,30 @@
966
1202
  return this._dom.classList.contains(name);
967
1203
  };
968
1204
 
1205
+
1206
+ /*
1207
+ Set/update a named flag. It remembers the previous
1208
+ value of the flag, and removes it before setting the new value.
1209
+
1210
+ node.setFlag('type','todo')
1211
+ node.setFlag('type','project')
1212
+ # todo is removed, project is added.
1213
+
1214
+ @return {self}
1215
+ */
1216
+
1217
+ Imba.Tag.prototype.setFlag = function (name,value){
1218
+ this._namedFlags || (this._namedFlags = []);
1219
+ var prev = this._namedFlags[name];
1220
+ if (prev != value) {
1221
+ if (prev) { this.unflag(prev) };
1222
+ if (value) { this.flag(value) };
1223
+ this._namedFlags[name] = value;
1224
+ };
1225
+ return this;
1226
+ };
1227
+
1228
+
969
1229
  /*
970
1230
  Get the scheduler for this node. A new scheduler will be created
971
1231
  if it does not already exist.
@@ -1012,6 +1272,200 @@
1012
1272
  return tag$wrap(this.dom().parentNode);
1013
1273
  };
1014
1274
 
1275
+ /*
1276
+ Get the child at index
1277
+ */
1278
+
1279
+ Imba.Tag.prototype.child = function (i){
1280
+ return tag$wrap(this.dom().children[i || 0]);
1281
+ };
1282
+
1283
+
1284
+ /*
1285
+ Get the children of node
1286
+ @return {Imba.Selector}
1287
+ */
1288
+
1289
+ Imba.Tag.prototype.children = function (sel){
1290
+ var nodes = new Imba.Selector(null,this,this._dom.children);
1291
+ return sel ? (nodes.filter(sel)) : (nodes);
1292
+ };
1293
+
1294
+ /*
1295
+ Get the siblings of node
1296
+ @return {Imba.Selector}
1297
+ */
1298
+
1299
+ Imba.Tag.prototype.siblings = function (sel){
1300
+ var par, self = this;
1301
+ if (!(par = this.parent())) { return [] }; // FIXME
1302
+ var ary = this.dom().parentNode.children;
1303
+ var nodes = new Imba.Selector(null,this,ary);
1304
+ return nodes.filter(function(n) { return n != self && (!sel || n.matches(sel)); });
1305
+ };
1306
+
1307
+ /*
1308
+ Get node and its ascendents
1309
+ @return {Array}
1310
+ */
1311
+
1312
+ Imba.Tag.prototype.path = function (sel){
1313
+ var node = this;
1314
+ var nodes = [];
1315
+ if (sel && sel.query) { sel = sel.query() };
1316
+
1317
+ while (node){
1318
+ if (!sel || node.matches(sel)) { nodes.push(node) };
1319
+ node = node.parent();
1320
+ };
1321
+ return nodes;
1322
+ };
1323
+
1324
+ /*
1325
+ Get ascendents of node
1326
+ @return {Array}
1327
+ */
1328
+
1329
+ Imba.Tag.prototype.parents = function (sel){
1330
+ var par = this.parent();
1331
+ return par ? (par.path(sel)) : ([]);
1332
+ };
1333
+
1334
+ /*
1335
+ Get the immediately following sibling of node.
1336
+ */
1337
+
1338
+ Imba.Tag.prototype.next = function (sel){
1339
+ if (sel) {
1340
+ var el = this;
1341
+ while (el = el.next()){
1342
+ if (el.matches(sel)) { return el };
1343
+ };
1344
+ return null;
1345
+ };
1346
+ return tag$wrap(this.dom().nextElementSibling);
1347
+ };
1348
+
1349
+ /*
1350
+ Get the immediately preceeding sibling of node.
1351
+ */
1352
+
1353
+ Imba.Tag.prototype.prev = function (sel){
1354
+ if (sel) {
1355
+ var el = this;
1356
+ while (el = el.prev()){
1357
+ if (el.matches(sel)) { return el };
1358
+ };
1359
+ return null;
1360
+ };
1361
+ return tag$wrap(this.dom().previousElementSibling);
1362
+ };
1363
+
1364
+ /*
1365
+ Get descendants of current node, optionally matching selector
1366
+ @return {Imba.Selector}
1367
+ */
1368
+
1369
+ Imba.Tag.prototype.find = function (sel){
1370
+ return new Imba.Selector(sel,this);
1371
+ };
1372
+
1373
+ /*
1374
+ Get the first matching child of node
1375
+
1376
+ @return {Imba.Tag}
1377
+ */
1378
+
1379
+ Imba.Tag.prototype.first = function (sel){
1380
+ return sel ? (this.find(sel).first()) : (tag$wrap(this.dom().firstElementChild));
1381
+ };
1382
+
1383
+ /*
1384
+ Get the last matching child of node
1385
+
1386
+ node.last # returns the last child of node
1387
+ node.last %span # returns the last span inside node
1388
+ node.last do |el| el.text == 'Hi' # return last node with text Hi
1389
+
1390
+ @return {Imba.Tag}
1391
+ */
1392
+
1393
+ Imba.Tag.prototype.last = function (sel){
1394
+ return sel ? (this.find(sel).last()) : (tag$wrap(this.dom().lastElementChild));
1395
+ };
1396
+
1397
+ /*
1398
+ Check if this node matches a selector
1399
+ @return {Boolean}
1400
+ */
1401
+
1402
+ Imba.Tag.prototype.matches = function (sel){
1403
+ var fn;
1404
+ if (sel instanceof Function) {
1405
+ return sel(this);
1406
+ };
1407
+
1408
+ if (sel.query) { sel = sel.query() };
1409
+ if (fn = (this._dom.matches || this._dom.matchesSelector || this._dom.webkitMatchesSelector || this._dom.msMatchesSelector || this._dom.mozMatchesSelector)) {
1410
+ return fn.call(this._dom,sel);
1411
+ };
1412
+ };
1413
+
1414
+ /*
1415
+ Get the first element matching supplied selector / filter
1416
+ traversing upwards, but including the node itself.
1417
+ @return {Imba.Tag}
1418
+ */
1419
+
1420
+ Imba.Tag.prototype.closest = function (sel){
1421
+ if (!sel) { return this.parent() }; // should return self?!
1422
+ var node = this;
1423
+ if (sel.query) { sel = sel.query() };
1424
+
1425
+ while (node){
1426
+ if (node.matches(sel)) { return node };
1427
+ node = node.parent();
1428
+ };
1429
+ return null;
1430
+ };
1431
+
1432
+ /*
1433
+ Get the closest ancestor of node that matches
1434
+ specified selector / matcher.
1435
+
1436
+ @return {Imba.Tag}
1437
+ */
1438
+
1439
+ Imba.Tag.prototype.up = function (sel){
1440
+ if (!sel) { return this.parent() };
1441
+ return this.parent() && this.parent().closest(sel);
1442
+ };
1443
+
1444
+ /*
1445
+ Get the index of node.
1446
+ @return {Number}
1447
+ */
1448
+
1449
+ Imba.Tag.prototype.index = function (){
1450
+ var i = 0;
1451
+ var el = this.dom();
1452
+ while (el.previousSibling){
1453
+ el = el.previousSibling;
1454
+ i++;
1455
+ };
1456
+ return i;
1457
+ };
1458
+
1459
+ /*
1460
+ Check if node contains other node
1461
+ @return {Boolean}
1462
+ */
1463
+
1464
+ Imba.Tag.prototype.contains = function (node){
1465
+ return this.dom().contains(node && node._dom || node);
1466
+ };
1467
+
1468
+
1015
1469
  /*
1016
1470
  Shorthand for console.log on elements
1017
1471
  @return {self}
@@ -1069,6 +1523,26 @@
1069
1523
  return this.getAttribute('style');
1070
1524
  };
1071
1525
 
1526
+ /*
1527
+ Focus on current node
1528
+ @return {self}
1529
+ */
1530
+
1531
+ Imba.Tag.prototype.focus = function (){
1532
+ this.dom().focus();
1533
+ return this;
1534
+ };
1535
+
1536
+ /*
1537
+ Remove focus from current node
1538
+ @return {self}
1539
+ */
1540
+
1541
+ Imba.Tag.prototype.blur = function (){
1542
+ this.dom().blur();
1543
+ return this;
1544
+ };
1545
+
1072
1546
  Imba.Tag.prototype.toString = function (){
1073
1547
  return this.dom().outerHTML;
1074
1548
  };
@@ -1088,14 +1562,14 @@
1088
1562
 
1089
1563
  obj.prototype = Object.create(sup.prototype);
1090
1564
  obj.__super__ = obj.prototype.__super__ = sup.prototype;
1091
- obj.prototype.initialize = obj.prototype.constructor = obj;
1565
+ obj.prototype.constructor = obj;
1092
1566
  if (sup.inherit) { sup.inherit(obj) };
1093
1567
  return obj;
1094
1568
  };
1095
1569
 
1096
1570
  function Tag(){
1097
1571
  return function(dom) {
1098
- this.setDom(dom);
1572
+ this.initialize(dom);
1099
1573
  return this;
1100
1574
  };
1101
1575
  };
@@ -1326,7 +1800,6 @@
1326
1800
  /***/ function(module, exports) {
1327
1801
 
1328
1802
  (function(){
1329
- function iter$(a){ return a ? (a.toArray ? a.toArray() : a) : []; };
1330
1803
 
1331
1804
  Imba.document = function (){
1332
1805
  return window.document;
@@ -1386,16 +1859,6 @@
1386
1859
  tag.prototype.name = function(v){ return this.getAttribute('name'); }
1387
1860
  tag.prototype.setName = function(v){ this.setAttribute('name',v); return this; };
1388
1861
 
1389
- tag.prototype.id = function (){
1390
- return this.dom().id;
1391
- };
1392
-
1393
- tag.prototype.setId = function (id){
1394
- this.dom().id = id;
1395
- this;
1396
- return this;
1397
- };
1398
-
1399
1862
  tag.prototype.width = function (){
1400
1863
  return this._dom.offsetWidth;
1401
1864
  };
@@ -1410,48 +1873,6 @@
1410
1873
  return this;
1411
1874
  };
1412
1875
 
1413
- /*
1414
- Set inner html of node
1415
- */
1416
-
1417
- tag.prototype.setHtml = function (html){
1418
- this._dom.innerHTML = html;
1419
- this;
1420
- return this;
1421
- };
1422
-
1423
- /*
1424
- Get inner html of node
1425
- */
1426
-
1427
- tag.prototype.html = function (){
1428
- return this._dom.innerHTML;
1429
- };
1430
-
1431
- /*
1432
- Remove all content inside node
1433
- */
1434
-
1435
- tag.prototype.empty = function (){
1436
- while (this._dom.firstChild){
1437
- this._dom.removeChild(this._dom.firstChild);
1438
- };
1439
- this._children = null;
1440
- this._empty = true;
1441
- return this;
1442
- };
1443
-
1444
- /*
1445
- Remove specified child from current node.
1446
- */
1447
-
1448
- tag.prototype.remove = function (child){
1449
- var par = this.dom();
1450
- var el = child && child.dom();
1451
- if (el && el.parentNode == par) { par.removeChild(el) };
1452
- return this;
1453
- };
1454
-
1455
1876
  tag.prototype.emit = function (name,pars){
1456
1877
  if(!pars||pars.constructor !== Object) pars = {};
1457
1878
  var data = pars.data !== undefined ? pars.data : null;
@@ -1460,345 +1881,9 @@
1460
1881
  return this;
1461
1882
  };
1462
1883
 
1463
- tag.prototype.dataset = function (key,val){
1464
- if (key instanceof Object) {
1465
- for (var i = 0, keys = Object.keys(key), l = keys.length; i < l; i++){
1466
- this.dataset(keys[i],key[keys[i]]);
1467
- };
1468
- return this;
1469
- };
1470
-
1471
- if (arguments.length == 2) {
1472
- this.setAttribute(("data-" + key),val);
1473
- return this;
1474
- };
1475
-
1476
- if (key) {
1477
- return this.getAttribute(("data-" + key));
1478
- };
1479
-
1480
- var dataset = this.dom().dataset;
1481
-
1482
- if (!dataset) {
1483
- dataset = {};
1484
- for (var i = 0, ary = iter$(this.dom().attributes), len = ary.length, atr; i < len; i++) {
1485
- atr = ary[i];
1486
- if (atr.name.substr(0,5) == 'data-') {
1487
- dataset[Imba.toCamelCase(atr.name.slice(5))] = atr.value;
1488
- };
1489
- };
1490
- };
1491
-
1492
- return dataset;
1493
- };
1494
-
1495
- /*
1496
- Get descendants of current node, optionally matching selector
1497
- @return {Imba.Selector}
1498
- */
1499
-
1500
- tag.prototype.find = function (sel){
1501
- return new Imba.Selector(sel,this);
1502
- };
1503
-
1504
- /*
1505
- Get the first matching child of node
1506
-
1507
- @return {Imba.Tag}
1508
- */
1509
-
1510
- tag.prototype.first = function (sel){
1511
- return sel ? (this.find(sel).first()) : (tag$wrap(this.dom().firstElementChild));
1512
- };
1513
-
1514
- /*
1515
- Get the last matching child of node
1516
-
1517
- node.last # returns the last child of node
1518
- node.last %span # returns the last span inside node
1519
- node.last do |el| el.text == 'Hi' # return last node with text Hi
1520
-
1521
- @return {Imba.Tag}
1522
- */
1523
-
1524
- tag.prototype.last = function (sel){
1525
- return sel ? (this.find(sel).last()) : (tag$wrap(this.dom().lastElementChild));
1526
- };
1527
-
1528
- /*
1529
- Get the child at index
1530
- */
1531
-
1532
- tag.prototype.child = function (i){
1533
- return tag$wrap(this.dom().children[i || 0]);
1534
- };
1535
-
1536
- tag.prototype.children = function (sel){
1537
- var nodes = new Imba.Selector(null,this,this._dom.children);
1538
- return sel ? (nodes.filter(sel)) : (nodes);
1539
- };
1540
-
1541
- tag.prototype.orphanize = function (){
1542
- var par;
1543
- if (par = this.dom().parentNode) { par.removeChild(this._dom) };
1544
- return this;
1545
- };
1546
-
1547
- tag.prototype.matches = function (sel){
1548
- var fn;
1549
- if (sel instanceof Function) {
1550
- return sel(this);
1551
- };
1552
-
1553
- if (sel.query) { sel = sel.query() };
1554
- if (fn = (this._dom.matches || this._dom.matchesSelector || this._dom.webkitMatchesSelector || this._dom.msMatchesSelector || this._dom.mozMatchesSelector)) {
1555
- return fn.call(this._dom,sel);
1556
- };
1557
- };
1558
-
1559
- /*
1560
- Get the first element matching supplied selector / filter
1561
- traversing upwards, but including the node itself.
1562
- @return {Imba.Tag}
1563
- */
1564
-
1565
- tag.prototype.closest = function (sel){
1566
- if (!sel) { return this.parent() }; // should return self?!
1567
- var node = this;
1568
- if (sel.query) { sel = sel.query() };
1569
-
1570
- while (node){
1571
- if (node.matches(sel)) { return node };
1572
- node = node.parent();
1573
- };
1574
- return null;
1575
- };
1576
-
1577
- /*
1578
- Get the closest ancestor of node that matches
1579
- specified selector / matcher.
1580
-
1581
- @return {Imba.Tag}
1582
- */
1583
-
1584
- tag.prototype.up = function (sel){
1585
- if (!sel) { return this.parent() };
1586
- return this.parent() && this.parent().closest(sel);
1587
- };
1588
-
1589
- tag.prototype.path = function (sel){
1590
- var node = this;
1591
- var nodes = [];
1592
- if (sel && sel.query) { sel = sel.query() };
1593
-
1594
- while (node){
1595
- if (!sel || node.matches(sel)) { nodes.push(node) };
1596
- node = node.parent();
1597
- };
1598
- return nodes;
1599
- };
1600
-
1601
- tag.prototype.parents = function (sel){
1602
- var par = this.parent();
1603
- return par ? (par.path(sel)) : ([]);
1604
- };
1605
-
1606
-
1607
-
1608
- tag.prototype.siblings = function (sel){
1609
- var par, self = this;
1610
- if (!(par = this.parent())) { return [] }; // FIXME
1611
- var ary = this.dom().parentNode.children;
1612
- var nodes = new Imba.Selector(null,this,ary);
1613
- return nodes.filter(function(n) { return n != self && (!sel || n.matches(sel)); });
1614
- };
1615
-
1616
- /*
1617
- Get the immediately following sibling of node.
1618
- */
1619
-
1620
- tag.prototype.next = function (sel){
1621
- if (sel) {
1622
- var el = this;
1623
- while (el = el.next()){
1624
- if (el.matches(sel)) { return el };
1625
- };
1626
- return null;
1627
- };
1628
- return tag$wrap(this.dom().nextElementSibling);
1629
- };
1630
-
1631
- /*
1632
- Get the immediately preceeding sibling of node.
1633
- */
1634
-
1635
- tag.prototype.prev = function (sel){
1636
- if (sel) {
1637
- var el = this;
1638
- while (el = el.prev()){
1639
- if (el.matches(sel)) { return el };
1640
- };
1641
- return null;
1642
- };
1643
- return tag$wrap(this.dom().previousElementSibling);
1644
- };
1645
-
1646
- tag.prototype.contains = function (node){
1647
- return this.dom().contains(node && node._dom || node);
1648
- };
1649
-
1650
- tag.prototype.index = function (){
1651
- var i = 0;
1652
- var el = this.dom();
1653
- while (el.previousSibling){
1654
- el = el.previousSibling;
1655
- i++;
1656
- };
1657
- return i;
1658
- };
1659
-
1660
-
1661
- /*
1662
-
1663
- @deprecated
1664
- */
1665
-
1666
- tag.prototype.insert = function (node,pars){
1667
- if(!pars||pars.constructor !== Object) pars = {};
1668
- var before = pars.before !== undefined ? pars.before : null;
1669
- var after = pars.after !== undefined ? pars.after : null;
1670
- if (after) { before = after.next() };
1671
- if (node instanceof Array) {
1672
- node = (tag$.$fragment().setContent(node,0).end());
1673
- };
1674
- if (before) {
1675
- this.dom().insertBefore(node.dom(),before.dom());
1676
- } else {
1677
- this.append(node);
1678
- };
1679
- return this;
1680
- };
1681
-
1682
- /*
1683
- Focus on current node
1684
- @return {self}
1685
- */
1686
-
1687
- tag.prototype.focus = function (){
1688
- this.dom().focus();
1689
- return this;
1690
- };
1691
-
1692
- /*
1693
- Remove focus from current node
1694
- @return {self}
1695
- */
1696
-
1697
- tag.prototype.blur = function (){
1698
- this.dom().blur();
1699
- return this;
1700
- };
1701
-
1702
1884
  tag.prototype.template = function (){
1703
1885
  return null;
1704
1886
  };
1705
-
1706
- /*
1707
- @todo Should support multiple arguments like append
1708
-
1709
- The .prepend method inserts the specified content as the first
1710
- child of the target node. If the content is already a child of
1711
- node it will be moved to the start.
1712
-
1713
- node.prepend <div.top> # prepend node
1714
- node.prepend "some text" # prepend text
1715
- node.prepend [<ul>,<ul>] # prepend array
1716
-
1717
- */
1718
-
1719
- tag.prototype.prepend = function (item){
1720
- var first = this._dom.childNodes[0];
1721
- first ? (this.insertBefore(item,first)) : (this.appendChild(item));
1722
- return this;
1723
- };
1724
-
1725
- /*
1726
- The .append method inserts the specified content as the last child
1727
- of the target node. If the content is already a child of node it
1728
- will be moved to the end.
1729
-
1730
- # example
1731
- var root = <div.root>
1732
- var item = <div.item> "This is an item"
1733
- root.append item # appends item to the end of root
1734
-
1735
- root.prepend "some text" # append text
1736
- root.prepend [<ul>,<ul>] # append array
1737
- */
1738
-
1739
- tag.prototype.append = function (item){
1740
- // possible to append blank
1741
- // possible to simplify on server?
1742
- if (!item) { return this };
1743
-
1744
- if (item instanceof Array) {
1745
- for (var i = 0, ary = iter$(item), len = ary.length, member; i < len; i++) {
1746
- member = ary[i];
1747
- member && this.append(member);
1748
- };
1749
- } else if ((typeof item=='string'||item instanceof String) || (typeof item=='number'||item instanceof Number)) {
1750
- var node = Imba.document().createTextNode(item);
1751
- this._dom.appendChild(node);
1752
- if (this._empty) { this._empty = false };
1753
- } else {
1754
- this._dom.appendChild(item._dom || item);
1755
- if (this._empty) { this._empty = false };
1756
- };
1757
-
1758
- return this;
1759
- };
1760
-
1761
- /*
1762
- Insert a node into the current node (self), before another.
1763
- The relative node must be a child of current node.
1764
- */
1765
-
1766
- tag.prototype.insertBefore = function (node,rel){
1767
- if ((typeof node=='string'||node instanceof String)) { node = Imba.document().createTextNode(node) };
1768
- if (node && rel) { this.dom().insertBefore((node._dom || node),(rel._dom || rel)) };
1769
- return this;
1770
- };
1771
-
1772
- /*
1773
- Append a single item (node or string) to the current node.
1774
- If supplied item is a string it will automatically. This is used
1775
- by Imba internally, but will practically never be used explicitly.
1776
- */
1777
-
1778
- tag.prototype.appendChild = function (node){
1779
- if ((typeof node=='string'||node instanceof String)) { node = Imba.document().createTextNode(node) };
1780
- if (node) { this.dom().appendChild(node._dom || node) };
1781
- return this;
1782
- };
1783
-
1784
- /*
1785
- Remove a single child from the current node.
1786
- Used by Imba internally.
1787
- */
1788
-
1789
- tag.prototype.removeChild = function (node){
1790
- if (node) { this.dom().removeChild(node._dom || node) };
1791
- return this;
1792
- };
1793
-
1794
- /*
1795
- @deprecated
1796
- */
1797
-
1798
- tag.prototype.classes = function (){
1799
- console.log('Imba.Tag#classes is deprecated');
1800
- return this._dom.classList;
1801
- };
1802
1887
  });
1803
1888
 
1804
1889
  return tag$.defineTag('svgelement', 'htmlelement');
@@ -1933,15 +2018,34 @@
1933
2018
  });
1934
2019
 
1935
2020
  tag$.defineTag('input', function(tag){
1936
- tag.prototype.type = function(v){ return this.getAttribute('type'); }
1937
- tag.prototype.setType = function(v){ this.setAttribute('type',v); return this; };
1938
- tag.prototype.required = function(v){ return this.getAttribute('required'); }
1939
- tag.prototype.setRequired = function(v){ this.setAttribute('required',v); return this; };
2021
+ tag.prototype.accept = function(v){ return this.getAttribute('accept'); }
2022
+ tag.prototype.setAccept = function(v){ this.setAttribute('accept',v); return this; };
1940
2023
  tag.prototype.disabled = function(v){ return this.getAttribute('disabled'); }
1941
2024
  tag.prototype.setDisabled = function(v){ this.setAttribute('disabled',v); return this; };
1942
- tag.prototype.autofocus = function(v){ return this.getAttribute('autofocus'); }
1943
- tag.prototype.setAutofocus = function(v){ this.setAttribute('autofocus',v); return this; };
2025
+ tag.prototype.form = function(v){ return this.getAttribute('form'); }
2026
+ tag.prototype.setForm = function(v){ this.setAttribute('form',v); return this; };
2027
+ tag.prototype.list = function(v){ return this.getAttribute('list'); }
2028
+ tag.prototype.setList = function(v){ this.setAttribute('list',v); return this; };
2029
+ tag.prototype.max = function(v){ return this.getAttribute('max'); }
2030
+ tag.prototype.setMax = function(v){ this.setAttribute('max',v); return this; };
2031
+ tag.prototype.maxlength = function(v){ return this.getAttribute('maxlength'); }
2032
+ tag.prototype.setMaxlength = function(v){ this.setAttribute('maxlength',v); return this; };
2033
+ tag.prototype.min = function(v){ return this.getAttribute('min'); }
2034
+ tag.prototype.setMin = function(v){ this.setAttribute('min',v); return this; };
2035
+ tag.prototype.pattern = function(v){ return this.getAttribute('pattern'); }
2036
+ tag.prototype.setPattern = function(v){ this.setAttribute('pattern',v); return this; };
2037
+ tag.prototype.required = function(v){ return this.getAttribute('required'); }
2038
+ tag.prototype.setRequired = function(v){ this.setAttribute('required',v); return this; };
2039
+ tag.prototype.size = function(v){ return this.getAttribute('size'); }
2040
+ tag.prototype.setSize = function(v){ this.setAttribute('size',v); return this; };
2041
+ tag.prototype.step = function(v){ return this.getAttribute('step'); }
2042
+ tag.prototype.setStep = function(v){ this.setAttribute('step',v); return this; };
2043
+ tag.prototype.type = function(v){ return this.getAttribute('type'); }
2044
+ tag.prototype.setType = function(v){ this.setAttribute('type',v); return this; };
1944
2045
 
2046
+ tag.prototype.__autofocus = {dom: true,name: 'autofocus'};
2047
+ tag.prototype.autofocus = function(v){ return this.dom().autofocus; }
2048
+ tag.prototype.setAutofocus = function(v){ if (v != this.dom().autofocus) { this.dom().autofocus = v }; return this; };
1945
2049
  tag.prototype.__value = {dom: true,name: 'value'};
1946
2050
  tag.prototype.value = function(v){ return this.dom().value; }
1947
2051
  tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
@@ -1968,7 +2072,16 @@
1968
2072
  tag$.defineTag('ins');
1969
2073
  tag$.defineTag('kbd');
1970
2074
  tag$.defineTag('keygen');
1971
- tag$.defineTag('label');
2075
+ tag$.defineTag('label', function(tag){
2076
+ tag.prototype.accesskey = function(v){ return this.getAttribute('accesskey'); }
2077
+ tag.prototype.setAccesskey = function(v){ this.setAttribute('accesskey',v); return this; };
2078
+ tag.prototype.for = function(v){ return this.getAttribute('for'); }
2079
+ tag.prototype.setFor = function(v){ this.setAttribute('for',v); return this; };
2080
+ tag.prototype.form = function(v){ return this.getAttribute('form'); }
2081
+ tag.prototype.setForm = function(v){ this.setAttribute('form',v); return this; };
2082
+ });
2083
+
2084
+
1972
2085
  tag$.defineTag('legend');
1973
2086
  tag$.defineTag('li');
1974
2087
 
@@ -2001,13 +2114,18 @@
2001
2114
  tag$.defineTag('noscript');
2002
2115
 
2003
2116
  tag$.defineTag('ol');
2117
+
2004
2118
  tag$.defineTag('optgroup', function(tag){
2119
+ tag.prototype.label = function(v){ return this.getAttribute('label'); }
2120
+ tag.prototype.setLabel = function(v){ this.setAttribute('label',v); return this; };
2005
2121
  tag.prototype.__disabled = {dom: true,name: 'disabled'};
2006
2122
  tag.prototype.disabled = function(v){ return this.dom().disabled; }
2007
2123
  tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
2008
2124
  });
2009
2125
 
2010
2126
  tag$.defineTag('option', function(tag){
2127
+ tag.prototype.label = function(v){ return this.getAttribute('label'); }
2128
+ tag.prototype.setLabel = function(v){ this.setAttribute('label',v); return this; };
2011
2129
  tag.prototype.__disabled = {dom: true,name: 'disabled'};
2012
2130
  tag.prototype.disabled = function(v){ return this.dom().disabled; }
2013
2131
  tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
@@ -2019,7 +2137,13 @@
2019
2137
  tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
2020
2138
  });
2021
2139
 
2022
- tag$.defineTag('output');
2140
+ tag$.defineTag('output', function(tag){
2141
+ tag.prototype.for = function(v){ return this.getAttribute('for'); }
2142
+ tag.prototype.setFor = function(v){ this.setAttribute('for',v); return this; };
2143
+ tag.prototype.form = function(v){ return this.getAttribute('form'); }
2144
+ tag.prototype.setForm = function(v){ this.setAttribute('form',v); return this; };
2145
+ });
2146
+
2023
2147
  tag$.defineTag('p');
2024
2148
 
2025
2149
  tag$.defineTag('object', function(tag){
@@ -2037,7 +2161,14 @@
2037
2161
  });
2038
2162
 
2039
2163
  tag$.defineTag('pre');
2040
- tag$.defineTag('progress');
2164
+ tag$.defineTag('progress', function(tag){
2165
+ tag.prototype.max = function(v){ return this.getAttribute('max'); }
2166
+ tag.prototype.setMax = function(v){ this.setAttribute('max',v); return this; };
2167
+ tag.prototype.__value = {dom: true,name: 'value'};
2168
+ tag.prototype.value = function(v){ return this.dom().value; }
2169
+ tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
2170
+ });
2171
+
2041
2172
  tag$.defineTag('q');
2042
2173
  tag$.defineTag('rp');
2043
2174
  tag$.defineTag('rt');
@@ -2059,18 +2190,21 @@
2059
2190
  tag$.defineTag('section');
2060
2191
 
2061
2192
  tag$.defineTag('select', function(tag){
2193
+ tag.prototype.size = function(v){ return this.getAttribute('size'); }
2194
+ tag.prototype.setSize = function(v){ this.setAttribute('size',v); return this; };
2195
+ tag.prototype.form = function(v){ return this.getAttribute('form'); }
2196
+ tag.prototype.setForm = function(v){ this.setAttribute('form',v); return this; };
2062
2197
  tag.prototype.multiple = function(v){ return this.getAttribute('multiple'); }
2063
2198
  tag.prototype.setMultiple = function(v){ this.setAttribute('multiple',v); return this; };
2064
-
2199
+ tag.prototype.__autofocus = {dom: true,name: 'autofocus'};
2200
+ tag.prototype.autofocus = function(v){ return this.dom().autofocus; }
2201
+ tag.prototype.setAutofocus = function(v){ if (v != this.dom().autofocus) { this.dom().autofocus = v }; return this; };
2065
2202
  tag.prototype.__disabled = {dom: true,name: 'disabled'};
2066
2203
  tag.prototype.disabled = function(v){ return this.dom().disabled; }
2067
2204
  tag.prototype.setDisabled = function(v){ if (v != this.dom().disabled) { this.dom().disabled = v }; return this; };
2068
2205
  tag.prototype.__required = {dom: true,name: 'required'};
2069
2206
  tag.prototype.required = function(v){ return this.dom().required; }
2070
2207
  tag.prototype.setRequired = function(v){ if (v != this.dom().required) { this.dom().required = v }; return this; };
2071
- tag.prototype.__readOnly = {dom: true,name: 'readOnly'};
2072
- tag.prototype.readOnly = function(v){ return this.dom().readOnly; }
2073
- tag.prototype.setReadOnly = function(v){ if (v != this.dom().readOnly) { this.dom().readOnly = v }; return this; };
2074
2208
  tag.prototype.__value = {dom: true,name: 'value'};
2075
2209
  tag.prototype.value = function(v){ return this.dom().value; }
2076
2210
  tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };
@@ -2094,9 +2228,10 @@
2094
2228
  tag.prototype.setRows = function(v){ this.setAttribute('rows',v); return this; };
2095
2229
  tag.prototype.cols = function(v){ return this.getAttribute('cols'); }
2096
2230
  tag.prototype.setCols = function(v){ this.setAttribute('cols',v); return this; };
2097
- tag.prototype.autofocus = function(v){ return this.getAttribute('autofocus'); }
2098
- tag.prototype.setAutofocus = function(v){ this.setAttribute('autofocus',v); return this; };
2099
2231
 
2232
+ tag.prototype.__autofocus = {dom: true,name: 'autofocus'};
2233
+ tag.prototype.autofocus = function(v){ return this.dom().autofocus; }
2234
+ tag.prototype.setAutofocus = function(v){ if (v != this.dom().autofocus) { this.dom().autofocus = v }; return this; };
2100
2235
  tag.prototype.__value = {dom: true,name: 'value'};
2101
2236
  tag.prototype.value = function(v){ return this.dom().value; }
2102
2237
  tag.prototype.setValue = function(v){ if (v != this.dom().value) { this.dom().value = v }; return this; };