uki 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -6,13 +6,12 @@ include('../background.js');
6
6
  * @class
7
7
  */
8
8
  uki.background.Rows = uki.newClass(new function() {
9
- var proto = this,
10
- cache = [],
9
+ var cache = [],
11
10
  packSize = 100;
12
11
 
13
12
  /**#@+ @memberOf uki.background.Rows.prototype */
14
13
 
15
- proto.init = function(height, colors) {
14
+ this.init = function(height, colors) {
16
15
  this._height = height || 20;
17
16
  this._colors = uki.isArray(colors) ? colors : colors.split(' ');
18
17
  this._packSize = CEIL(packSize/this._colors.length)*this._colors.length;
@@ -21,7 +20,7 @@ uki.background.Rows = uki.newClass(new function() {
21
20
  if (this._colors.length == 1) this._colors = this._colors.concat(['#FFF']);
22
21
  };
23
22
 
24
- proto.attachTo = function(comp) {
23
+ this.attachTo = function(comp) {
25
24
  this._comp && this.detach();
26
25
  this._comp = comp;
27
26
  if (!this._container) {
@@ -35,7 +34,7 @@ uki.background.Rows = uki.newClass(new function() {
35
34
  this._comp.bind('layout', this._layoutHandler);
36
35
  };
37
36
 
38
- proto.layout = function(rect, visibleRect) {
37
+ this.layout = function(rect, visibleRect) {
39
38
  var height = visibleRect ? visibleRect.height + this._visibleExt*2 : rect.maxY();
40
39
  while (this._renderedHeight < height) {
41
40
  var h = packSize * this._height,
@@ -48,7 +47,8 @@ uki.background.Rows = uki.newClass(new function() {
48
47
  }
49
48
  };
50
49
 
51
- proto.detach = function() {
50
+ this.detach = function() {
51
+ if (!this._comp) return;
52
52
  this._comp.dom().removeChild(this._container);
53
53
  this._comp.unbind('layout', this._layoutHandler);
54
54
  this._comp = null;
@@ -52,7 +52,7 @@ uki.background.Sliced9 = uki.newClass(new function() {
52
52
 
53
53
  /** @ignore */
54
54
  function img (setting, style) {
55
- return uki.imageHTML(setting[0], setting[1], setting[2], ' galleryimg="no" style="-webkit-user-drag:none;position:absolute;' + style + '"');
55
+ return uki.imageHTML(setting[0], setting[1], setting[2], ' ondragstart="return false;" galleryimg="no" style="-webkit-user-drag:none;position:absolute;' + style + '"');
56
56
  }
57
57
 
58
58
  /** @ignore */
@@ -101,7 +101,7 @@ uki.background.Sliced9 = uki.newClass(new function() {
101
101
  }
102
102
  if (settings.m) {
103
103
  html[html.length] = makeDiv('m',
104
- [LEFT + inset.left + PX, TOP + inset.top + PX, RIGHT + inset.left + PX, BOTTOM + inset.bottom + PX].join(';'),
104
+ [LEFT + inset.left + PX, TOP + inset.top + PX, RIGHT + inset.right + PX, BOTTOM + inset.bottom + PX].join(';'),
105
105
  settings.m, [LEFT + 0, TOP + 0, HEIGHT + P100, WIDTH + P100].join(';'), ''
106
106
  );
107
107
  }
@@ -167,8 +167,7 @@ uki.fn = uki.Collection.prototype = new function() {
167
167
  @name uki.Collection#focusable */
168
168
  /** @function
169
169
  @name uki.Collection#style */
170
- uki.Collection.addAttrs(('dom,html,text,background,value,rect,checked,anchors,' +
171
- 'childViews,typeName,id,name,visible,disabled,focusable,style').split(','));
170
+ uki.Collection.addAttrs('dom html text background value rect checked anchors childViews typeName id name visible disabled focusable style draggable textSelectable'.split(' '));
172
171
 
173
172
  /** @function
174
173
  @name uki.Collection#parent */
@@ -1,3 +1,4 @@
1
+ include('const.js');
1
2
  /**
2
3
  * Shortcut access to uki.build, uki.Selector.find and uki.Collection constructor
3
4
  * uki('#id') is also a shortcut for search by id
@@ -9,7 +10,7 @@
9
10
  * @name uki
10
11
  * @return {uki.Collection}
11
12
  */
12
- root.uki = function(val, context) {
13
+ root.uki = root.uki || function(val, context) {
13
14
  if (typeof val == 'string') {
14
15
  var m = val.match(/^#((?:[\w\u00c0-\uFFFF_-]|\\.)+)$/),
15
16
  e = m && uki._ids[m[1]];
@@ -27,7 +28,7 @@ root.uki = function(val, context) {
27
28
  * @type string
28
29
  * @field
29
30
  */
30
- uki.version = '0.1.0.1';
31
+ uki.version = '0.1.2';
31
32
 
32
33
  /**
33
34
  * Empty function
@@ -2,17 +2,17 @@ include('uki.js');
2
2
 
3
3
  var toString = Object.prototype.toString,
4
4
  trim = String.prototype.trim,
5
+ slice = Array.prototype.slice,
5
6
 
6
7
  trimRe = /^\s+|\s+$/g;
7
8
 
8
9
  var marked = '__uki_marked';
9
-
10
- var utils =
10
+
11
+
11
12
  /**
12
- * Utility functions. Can be called both as uki.utils.function or uki.function
13
- * @namespace
13
+ * Utility functions.
14
14
  */
15
- uki.utils = {
15
+ var utils = {
16
16
 
17
17
  /**
18
18
  * Sets or retrieves attribute on an object.
@@ -30,16 +30,16 @@ uki.utils = {
30
30
  */
31
31
  attr: function(target, attr, value) {
32
32
  if (value !== undefined) {
33
- // if (target[attr].apply) {
34
- if (utils.isFunction(target[attr])) {
33
+ if (target[attr] && target[attr].apply) {
34
+ // if (uki.isFunction(target[attr])) {
35
35
  target[attr](value);
36
36
  } else {
37
37
  target[attr] = value;
38
38
  }
39
39
  return target;
40
40
  } else {
41
- // if (target[attr].apply) {
42
- if (utils.isFunction(target[attr])) {
41
+ if (target[attr] && target[attr].apply) {
42
+ // if (uki.isFunction(target[attr])) {
43
43
  return target[attr]();
44
44
  } else {
45
45
  return target[attr];
@@ -54,9 +54,12 @@ uki.utils = {
54
54
  * @param {object} context
55
55
  */
56
56
  proxy: function(fn, context) {
57
- return function() {
58
- return fn.apply(context, arguments);
59
- }
57
+ var args = slice.call(arguments, 2),
58
+ result = function() {
59
+ return fn.apply(context, args.concat(slice.call(arguments, 0)));
60
+ };
61
+ result.huid = fn.huid = fn.huid || uki.dom.guid++;
62
+ return result;
60
63
  },
61
64
 
62
65
  /**
@@ -213,8 +216,8 @@ uki.utils = {
213
216
  */
214
217
  map: function( elems, callback, context ) {
215
218
  var ret = [],
216
- mapper = utils.isFunction(callback) ? callback :
217
- function(e) { return utils.attr(e, callback); };
219
+ mapper = uki.isFunction(callback) ? callback :
220
+ function(e) { return uki.attr(e, callback); };
218
221
 
219
222
  for ( var i = 0, length = elems.length; i < length; i++ ) {
220
223
  var value = mapper.call( context || elems[ i ], elems[ i ], i );
@@ -312,7 +315,7 @@ uki.utils = {
312
315
  tmp = arguments[i];
313
316
  if (this.isFunction(tmp)) tmp = tmp.apply(tmp, baseClasses);
314
317
  baseClasses.push(tmp);
315
- utils.extend(klass.prototype, arguments[i]);
318
+ uki.extend(klass.prototype, arguments[i]);
316
319
  };
317
320
  if (!klass.prototype.init) klass.prototype.init = function() {};
318
321
  return klass;
@@ -372,22 +375,22 @@ uki.utils = {
372
375
  * @param {Array.<string>} props Property names
373
376
  */
374
377
  addProps: function(proto, props) {
375
- utils.each(props, function() { proto[this] = utils.newProp('_' + this); });
378
+ uki.each(props, function() { proto[this] = uki.newProp('_' + this); });
376
379
  },
377
380
 
378
381
  toArray: function(arr) {
379
- return Array.prototype.slice.call(arr, 0);
382
+ return slice.call(arr, 0);
380
383
  },
381
384
 
382
385
  delegateProp: function(proto, name, target) {
383
386
  var propName = '_' + name;
384
387
  proto[name] = function(value) {
385
388
  if (value === undefined) {
386
- if (this[target]) return utils.attr(this[target], name, value);
389
+ if (this[target]) return uki.attr(this[target], name, value);
387
390
  return this[propName];
388
391
  }
389
392
  if (this[target]) {
390
- utils.attr(this[target], name, value);
393
+ uki.attr(this[target], name, value);
391
394
  } else {
392
395
  this[propName] = value;
393
396
  }
@@ -395,5 +398,5 @@ uki.utils = {
395
398
  };
396
399
  }
397
400
  };
398
-
399
- utils.extend(uki, utils);
401
+ utils.extend(uki, utils);
402
+ delete utils;
@@ -274,25 +274,22 @@ uki.view.declare('uki.view.Base', uki.view.Observable, uki.view.Styleable, funct
274
274
  this._firstLayout = false;
275
275
  };
276
276
 
277
- /**
278
- * @function
279
- */
280
- this.minSize = uki.newProp('_minSize', function(s) {
281
- this._minSize = Size.create(s);
282
- this.rect(this._parentRect);
283
- if (this._minSize.width) this._dom.style.minWidth = this._minSize.width + PX;
284
- if (this._minSize.height) this._dom.style.minHeight = this._minSize.height + PX;
285
- });
286
277
 
287
278
  /**
288
- * @function
279
+ * @function uki.view.Base#minSize
280
+ * @function uki.view.Base#maxSize
289
281
  */
290
- this.maxSize = uki.newProp('_maxSize', function(s) {
291
- this._maxSize = Size.create(s);
292
- this.rect(this._parentRect);
293
- if (this._maxSize.width) this._dom.style.maxWidth = this._maxSize.width + PX;
294
- if (this._maxSize.height) this._dom.style.maxHeight = this._maxSize.height + PX;
295
- });
282
+ uki.each(['min', 'max'], function(i, name) {
283
+ var attr = name + 'Size',
284
+ prop = '_' + attr;
285
+ this[attr] = function(s) {
286
+ if (s === undefined) return this[prop] || new Size();
287
+ this[prop] = Size.create(s);
288
+ this.rect(this._parentRect);
289
+ if (this[prop].width) this._dom.style[name + 'Width'] = this[prop].width + PX;
290
+ if (this[prop].height) this._dom.style[name + 'Height'] = this[prop].height + PX;
291
+ };
292
+ }, this);
296
293
 
297
294
  /**
298
295
  * Resizes view when parent changes size according to anchors.
@@ -431,7 +428,9 @@ uki.view.declare('uki.view.Base', uki.view.Observable, uki.view.Styleable, funct
431
428
  @name uki.view.Base#top */
432
429
  uki.each(['width', 'height', 'minX', 'maxX', 'minY', 'maxY', 'left', 'top'], function(index, attr) {
433
430
  this[attr] = function(value) {
434
- return uki.attr(this.rect(), attr, value);
431
+ if (value === undefined) return uki.attr(this.rect(), attr);
432
+ uki.attr(this.rect(), attr, value);
433
+ return this;
435
434
  };
436
435
  }, this);
437
436
 
@@ -54,7 +54,7 @@ uki.view.Styleable = new function() {
54
54
  if (this._textSelectProp) {
55
55
  this._dom.style[this._textSelectProp] = state ? '' : this._textSelectProp == 'MozUserSelect' ? '-moz-none' : 'none';
56
56
  } else {
57
- // uki.dom[state ? 'unbind' : 'bind'](this.dom(), 'selectstart mousedown', uki.dom.preventDefaultHandler);
57
+ uki.dom[state ? 'unbind' : 'bind'](this.dom(), 'selectstart', uki.dom.preventDefaultHandler);
58
58
  }
59
59
  this._dom.style.cursor = state ? 'text' : 'default';
60
60
  return this;