hobo_w2ui 0.1.3 → 0.1.4

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: 832f785cd3c2ce0d3f880ce59c995072c03bd56a
4
- data.tar.gz: 08bbdc45efe578f148e48ba1fa54a2976afb4e16
3
+ metadata.gz: bd32730b9ec51461239534e4a74e9983e0c46ded
4
+ data.tar.gz: deb93dd861acf40e92ab2d64345d530e50042013
5
5
  SHA512:
6
- metadata.gz: 6e70744004f759c11f575c9b3e3b3c7aa5d37754e2d0859c3e073a2275db241455dde8dbb138dfaaeff3c78accb22ab4bf12c209f00ecd572c2e65ea817789c9
7
- data.tar.gz: 83fb65af4d687a25679ad67b1fba72301d5319af2474d40ddbcc3a336f7b739b8afb8f4f3bb6f1f263c40517abaf0340df6ff819aac6e2f2bb896f9d62e72ae4
6
+ metadata.gz: 65525b25d5b067b30494ec38bf828e264166fce3066ca795dc8f2a7f78fbcbca87da0818b3a75abbb852024079cede70f8a650f1839ad2e88db98bef8ba6d598
7
+ data.tar.gz: 2b0aac76c076a8fa94a3f0defc74bb08c5d73f3fe10dcbfd730e614cadc6192a9d6e1343a7266ff0ea0cc66703ab91644fb27dc6007a35c212c082b5423dcc96
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1
1
+ 0.1.4
Binary file
@@ -1074,7 +1074,7 @@ w2utils.keyboard = (function (obj) {
1074
1074
  var obj = w2ui[name];
1075
1075
  if (name != w2ui_name) {
1076
1076
  if (clear(event) === false) return; // event cancelled
1077
- if (active(name) === false) return; // event cancelled
1077
+ if (active(name, event) === false) return; // event cancelled
1078
1078
  }
1079
1079
  if (obj && obj.keyboard) w2ui_name = name;
1080
1080
  } else {
@@ -1082,7 +1082,7 @@ w2utils.keyboard = (function (obj) {
1082
1082
  }
1083
1083
  }
1084
1084
 
1085
- function active (new_w2ui_name) {
1085
+ function active (new_w2ui_name, event) {
1086
1086
  if (new_w2ui_name == null) return w2ui_name;
1087
1087
  var obj = w2ui[new_w2ui_name];
1088
1088
  if (obj && obj.focus) {
@@ -1126,12 +1126,10 @@ w2utils.keyboard = (function (obj) {
1126
1126
  $.fn.w2marker = function () {
1127
1127
  var str = Array.prototype.slice.call(arguments, 0);
1128
1128
  if (str.length == 0 || !str[0]) { // remove marker
1129
- return $(this).each(function (index, el) {
1130
- el.innerHTML = el.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig, '$1'); // unmark
1131
- });
1129
+ return $(this).each(clearMarkedText);
1132
1130
  } else { // add marker
1133
1131
  return $(this).each(function (index, el) {
1134
- el.innerHTML = el.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig, '$1'); // unmark
1132
+ clearMarkedText(index, el);
1135
1133
  for (var s = 0; s < str.length; s++) {
1136
1134
  var tmp = str[s];
1137
1135
  if (typeof tmp !== 'string') tmp = String(tmp);
@@ -1145,6 +1143,12 @@ w2utils.keyboard = (function (obj) {
1145
1143
  }
1146
1144
  });
1147
1145
  }
1146
+
1147
+ function clearMarkedText(index, el) {
1148
+ while (el.innerHTML.indexOf('<span class="w2ui-marker">') != -1) {
1149
+ el.innerHTML = el.innerHTML.replace(/\<span class=\"w2ui\-marker\"\>(.*)\<\/span\>/ig, '$1'); // unmark
1150
+ }
1151
+ }
1148
1152
  };
1149
1153
 
1150
1154
  // -- w2tag - appears on the right side from element, there can be multiple on screen at a time
@@ -1762,6 +1766,8 @@ w2utils.keyboard = (function (obj) {
1762
1766
  * - record.style[field_name]
1763
1767
  * - added focus(), blur(), onFocus, onBlur
1764
1768
  * - added search.operator
1769
+ * - refactor reorderRow (not finished)
1770
+ * - return JSON can now have summary array
1765
1771
  *
1766
1772
  ************************************************************************/
1767
1773
 
@@ -1876,6 +1882,7 @@ w2utils.keyboard = (function (obj) {
1876
1882
  this.onStateRestore = null;
1877
1883
  this.onFocus = null;
1878
1884
  this.onBlur = null;
1885
+ this.onReorderRow = null;
1879
1886
 
1880
1887
  // internal
1881
1888
  this.last = {
@@ -1936,7 +1943,7 @@ w2utils.keyboard = (function (obj) {
1936
1943
 
1937
1944
  // check if there are records without recid
1938
1945
  if (records) for (var r = 0; r < records.length; r++) {
1939
- if (records[r].recid == null || typeof records[r].recid == 'undefined') {
1946
+ if (records[r].recid == null && records[r][object.recid] == null) {
1940
1947
  console.log('ERROR: Cannot add records without recid. (obj: '+ object.name +')');
1941
1948
  return;
1942
1949
  }
@@ -1945,7 +1952,7 @@ w2utils.keyboard = (function (obj) {
1945
1952
  // add searches
1946
1953
  for (var c in object.columns) {
1947
1954
  var col = object.columns[c];
1948
- if (typeof col.searchable == 'undefined' || object.getSearch(col.field) != null) continue;
1955
+ if (col.searchable == null || col.searchable === false || object.getSearch(col.field) != null) continue;
1949
1956
  var stype = col.searchable;
1950
1957
  var attr = '';
1951
1958
  if (col.searchable === true) { stype = 'text'; attr = 'size="20"'; }
@@ -2001,8 +2008,7 @@ w2utils.keyboard = (function (obj) {
2001
2008
  if (!$.isArray(record)) record = [record];
2002
2009
  var added = 0;
2003
2010
  for (var o in record) {
2004
- if (this.recid && typeof record[o].recid == 'undefined') record[o].recid = record[o][this.recid];
2005
- if (record[o].recid == null || typeof record[o].recid == 'undefined') {
2011
+ if (record[o].recid == null && record[o][this.recid] == null) {
2006
2012
  console.log('ERROR: Cannot add record without recid. (obj: '+ this.name +')');
2007
2013
  continue;
2008
2014
  }
@@ -2020,7 +2026,7 @@ w2utils.keyboard = (function (obj) {
2020
2026
  },
2021
2027
 
2022
2028
  find: function (obj, returnIndex) {
2023
- if (typeof obj == 'undefined' || obj == null) obj = {};
2029
+ if (obj == null) obj = {};
2024
2030
  var recs = [];
2025
2031
  var hasDots = false;
2026
2032
  // check if property is nested - needed for speed
@@ -2377,15 +2383,15 @@ w2utils.keyboard = (function (obj) {
2377
2383
  }
2378
2384
  switch (sdata.operator) {
2379
2385
  case 'is':
2380
- if (rec[search.field] == sdata.value) fl++; // do not hide record
2386
+ if (obj.parseField(rec, search.field) == sdata.value) fl++; // do not hide record
2381
2387
  if (search.type == 'date') {
2382
- var tmp = (rec[search.field + '_'] instanceof Date ? rec[search.field + '_'] : rec[search.field]);
2388
+ var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field));
2383
2389
  var val1 = w2utils.formatDate(tmp, 'yyyy-mm-dd');
2384
2390
  var val2 = w2utils.formatDate(val2, 'yyyy-mm-dd');
2385
2391
  if (val1 == val2) fl++;
2386
2392
  }
2387
2393
  if (search.type == 'time') {
2388
- var tmp = (rec[search.field + '_'] instanceof Date ? rec[search.field + '_'] : rec[search.field]);
2394
+ var tmp = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field));
2389
2395
  var val1 = w2utils.formatTime(tmp, 'h24:mi');
2390
2396
  var val2 = w2utils.formatTime(val2, 'h24:mi');
2391
2397
  if (val1 == val2) fl++;
@@ -2393,17 +2399,17 @@ w2utils.keyboard = (function (obj) {
2393
2399
  break;
2394
2400
  case 'between':
2395
2401
  if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1) {
2396
- if (parseFloat(rec[search.field]) >= parseFloat(val2) && parseFloat(rec[search.field]) <= parseFloat(val3)) fl++;
2402
+ if (parseFloat(obj.parseField(rec, search.field)) >= parseFloat(val2) && parseFloat(obj.parseField(rec, search.field)) <= parseFloat(val3)) fl++;
2397
2403
  }
2398
2404
  if (search.type == 'date') {
2399
- var val1 = (rec[search.field + '_'] instanceof Date ? rec[search.field + '_'] : rec[search.field]);
2405
+ var val1 = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field));
2400
2406
  var val2 = w2utils.isDate(val2, w2utils.settings.date_format, true);
2401
2407
  var val3 = w2utils.isDate(val3, w2utils.settings.date_format, true);
2402
2408
  if (val3 != null) val3 = new Date(val3.getTime() + 86400000); // 1 day
2403
2409
  if (val1 >= val2 && val1 < val3) fl++;
2404
2410
  }
2405
2411
  if (search.type == 'time') {
2406
- var val1 = (rec[search.field + '_'] instanceof Date ? rec[search.field + '_'] : rec[search.field]);
2412
+ var val1 = (obj.parseField(rec, search.field + '_') instanceof Date ? obj.parseField(rec, search.field + '_') : obj.parseField(rec, search.field));
2407
2413
  var val2 = w2utils.isTime(val2, true);
2408
2414
  var val3 = w2utils.isTime(val3, true);
2409
2415
  val2 = (new Date()).setHours(val2.hours, val2.minutes, val2.seconds ? val2.seconds : 0, 0);
@@ -3118,7 +3124,7 @@ w2utils.keyboard = (function (obj) {
3118
3124
  if ($.trim(value) != '') searchData.push(tmp);
3119
3125
  }
3120
3126
  // range in global search box
3121
- if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1 && String($.trim(value)).indexOf('-') > 0) {
3127
+ if (['int', 'float', 'money', 'currency', 'percent'].indexOf(search.type) != -1 && $.trim(String(value)).split('-').length == 2) {
3122
3128
  var t = $.trim(String(value)).split('-');
3123
3129
  var tmp = {
3124
3130
  field : search.field,
@@ -3349,7 +3355,8 @@ w2utils.keyboard = (function (obj) {
3349
3355
  if (field == 'all') {
3350
3356
  var search = { field: 'all', caption: w2utils.lang('All Fields') };
3351
3357
  el.w2field('clear');
3352
- el.change().focus();
3358
+ el.change();
3359
+ if (value !== null) el.focus();
3353
3360
  } else {
3354
3361
  var search = this.getSearch(field);
3355
3362
  if (search == null) return;
@@ -3377,36 +3384,29 @@ w2utils.keyboard = (function (obj) {
3377
3384
  $().w2overlay();
3378
3385
  },
3379
3386
 
3387
+ // clears records and related params
3380
3388
  clear: function (noRefresh) {
3381
- // this.offset = 0; // clear should not reset offset
3382
- // this.total = 0; // clear should not reset total
3383
- this.records = [];
3384
- this.summary = [];
3385
- this.last.scrollTop = 0;
3386
- this.last.scrollLeft = 0;
3387
- this.last.selection.indexes = [];
3388
- this.last.selection.columns = {};
3389
- this.last.range_start = null;
3390
- this.last.range_end = null;
3391
- this.last.xhr_offset = 0; // need this for reload button to work on remote data set
3389
+ this.total = 0;
3390
+ this.records = [];
3391
+ this.summary = [];
3392
+ this.last.xhr_offset = 0; // need this for reload button to work on remote data set
3393
+ this.reset(true);
3394
+ // refresh
3392
3395
  if (!noRefresh) this.refresh();
3393
3396
  },
3394
3397
 
3398
+ // clears scroll position, selection, ranges, goes to initial sort
3395
3399
  reset: function (noRefresh) {
3396
- // this.offset = 0; // reset should not reset offset
3397
- // this.total = 0; // reset should not reset total
3398
- this.last.scrollTop = 0;
3399
- this.last.scrollLeft = 0;
3400
- this.last.selection.indexes = [];
3401
- this.last.selection.columns = {};
3402
- this.last.range_start = null;
3403
- this.last.range_end = null;
3404
- this.last.xhr_offset = 0;
3405
- // this.searchReset(noRefresh); // do not reset search fields
3406
- // initial sort
3407
- if (this.last.sortData != null ) this.sortData = this.last.sortData;
3408
- // select none without refresh
3400
+ // position
3401
+ this.last.scrollTop = 0;
3402
+ this.last.scrollLeft = 0;
3403
+ this.last.selection = { indexes : [], column : {} };
3404
+ this.last.range_start = null;
3405
+ this.last.range_end = null;
3406
+ // additional
3407
+ this.sortData = (this.last.initialSort != null ? this.last.initialSort : []);
3409
3408
  this.set({ expanded: false }, true);
3409
+ $('#grid_'+ this.name +'_records').prop('scrollTop', 0);
3410
3410
  // refresh
3411
3411
  if (!noRefresh) this.refresh();
3412
3412
  },
@@ -3417,12 +3417,7 @@ w2utils.keyboard = (function (obj) {
3417
3417
  this.offset = parseInt(offset);
3418
3418
  if (this.offset > this.total) this.offset = this.total - this.limit;
3419
3419
  if (this.offset < 0 || !w2utils.isInt(this.offset)) this.offset = 0;
3420
- this.records = [];
3421
- this.last.xhr_offset = 0;
3422
- this.last.pull_more = true;
3423
- this.last.scrollTop = 0;
3424
- this.last.scrollLeft = 0;
3425
- $('#grid_'+ this.name +'_records').prop('scrollTop', 0);
3420
+ this.clear(true);
3426
3421
  this.reload();
3427
3422
  } else {
3428
3423
  console.log('ERROR: grid.skip() can only be called when you have remote data source.');
@@ -3430,33 +3425,29 @@ w2utils.keyboard = (function (obj) {
3430
3425
  },
3431
3426
 
3432
3427
  load: function (url, callBack) {
3433
- if (typeof url == 'undefined') {
3428
+ if (url == null) {
3434
3429
  console.log('ERROR: You need to provide url argument when calling .load() method of "'+ this.name +'" object.');
3435
3430
  return;
3436
3431
  }
3437
3432
  // default action
3433
+ this.clear(true);
3438
3434
  this.request('get-records', {}, url, callBack);
3439
3435
  },
3440
3436
 
3441
3437
  reload: function (callBack) {
3442
3438
  var url = (typeof this.url != 'object' ? this.url : this.url.get);
3443
3439
  if (url) {
3444
- this.clear(true);
3445
- this.request('get-records', {}, null, callBack);
3440
+ this.load(url, callBack);
3446
3441
  } else {
3447
- this.last.scrollTop = 0;
3448
- this.last.scrollLeft = 0;
3449
- this.last.range_start = null;
3450
- this.last.range_end = null;
3442
+ this.reset();
3451
3443
  this.localSearch();
3452
- this.refresh();
3453
3444
  if (typeof callBack == 'function') callBack({ status: 'success' });
3454
3445
  }
3455
3446
  },
3456
3447
 
3457
3448
  request: function (cmd, add_params, url, callBack) {
3458
3449
  if (typeof add_params == 'undefined') add_params = {};
3459
- if (typeof url == 'undefined' || url == '' || url == null) url = this.url;
3450
+ if (url == '' || url == null) url = this.url;
3460
3451
  if (url == '' || url == null) return;
3461
3452
  // build parameters list
3462
3453
  var params = {};
@@ -3626,9 +3617,7 @@ w2utils.keyboard = (function (obj) {
3626
3617
  if (this.last.xhr_offset == 0) {
3627
3618
  this.records = [];
3628
3619
  this.summary = [];
3629
- //data.xhr_status=data.status;
3630
- delete data.status;
3631
- $.extend(true, this, data);
3620
+ if (w2utils.isInt(data.total)) this.total = parseInt(data.total);
3632
3621
  } else {
3633
3622
  if (parseInt(data.total) != parseInt(this.total)) {
3634
3623
  w2alert(this.msgNeedReload);
@@ -3636,14 +3625,20 @@ w2utils.keyboard = (function (obj) {
3636
3625
  this.reload();
3637
3626
  return;
3638
3627
  }
3639
- var records = data.records;
3640
- delete data.records;
3641
- delete data.status;
3642
- $.extend(true, this, data);
3643
- for (var r = 0; r < records.length; r++) {
3644
- this.records.push(records[r]);
3628
+ }
3629
+ // records
3630
+ if (data.records) {
3631
+ for (var r = 0; r < data.records.length; r++) {
3632
+ this.records.push(data.records[r]);
3645
3633
  }
3646
3634
  }
3635
+ // summary records (if any)
3636
+ if (data.summary) {
3637
+ this.summary = [];
3638
+ for (var r = 0; r < data.summary.length; r++) {
3639
+ this.summary.push(data.summary[r]);
3640
+ }
3641
+ }
3647
3642
  }
3648
3643
  if (cmd == 'delete-records') {
3649
3644
  this.reset(); // unselect old selections
@@ -3768,8 +3763,8 @@ w2utils.keyboard = (function (obj) {
3768
3763
  if (typeof edit.style == 'undefined') edit.style = '';
3769
3764
  if (typeof edit.items == 'undefined') edit.items = [];
3770
3765
  var val = (rec.changes && typeof rec.changes[col.field] != 'undefined' ? w2utils.stripTags(rec.changes[col.field]) : w2utils.stripTags(rec[col.field]));
3771
- if (val == null || typeof val == 'undefined') val = '';
3772
- if (typeof value != 'undefined' && value != null) val = value;
3766
+ if (val == null) val = '';
3767
+ if (value != null) val = value;
3773
3768
  var addStyle = (typeof col.style != 'undefined' ? col.style + ';' : '');
3774
3769
  if (typeof col.render == 'string' && ['number', 'int', 'float', 'money', 'percent'].indexOf(col.render.split(':')[0]) != -1) {
3775
3770
  addStyle += 'text-align: right;';
@@ -3958,6 +3953,7 @@ w2utils.keyboard = (function (obj) {
3958
3953
  phase: 'before', type: 'change', target: this.name, input_id: el.id, recid: rec.recid, index: index, column: column,
3959
3954
  value_new: new_val, value_previous: (rec.changes && rec.changes.hasOwnProperty(col.field) ? rec.changes[col.field]: old_val), value_original: old_val
3960
3955
  };
3956
+ if (old_val == null) old_val = '';
3961
3957
  while (true) {
3962
3958
  new_val = eventData.value_new;
3963
3959
  if ((typeof new_val != 'object' && String(old_val) != String(new_val)) ||
@@ -4291,7 +4287,7 @@ w2utils.keyboard = (function (obj) {
4291
4287
  var recid = parent.prev().attr('recid');
4292
4288
  var grid = parent.parents('.w2ui-grid').attr('name');
4293
4289
  obj.selectNone();
4294
- w2utils.keyboard.active(grid);
4290
+ w2utils.keyboard.active(grid, event);
4295
4291
  w2ui[grid].set(recid, { expanded: false });
4296
4292
  w2ui[grid].collapse(recid);
4297
4293
  w2ui[grid].click(recid);
@@ -4397,7 +4393,7 @@ w2utils.keyboard = (function (obj) {
4397
4393
  obj.selectNone();
4398
4394
  var grid = subgrid.attr('name');
4399
4395
  var recs = w2ui[grid].records;
4400
- w2utils.keyboard.active(grid);
4396
+ w2utils.keyboard.active(grid, event);
4401
4397
  w2ui[grid].click(recs[recs.length-1].recid);
4402
4398
  cancel = true;
4403
4399
  break;
@@ -4444,7 +4440,7 @@ w2utils.keyboard = (function (obj) {
4444
4440
  var recid = parent.prev().attr('recid');
4445
4441
  var grid = parent.parents('.w2ui-grid').attr('name');
4446
4442
  obj.selectNone();
4447
- w2utils.keyboard.active(grid);
4443
+ w2utils.keyboard.active(grid, event);
4448
4444
  w2ui[grid].click(recid);
4449
4445
  cancel = true;
4450
4446
  break;
@@ -4462,7 +4458,7 @@ w2utils.keyboard = (function (obj) {
4462
4458
  obj.selectNone();
4463
4459
  var grid = subgrid.attr('name');
4464
4460
  var recs = w2ui[grid].records;
4465
- w2utils.keyboard.active(grid);
4461
+ w2utils.keyboard.active(grid, event);
4466
4462
  w2ui[grid].click(recs[0].recid);
4467
4463
  cancel = true;
4468
4464
  break;
@@ -4512,7 +4508,7 @@ w2utils.keyboard = (function (obj) {
4512
4508
  var recid = parent.next().attr('recid');
4513
4509
  var grid = parent.parents('.w2ui-grid').attr('name');
4514
4510
  obj.selectNone();
4515
- w2utils.keyboard.active(grid);
4511
+ w2utils.keyboard.active(grid, event);
4516
4512
  w2ui[grid].click(recid);
4517
4513
  cancel = true;
4518
4514
  break;
@@ -4533,11 +4529,11 @@ w2utils.keyboard = (function (obj) {
4533
4529
  ' style="position: absolute; top: -100px; height: 1px; width: 1px">'+ text +'</textarea>');
4534
4530
  $('#_tmp_copy_data').focus().select();
4535
4531
  // remove _tmp_copy_data textarea
4536
- $(document).on('keyup', tmp_key_down);
4537
- function tmp_key_down() {
4538
- $('#_tmp_copy_data').remove();
4539
- $(document).off('keyup', tmp_key_down);
4532
+ function tmp_key_down() {
4533
+ $('#_tmp_copy_data').remove();
4534
+ $(document).off('keyup', tmp_key_down);
4540
4535
  }
4536
+ $(document).on('keyup', tmp_key_down);
4541
4537
  break;
4542
4538
 
4543
4539
  case 88: // x - cut
@@ -5002,6 +4998,18 @@ w2utils.keyboard = (function (obj) {
5002
4998
  var rec_html = this.getRecordHTML(ind, line, isSummary);
5003
4999
  $(tr1).replaceWith(rec_html[0]);
5004
5000
  $(tr2).replaceWith(rec_html[1]);
5001
+ // apply style to row if it was changed in render functions
5002
+ var st = this.records[ind].style;
5003
+ if (typeof st == 'string') {
5004
+ var tr1 = $(this.box).find('#grid_'+ this.name +'_frec_'+ w2utils.escapeId(recid));
5005
+ var tr2 = $(this.box).find('#grid_'+ this.name +'_rec_'+ w2utils.escapeId(recid));
5006
+ tr1.attr('custom_style', st);
5007
+ tr2.attr('custom_style', st);
5008
+ if (!tr1.hasClass('w2ui-selected')) {
5009
+ tr1[0].style.cssText = 'height: '+ this.recordHeight + 'px;' + st;
5010
+ tr2[0].style.cssText = 'height: '+ this.recordHeight + 'px;' +st;
5011
+ }
5012
+ }
5005
5013
  if (isSummary) this.resize();
5006
5014
  }
5007
5015
  },
@@ -5160,7 +5168,7 @@ w2utils.keyboard = (function (obj) {
5160
5168
  this.box = box;
5161
5169
  }
5162
5170
  if (!this.box) return;
5163
- if (this.last.sortData == null) this.last.sortData = this.sortData;
5171
+ if (this.last.initialSort == null) this.last.initialSort = this.sortData;
5164
5172
  // event before
5165
5173
  var eventData = this.trigger({ phase: 'before', target: this.name, type: 'render', box: box });
5166
5174
  if (eventData.isCancelled === true) return;
@@ -5241,6 +5249,45 @@ w2utils.keyboard = (function (obj) {
5241
5249
  start : true
5242
5250
  };
5243
5251
  }
5252
+ if (obj.reorderRows == true) {
5253
+ var el = event.target;
5254
+ if (el.tagName != 'TD') el = $(el).parents('td')[0];
5255
+ if ($(el).hasClass('w2ui-col-number')) {
5256
+ obj.selectNone();
5257
+ obj.last.move.reorder = true;
5258
+ // supress hover
5259
+ var eColor = $(obj.box).find('.w2ui-even.w2ui-empty-record').css('background-color');
5260
+ var oColor = $(obj.box).find('.w2ui-odd.w2ui-empty-record').css('background-color');
5261
+ $(obj.box).find('.w2ui-even td').not('.w2ui-col-number').css('background-color', eColor);
5262
+ $(obj.box).find('.w2ui-odd td').not('.w2ui-col-number').css('background-color', oColor);
5263
+ // display empty record and ghost record
5264
+ var mv = obj.last.move;
5265
+ if (!mv.ghost) {
5266
+ var row = $('#grid_'+ obj.name + '_rec_'+ mv.recid);
5267
+ var tmp = row.parents('table').find('tr:first-child').clone();
5268
+ mv.offsetY = event.offsetY;
5269
+ mv.from = mv.recid;
5270
+ mv.pos = row.position();
5271
+ mv.ghost = $(row).clone(true);
5272
+ mv.ghost.removeAttr('id');
5273
+ row.find('td').remove();
5274
+ row.append('<td colspan="1000" style="height: '+ obj.recordHeight +'px; background-color: #eee; border-bottom: 1px dashed #aaa; border-top: 1px dashed #aaa;"></td>');
5275
+ var recs = $(obj.box).find('.w2ui-grid-records');
5276
+ recs.append('<table id="grid_'+ obj.name + '_ghost" style="position: absolute; z-index: 999999; opacity: 0.7; pointer-events: none;"></table>');
5277
+ $('#grid_'+ obj.name + '_ghost').append(tmp).append(mv.ghost);
5278
+ }
5279
+ var ghost = $('#grid_'+ obj.name + '_ghost');
5280
+ var recs = $(obj.box).find('.w2ui-grid-records');
5281
+ ghost.css({
5282
+ top : mv.pos.top + recs.scrollTop(),
5283
+ left : mv.pos.left,
5284
+ "border-top" : '1px solid #aaa',
5285
+ "border-bottom" : '1px solid #aaa'
5286
+ });
5287
+ } else {
5288
+ obj.last.move.reorder = false;
5289
+ }
5290
+ }
5244
5291
  $(document).on('mousemove', mouseMove);
5245
5292
  $(document).on('mouseup', mouseStop);
5246
5293
  }
@@ -5252,32 +5299,23 @@ w2utils.keyboard = (function (obj) {
5252
5299
  mv.divY = (event.screenY - mv.y);
5253
5300
  if (Math.abs(mv.divX) <= 1 && Math.abs(mv.divY) <= 1) return; // only if moved more then 1px
5254
5301
  obj.last.cancelClick = true;
5255
- if (obj.reorderRows == true) {
5256
- if (!mv.ghost) {
5257
- var row = $('#grid_'+ obj.name + '_rec_'+ mv.recid);
5258
- var tmp = row.parents('table').find('tr:first-child').clone();
5259
- mv.offsetY = event.offsetY;
5260
- mv.from = mv.recid;
5261
- mv.pos = row.position();
5262
- mv.ghost = $(row).clone(true);
5263
- mv.ghost.removeAttr('id');
5264
- row.find('td:first-child').replaceWith('<td colspan="1000" style="height: '+ obj.recordHeight +'px; background-color: #ddd"></td>');
5265
- var recs = $(obj.box).find('.w2ui-grid-records');
5266
- recs.append('<table id="grid_'+ obj.name + '_ghost" style="position: absolute; z-index: 999999; opacity: 0.8; border-bottom: 2px dashed #aaa; border-top: 2px dashed #aaa; pointer-events: none;"></table>');
5267
- $('#grid_'+ obj.name + '_ghost').append(tmp).append(mv.ghost);
5268
- }
5269
- var recid = $(event.target).parents('tr').attr('recid');
5302
+ if (obj.reorderRows == true && obj.last.move.reorder) {
5303
+ var tmp = $(event.target).parents('tr');
5304
+ var recid = tmp.attr('recid');
5270
5305
  if (recid != mv.from) {
5271
5306
  var row1 = $('#grid_'+ obj.name + '_rec_'+ mv.recid);
5272
5307
  var row2 = $('#grid_'+ obj.name + '_rec_'+ recid);
5273
- if (event.screenY - mv.lastY < 0) row1.after(row2); else row2.after(row1);
5308
+ $(obj.box).find('.tmp-ghost').css('border-top', '0px');
5309
+ row2.addClass('tmp-ghost').css('border-top', '2px solid #769EFC');
5310
+ // MOVABLE GHOST
5311
+ // if (event.screenY - mv.lastY < 0) row1.after(row2); else row2.after(row1);
5274
5312
  mv.lastY = event.screenY;
5275
5313
  mv.to = recid;
5276
5314
  }
5277
5315
  var ghost = $('#grid_'+ obj.name + '_ghost');
5278
5316
  var recs = $(obj.box).find('.w2ui-grid-records');
5279
5317
  ghost.css({
5280
- top : mv.pos.top + mv.divY + recs.scrollTop(), // + mv.offsetY - obj.recordHeight / 2,
5318
+ top : mv.pos.top + mv.divY + recs.scrollTop(),
5281
5319
  left : mv.pos.left
5282
5320
  });
5283
5321
  return;
@@ -5347,14 +5385,31 @@ w2utils.keyboard = (function (obj) {
5347
5385
  setTimeout(function () { delete obj.last.cancelClick; }, 1);
5348
5386
  if ($(event.target).parents().hasClass('.w2ui-head') || $(event.target).hasClass('.w2ui-head')) return;
5349
5387
  if (mv && mv.type == 'select') {
5350
- if (obj.reorderRows == true) {
5388
+ if (obj.reorderRows == true && obj.last.move.reorder) {
5389
+ // event
5390
+ var eventData = obj.trigger({ phase: 'before', target: obj.name, type: 'reorderRow', recid: mv.from, moveAfter: mv.to });
5391
+ if (eventData.isCancelled === true) {
5392
+ $('#grid_'+ obj.name + '_ghost').remove();
5393
+ obj.refresh();
5394
+ return;
5395
+ }
5396
+ // default behavior
5351
5397
  var ind1 = obj.get(mv.from, true);
5352
- var tmp = obj.records[ind1];
5353
- obj.records.splice(ind1, 1);
5354
5398
  var ind2 = obj.get(mv.to, true);
5355
- if (ind1 > ind2) obj.records.splice(ind2, 0, tmp); else obj.records.splice(ind2+1, 0, tmp);
5399
+ var tmp = obj.records[ind1];
5400
+ // swap records
5401
+ if (ind1 != null && ind2 != null) {
5402
+ obj.records.splice(ind1, 1);
5403
+ if (ind1 > ind2) {
5404
+ obj.records.splice(ind2, 0, tmp);
5405
+ } else {
5406
+ obj.records.splice(ind2 - 1, 0, tmp);
5407
+ }
5408
+ }
5356
5409
  $('#grid_'+ obj.name + '_ghost').remove();
5357
5410
  obj.refresh();
5411
+ // event after
5412
+ obj.trigger($.extend(eventData, { phase: 'after' }));
5358
5413
  }
5359
5414
  }
5360
5415
  delete obj.last.move;
@@ -5747,7 +5802,7 @@ w2utils.keyboard = (function (obj) {
5747
5802
  '<table cellpadding="0" cellspacing="0"><tr>'+
5748
5803
  ' <td>'+ this.buttons['search'].html +'</td>'+
5749
5804
  ' <td>'+
5750
- ' <input id="grid_'+ this.name +'_search_all" class="w2ui-search-all" '+
5805
+ ' <input type="text" id="grid_'+ this.name +'_search_all" class="w2ui-search-all" '+
5751
5806
  ' placeholder="'+ this.last.caption +'" value="'+ this.last.search +'"'+
5752
5807
  ' onkeydown="if (event.keyCode == 13 && w2utils.isIE) this.onchange();"'+
5753
5808
  ' onchange="'+
@@ -5997,12 +6052,7 @@ w2utils.keyboard = (function (obj) {
5997
6052
 
5998
6053
  var bodyOverflowX = false;
5999
6054
  var bodyOverflowY = false;
6000
- if (body.width() < $(records).find('>table').width() + $(frecords).find('>table').width() + 5) bodyOverflowX = true;
6001
- if (body.height() - columns.height() < $(records).find('>table').height() + (bodyOverflowX ? w2utils.scrollBarSize() : 0)) bodyOverflowY = true;
6002
-
6003
- var bodyOverflowX = false;
6004
- var bodyOverflowY = false;
6005
- if (body.width() < $(records).find('>table').width() + $(frecords).find('>table').width() + 5) bodyOverflowX = true;
6055
+ if (body.width() < $(records).find('>table').width() + $(frecords).find('>table').width()) bodyOverflowX = true;
6006
6056
  if (body.height() - columns.height() < $(records).find('>table').height() + (bodyOverflowX ? w2utils.scrollBarSize() : 0)) bodyOverflowY = true;
6007
6057
 
6008
6058
  // body might be expanded by data
@@ -6093,7 +6143,8 @@ w2utils.keyboard = (function (obj) {
6093
6143
  - (bodyOverflowY ? w2utils.scrollBarSize() : 0)
6094
6144
  - (this.show.lineNumbers ? lineNumberWidth : 0)
6095
6145
  - (this.show.selectColumn ? 26 : 0)
6096
- - (this.show.expandColumn ? 26 : 0);
6146
+ - (this.show.expandColumn ? 26 : 0)
6147
+ - 1; // left is 1xp due to border width
6097
6148
  var width_box = width_max;
6098
6149
  var percent = 0;
6099
6150
  // gridMinWidth processiong
@@ -6895,6 +6946,7 @@ w2utils.keyboard = (function (obj) {
6895
6946
  record = this.summary[ind];
6896
6947
  }
6897
6948
  if (!record) return '';
6949
+ if (record.recid == null && this.recid != null && record[this.recid] != null) record.recid = record[this.recid];
6898
6950
  var id = w2utils.escapeId(record.recid);
6899
6951
  var isRowSelected = false;
6900
6952
  if (sel.indexes.indexOf(ind) != -1) isRowSelected = true;
@@ -6939,7 +6991,8 @@ w2utils.keyboard = (function (obj) {
6939
6991
  '>';
6940
6992
  if (this.show.lineNumbers) {
6941
6993
  rec_html1 += '<td id="grid_'+ this.name +'_cell_'+ ind +'_number' + (summary ? '_s' : '') + '" '+
6942
- ' class="w2ui-col-number '+ (isRowSelected ? ' w2ui-row-selected' : '') +'">'+
6994
+ ' class="w2ui-col-number '+ (isRowSelected ? ' w2ui-row-selected' : '') +'"'+
6995
+ (this.reorderRows ? 'style="cursor: move"' : '') + '>'+
6943
6996
  (summary !== true ? '<div>'+ lineNum +'</div>' : '') +
6944
6997
  '</td>';
6945
6998
  }
@@ -7088,7 +7141,7 @@ w2utils.keyboard = (function (obj) {
7088
7141
  var data = '<div title="'+ w2utils.stripTags(title) +'" style="'+ addStyle +'">'+ data +'</div>';
7089
7142
  }
7090
7143
  }
7091
- if (data == null || typeof data == 'undefined') data = '';
7144
+ if (data == null) data = '';
7092
7145
  return data;
7093
7146
  },
7094
7147
 
@@ -7096,11 +7149,17 @@ w2utils.keyboard = (function (obj) {
7096
7149
  var col = this.columns[col_ind];
7097
7150
  var record = (summary !== true ? this.records[ind] : this.summary[ind]);
7098
7151
  var data = this.parseField(record, col.field);
7099
- if (record.changes && typeof record.changes[col.field] != 'undefined') data = record.changes[col.field];
7100
- if (data == null || typeof data == 'undefined') data = '';
7152
+ if (record.changes && typeof record.changes[col.field] != 'undefined') {
7153
+ data = record.changes[col.field];
7154
+ if ($.isPlainObject(data)) {
7155
+ if (data.text != null) data = data.text;
7156
+ if (data.id != null) data = data.id;
7157
+ }
7158
+ }
7159
+ if (data == null) data = '';
7101
7160
  return data;
7102
7161
  },
7103
-
7162
+
7104
7163
  getFooterHTML: function () {
7105
7164
  return '<div>'+
7106
7165
  ' <div class="w2ui-footer-left"></div>'+
@@ -7134,9 +7193,8 @@ w2utils.keyboard = (function (obj) {
7134
7193
  },
7135
7194
 
7136
7195
  lock: function (msg, showSpinner) {
7137
- var box = $(this.box).find('> div:first-child');
7138
7196
  var args = Array.prototype.slice.call(arguments, 0);
7139
- args.unshift(box);
7197
+ args.unshift(this.box);
7140
7198
  setTimeout(function () { w2utils.lock.apply(window, args); }, 10);
7141
7199
  },
7142
7200
 
@@ -7166,11 +7224,11 @@ w2utils.keyboard = (function (obj) {
7166
7224
  var col = this.columns[i];
7167
7225
  state.columns.push({
7168
7226
  field : col.field,
7169
- hidden : col.hidden,
7170
- size : col.size,
7171
- sizeCalculated : col.sizeCalculated,
7172
- sizeOriginal : col.sizeOriginal,
7173
- sizeType : col.sizeType
7227
+ hidden : col.hidden ? true : false,
7228
+ size : col.size ? col.size : null,
7229
+ sizeCalculated : col.sizeCalculated ? col.sizeCalculated : null,
7230
+ sizeOriginal : col.sizeOriginal ? col.sizeOriginal : null,
7231
+ sizeType : col.sizeType ? col.sizeType : null
7174
7232
  });
7175
7233
  }
7176
7234
  for (var i = 0; i < this.sortData.length; i++) state.sortData.push($.extend({}, this.sortData[i]));
@@ -8788,7 +8846,7 @@ var w2popup = {};
8788
8846
  obj.trigger($.extend(eventData, { phase: 'after'}));
8789
8847
  }, options.speed * 1000);
8790
8848
  // restore active
8791
- w2utils.keyboard.active(options._last_w2ui_name);
8849
+ w2utils.keyboard.active(options._last_w2ui_name, {});
8792
8850
  // remove keyboard events
8793
8851
  if (options.keyboard) $(document).off('keydown', this.keydown);
8794
8852
  },
@@ -9817,16 +9875,16 @@ var w2confirm = function (msg, title, callBack) {
9817
9875
  if (!$.isArray(items)) items = [items];
9818
9876
  for (var o = 0; o < items.length; o++) {
9819
9877
  // checks
9820
- if (typeof items[o].type === 'undefined') {
9878
+ if (typeof items[o].type == 'undefined') {
9821
9879
  console.log('ERROR: The parameter "type" is required but not supplied in w2toolbar.add() method.');
9822
9880
  return;
9823
9881
  }
9824
- if ($.inArray(String(items[o].type), ['button', 'check', 'radio', 'drop', 'menu', 'break', 'html', 'spacer']) === -1) {
9882
+ if ($.inArray(String(items[o].type), ['button', 'check', 'radio', 'drop', 'menu', 'break', 'html', 'spacer']) == -1) {
9825
9883
  console.log('ERROR: The parameter "type" should be one of the following [button, check, radio, drop, menu, break, html, spacer] '+
9826
9884
  'in w2toolbar.add() method.');
9827
9885
  return;
9828
9886
  }
9829
- if (typeof items[o].id === 'undefined') {
9887
+ if (typeof items[o].id == 'undefined') {
9830
9888
  console.log('ERROR: The parameter "id" is required but not supplied in w2toolbar.add() method.');
9831
9889
  return;
9832
9890
  }
@@ -9860,21 +9918,21 @@ var w2confirm = function (msg, title, callBack) {
9860
9918
 
9861
9919
  set: function (id, item) {
9862
9920
  var index = this.get(id, true);
9863
- if (index === null) return false;
9921
+ if (index == null) return false;
9864
9922
  $.extend(this.items[index], item);
9865
9923
  this.refresh(id);
9866
9924
  return true;
9867
9925
  },
9868
9926
 
9869
9927
  get: function (id, returnIndex) {
9870
- if (arguments.length === 0) {
9928
+ if (arguments.length == 0) {
9871
9929
  var all = [];
9872
9930
  for (var i1 = 0; i1 < this.items.length; i1++) if (this.items[i1].id !== null) all.push(this.items[i1].id);
9873
9931
  return all;
9874
9932
  }
9875
9933
  for (var i2 = 0; i2 < this.items.length; i2++) {
9876
- if (this.items[i2].id === id) {
9877
- if (returnIndex === true) return i2; else return this.items[i2];
9934
+ if (this.items[i2].id == id) {
9935
+ if (returnIndex == true) return i2; else return this.items[i2];
9878
9936
  }
9879
9937
  }
9880
9938
  return null;
@@ -10014,9 +10072,9 @@ var w2confirm = function (msg, title, callBack) {
10014
10072
  '<tr>';
10015
10073
  for (var i = 0; i < this.items.length; i++) {
10016
10074
  var it = this.items[i];
10075
+ if (it == null) continue;
10017
10076
  if (it.id == null) it.id = "item_" + i;
10018
- if (it === null) continue;
10019
- if (it.type === 'spacer') {
10077
+ if (it.type == 'spacer') {
10020
10078
  html += '<td width="100%" id="tb_'+ this.name +'_item_'+ it.id +'" align="right"></td>';
10021
10079
  } else {
10022
10080
  html += '<td id="tb_'+ this.name + '_item_'+ it.id +'" style="'+ (it.hidden ? 'display: none' : '') +'" '+
@@ -10053,20 +10111,20 @@ var w2confirm = function (msg, title, callBack) {
10053
10111
  }
10054
10112
  // create or refresh only one item
10055
10113
  var it = this.get(id);
10056
- if (it === null) return false;
10114
+ if (it == null) return false;
10057
10115
 
10058
10116
  var el = $(this.box).find('#tb_'+ this.name +'_item_'+ w2utils.escapeId(it.id));
10059
10117
  var html = this.getItemHTML(it);
10060
- if (el.length === 0) {
10118
+ if (el.length == 0) {
10061
10119
  // does not exist - create it
10062
- if (it.type === 'spacer') {
10120
+ if (it.type == 'spacer') {
10063
10121
  html = '<td width="100%" id="tb_'+ this.name +'_item_'+ it.id +'" align="right"></td>';
10064
10122
  } else {
10065
10123
  html = '<td id="tb_'+ this.name + '_item_'+ it.id +'" style="'+ (it.hidden ? 'display: none' : '') +'" '+
10066
10124
  ' class="'+ (it.disabled ? 'disabled' : '') +'" valign="middle">'+ html +
10067
10125
  '</td>';
10068
10126
  }
10069
- if (this.get(id, true) === this.items.length-1) {
10127
+ if (this.get(id, true) == this.items.length-1) {
10070
10128
  $(this.box).find('#tb_'+ this.name +'_right').before(html);
10071
10129
  } else {
10072
10130
  $(this.box).find('#tb_'+ this.name +'_item_'+ w2utils.escapeId(this.items[parseInt(this.get(id, true))+1].id)).before(html);
@@ -10119,8 +10177,8 @@ var w2confirm = function (msg, title, callBack) {
10119
10177
  var html = '';
10120
10178
 
10121
10179
  if (typeof item.caption !== 'undefined') item.text = item.caption;
10122
- if (typeof item.hint === 'undefined') item.hint = '';
10123
- if (typeof item.text === 'undefined') item.text = '';
10180
+ if (typeof item.hint == 'undefined') item.hint = '';
10181
+ if (typeof item.text == 'undefined') item.text = '';
10124
10182
 
10125
10183
  switch (item.type) {
10126
10184
  case 'menu':
@@ -10144,7 +10202,7 @@ var w2confirm = function (msg, title, callBack) {
10144
10202
  img +
10145
10203
  (item.text !== '' ? '<td class="w2ui-tb-caption" nowrap>'+ item.text +'</td>' : '') +
10146
10204
  (item.count != null ? '<td class="w2ui-tb-count" nowrap><span>'+ item.count +'</span></td>' : '') +
10147
- (((item.type === 'drop' || item.type === 'menu') && item.arrow !== false) ?
10205
+ (((item.type == 'drop' || item.type == 'menu') && item.arrow !== false) ?
10148
10206
  '<td class="w2ui-tb-down" nowrap><div></div></td>' : '') +
10149
10207
  ' </tr></table>'+
10150
10208
  '</td></tr></table>';
@@ -10164,8 +10222,8 @@ var w2confirm = function (msg, title, callBack) {
10164
10222
  }
10165
10223
 
10166
10224
  var newHTML = '';
10167
- if (typeof item.onRender === 'function') newHTML = item.onRender.call(this, item.id, html);
10168
- if (typeof this.onRender === 'function') newHTML = this.onRender(item.id, html);
10225
+ if (typeof item.onRender == 'function') newHTML = item.onRender.call(this, item.id, html);
10226
+ if (typeof this.onRender == 'function') newHTML = this.onRender(item.id, html);
10169
10227
  if (newHTML !== '' && newHTML != null) html = newHTML;
10170
10228
 
10171
10229
  return '<div>' + html + '</div>';
@@ -10210,11 +10268,11 @@ var w2confirm = function (msg, title, callBack) {
10210
10268
  var btn = '#tb_'+ this.name +'_item_'+ w2utils.escapeId(it.id) +' table.w2ui-button';
10211
10269
  $(btn).removeClass('down'); // need to requery at the moment -- as well as elsewhere in this function
10212
10270
 
10213
- if (it.type === 'radio') {
10271
+ if (it.type == 'radio') {
10214
10272
  for (var i = 0; i < this.items.length; i++) {
10215
10273
  var itt = this.items[i];
10216
- if (itt == null || itt.id === it.id || itt.type !== 'radio') continue;
10217
- if (itt.group === it.group && itt.checked) {
10274
+ if (itt == null || itt.id == it.id || itt.type !== 'radio') continue;
10275
+ if (itt.group == it.group && itt.checked) {
10218
10276
  itt.checked = false;
10219
10277
  this.refresh(itt.id);
10220
10278
  }
@@ -10223,7 +10281,7 @@ var w2confirm = function (msg, title, callBack) {
10223
10281
  $(btn).addClass('checked');
10224
10282
  }
10225
10283
 
10226
- if (it.type === 'drop' || it.type === 'menu') {
10284
+ if (it.type == 'drop' || it.type == 'menu') {
10227
10285
  if (it.checked) {
10228
10286
  // if it was already checked, second click will hide it
10229
10287
  it.checked = false;
@@ -10234,12 +10292,12 @@ var w2confirm = function (msg, title, callBack) {
10234
10292
  if (!$.isPlainObject(it.overlay)) it.overlay = {};
10235
10293
  var left = (el.width() - 50) / 2;
10236
10294
  if (left > 19) left = 19;
10237
- if (it.type === 'drop') {
10295
+ if (it.type == 'drop') {
10238
10296
  el.w2overlay(it.html, $.extend({ name: obj.name, left: left, top: 3 }, it.overlay, {
10239
10297
  onHide: function () { hideDrop(); }
10240
10298
  }));
10241
10299
  }
10242
- if (it.type === 'menu') {
10300
+ if (it.type == 'menu') {
10243
10301
  el.w2menu(it.items, $.extend({ left: left, top: 3 }, it.overlay, {
10244
10302
  select: function (event) {
10245
10303
  obj.menuClick({ name: obj.name, item: it, subItem: event.item, originalEvent: event.originalEvent });
@@ -10256,7 +10314,7 @@ var w2confirm = function (msg, title, callBack) {
10256
10314
  }
10257
10315
  }
10258
10316
 
10259
- if (it.type === 'check' || it.type === 'drop' || it.type === 'menu') {
10317
+ if (it.type == 'check' || it.type == 'drop' || it.type == 'menu') {
10260
10318
  it.checked = !it.checked;
10261
10319
  if (it.checked) {
10262
10320
  $(btn).addClass('checked');
@@ -10299,6 +10357,7 @@ var w2confirm = function (msg, title, callBack) {
10299
10357
  * - reorder with grag and drop
10300
10358
  * - node.style is missleading - should be there to apply color for example
10301
10359
  * - add multiselect
10360
+ * - add renderer for the node
10302
10361
  *
10303
10362
  * == 1.5 changes
10304
10363
  * - $('#sidebar').w2sidebar() - if called w/o argument then it returns sidebar object
@@ -11152,9 +11211,8 @@ var w2confirm = function (msg, title, callBack) {
11152
11211
  },
11153
11212
 
11154
11213
  lock: function (msg, showSpinner) {
11155
- var box = $(this.box).find('> div:first-child');
11156
11214
  var args = Array.prototype.slice.call(arguments, 0);
11157
- args.unshift(box);
11215
+ args.unshift(this.box);
11158
11216
  w2utils.lock.apply(window, args);
11159
11217
  },
11160
11218
 
@@ -13520,10 +13578,6 @@ var w2confirm = function (msg, title, callBack) {
13520
13578
 
13521
13579
  this.style = '';
13522
13580
  this.focus = 0; // focus first or other element
13523
- this.msgNotJSON = w2utils.lang('Return data is not in JSON format.');
13524
- this.msgAJAXerror = w2utils.lang('AJAX error. See console for more details.');
13525
- this.msgRefresh = w2utils.lang('Refreshing...');
13526
- this.msgSaving = w2utils.lang('Saving...');
13527
13581
 
13528
13582
  // events
13529
13583
  this.onRequest = null;
@@ -13645,6 +13699,10 @@ var w2confirm = function (msg, title, callBack) {
13645
13699
  // -- Implementation of core functionality
13646
13700
 
13647
13701
  w2form.prototype = {
13702
+ msgNotJSON : w2utils.lang('Return data is not in JSON format.'),
13703
+ msgAJAXerror : w2utils.lang('AJAX error. See console for more details.'),
13704
+ msgRefresh : w2utils.lang('Refreshing...'),
13705
+ msgSaving : w2utils.lang('Saving...'),
13648
13706
 
13649
13707
  get: function (field, returnIndex) {
13650
13708
  if (arguments.length === 0) {
@@ -14142,15 +14200,14 @@ var w2confirm = function (msg, title, callBack) {
14142
14200
  },
14143
14201
 
14144
14202
  lock: function (msg, showSpinner) {
14145
- var box = $(this.box).find('> div:first-child');
14146
14203
  var args = Array.prototype.slice.call(arguments, 0);
14147
- args.unshift(box);
14148
- w2utils.lock.apply(window, args);
14204
+ args.unshift(this.box);
14205
+ setTimeout(function () { w2utils.lock.apply(window, args); }, 10);
14149
14206
  },
14150
14207
 
14151
14208
  unlock: function (speed) {
14152
- var obj = this;
14153
- setTimeout(function () { w2utils.unlock(obj.box, speed); }, 25); // needed timer so if server fast, it will not flash
14209
+ var box = this.box;
14210
+ setTimeout(function () { w2utils.unlock(box, speed); }, 25); // needed timer so if server fast, it will not flash
14154
14211
  },
14155
14212
 
14156
14213
  goto: function (page) {
@@ -14400,10 +14457,12 @@ var w2confirm = function (msg, title, callBack) {
14400
14457
  $(field.el).parent().parent().removeClass('w2ui-required');
14401
14458
  }
14402
14459
  // disabled
14403
- if (field.disabled) {
14404
- $(field.el).prop('readonly', true);
14405
- } else {
14406
- $(field.el).prop('readonly', false);
14460
+ if (field.disabled != null) {
14461
+ if (field.disabled) {
14462
+ $(field.el).prop('readonly', true);
14463
+ } else {
14464
+ $(field.el).prop('readonly', false);
14465
+ }
14407
14466
  }
14408
14467
  // hidden
14409
14468
  if (field.hidden) {
@@ -14468,6 +14527,7 @@ var w2confirm = function (msg, title, callBack) {
14468
14527
  if (field.type == 'list') {
14469
14528
  var tmp_value = ($.isPlainObject(value) ? value.id : value);
14470
14529
  // normalized options
14530
+ if (!field.options.items) field.options.items = [];
14471
14531
  var items = field.options.items;
14472
14532
  if ($.isArray(items) && items.length > 0 && !$.isPlainObject(items[0])) {
14473
14533
  field.options.items = w2obj.field.prototype.normMenu(items);
@@ -14557,8 +14617,8 @@ var w2confirm = function (msg, title, callBack) {
14557
14617
  }
14558
14618
  var html = '<div>' +
14559
14619
  (this.header != '' ? '<div class="w2ui-form-header">' + this.header + '</div>' : '') +
14560
- ' <div id="form_'+ this.name +'_toolbar" class="w2ui-form-toolbar"></div>' +
14561
- ' <div id="form_'+ this.name +'_tabs" class="w2ui-form-tabs"></div>' +
14620
+ ' <div id="form_'+ this.name +'_toolbar" class="w2ui-form-toolbar" style="display: none"></div>' +
14621
+ ' <div id="form_'+ this.name +'_tabs" class="w2ui-form-tabs" style="display: none"></div>' +
14562
14622
  this.formHTML +
14563
14623
  '</div>';
14564
14624
  $(this.box).attr('name', this.name)
@@ -888,7 +888,7 @@ button.w2ui-btn-red.clicked {
888
888
  border-top-color: #81C6FF;
889
889
  }
890
890
  /*
891
- * ARROWS
891
+ * ARROWS
892
892
  */
893
893
  .arrow-up {
894
894
  background: none;
@@ -971,7 +971,7 @@ button.w2ui-btn-red.clicked {
971
971
  outline: 1px solid #666;
972
972
  border: 1px solid #fff;
973
973
  }
974
- /*
974
+ /*
975
975
  * DATE overlay
976
976
  */
977
977
  .w2ui-calendar {
@@ -2222,6 +2222,7 @@ button.w2ui-btn-red.clicked {
2222
2222
  * ---- Sidebar ----
2223
2223
  */
2224
2224
  .w2ui-sidebar {
2225
+ position: relative;
2225
2226
  cursor: default;
2226
2227
  overflow: hidden !important;
2227
2228
  background-color: #edf1f6 !important;
@@ -2239,7 +2240,7 @@ button.w2ui-btn-red.clicked {
2239
2240
  box-sizing: border-box;
2240
2241
  }
2241
2242
  .w2ui-sidebar > div {
2242
- position: relative;
2243
+ position: absolute;
2243
2244
  overflow: hidden;
2244
2245
  }
2245
2246
  .w2ui-sidebar .w2ui-sidebar-top {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hobo_w2ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Haslinger
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-19 00:00:00.000000000 Z
11
+ date: 2014-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hobo_jquery