zimjs 17.1.0 → 17.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/zim.js CHANGED
@@ -9745,6 +9745,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
9745
9745
  this.setBounds = function(a,b,c,d) {
9746
9746
  var n = normalizeBounds(a, b, c, d);
9747
9747
  that.cjsContainer_setBounds(n[0],n[1],n[2],n[3]);
9748
+ that.width;
9748
9749
  return that;
9749
9750
  };
9750
9751
  this.getBounds = function(targetSpace) {
@@ -10197,6 +10198,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
10197
10198
  this.setBounds = function(a,b,c,d) {
10198
10199
  var n = normalizeBounds(a, b, c, d);
10199
10200
  this.cjsShape_setBounds(n[0],n[1],n[2],n[3]);
10201
+ this.width;
10200
10202
  return this;
10201
10203
  };
10202
10204
  this.getBounds = function(targetSpace) {
@@ -10273,9 +10275,10 @@ zim class - extends a createjs.Bitmap
10273
10275
 
10274
10276
  DESCRIPTION
10275
10277
  Makes a Bitmap object from an image source (image, video or canvas).
10276
- It is best to use the assets and path parameters of ZIM Frame or the loadAssets() method of Frame
10277
- to preload the image and then use the asset() method to access the Bitmap.
10278
- See the ZIM Frame class and asset example on the ZIM Frame page of templates.
10278
+ It is best to preload images in the Frame() or with loadAssets() and the path parameter
10279
+ then simply use ZIM Pic() to display the image.
10280
+ See the ZIM Frame class and ZIM Pic in the Docs.
10281
+ But Bitmap() is handy to turn other canvases or any DisplayObject into a picture.
10279
10282
 
10280
10283
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
10281
10284
 
@@ -10597,6 +10600,7 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
10597
10600
  this.setBounds = function(a,b,c,d) {
10598
10601
  var n = normalizeBounds(a, b, c, d);
10599
10602
  that.cjsBitmap_setBounds(n[0],n[1],n[2],n[3]);
10603
+ that.width;
10600
10604
  return that;
10601
10605
  };
10602
10606
  this.getBounds = function(targetSpace) {
@@ -10786,6 +10790,424 @@ zim.Bitmap.prototype.dispose = function() {return this.doDispose();};
10786
10790
  zimify(zim.Bitmap.prototype);
10787
10791
  //-50.7
10788
10792
 
10793
+ /*--
10794
+ zim.SlicedBitmap = function(width, height, obj, slices, types, gap, scale, style, group, inherit)
10795
+
10796
+ SlicedBitmap
10797
+ zim class - extends a zim.Bitmap which extends a createjs.Bitmap
10798
+
10799
+ DESCRIPTION
10800
+ Makes an n-sliced bitmap. This is similar to 9-sliced, and can do 9-sliced,
10801
+ but also can have any number of horizontal or vertical slices.
10802
+ The slices make regions that can be fixed in scale, stretched or tiled.
10803
+ This is handy for graphics that have detailed corners or edges that should not be scaled
10804
+ and then areas that can be scaled or tiled when size is changed.
10805
+ The bitmap can then be sized with slicesWidth and slicesHeight rather than width and height
10806
+ to stretch and tile those regions but leave fixed regions fixed in size.
10807
+
10808
+ The ZIM transform() defaults to using slicesWidth and slicesHeight when resizing the edges
10809
+ it will still scale when using the corners. This can be turned off by setting sliceX and sliceY parameters of transform to false.
10810
+
10811
+ Properties for the slice lines are available and can be set and animated as can the scalesWidth and scalesHeight.
10812
+
10813
+ SEE: https://zimjs.com/slices for the ZIM Slices tool and example of SlicedBitmap
10814
+
10815
+ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
10816
+
10817
+ EXAMPLE
10818
+ // slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
10819
+ new SlicedBitmap(1600, pic.height, pic, [0.25,0.75],[0.25,0.75]], [[0,1,0],[0,1,0])
10820
+ .center()
10821
+ .transform({minScaleX:.05, minScaleY:.05});
10822
+ END EXAMPLE
10823
+
10824
+ EXAMPLE
10825
+ // slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
10826
+ const pic = new Pic("car.png"); // preload this in Frame() or loadAssets()
10827
+ const startSlices = [0.25,0.75],[0.25,0.75]];
10828
+ const startTypes = [[0,2,0],[0,1,0]; // middle is tiled horizontally and stretched vertically
10829
+ const slicer = new Slicer({
10830
+ obj:pic.clone(), // slicer will adjust obj so clone the pic so can use it unaffected later
10831
+ scale:.5,
10832
+ slices:startSlices,
10833
+ types:startTypes,
10834
+ upload:false
10835
+ })
10836
+ .pos(30,50)
10837
+ .change(()=>{preview.exchange = slicer.exchange;); // this will update the picture below
10838
+
10839
+ // this will provide slice type options
10840
+ new SlicerTypes(slicer).pos(30,120,RIGHT,TOP);
10841
+
10842
+ // SlicedBitmaps slicesWidth and slicesHeight do not currently scale from the registration point
10843
+ // here we animate the slicesWidth and use a container to animate from the center
10844
+ const holder = new Container(800,400).center();
10845
+ const preview = new SlicedBitmap(1600, pic.height, pic, slicer.slices, slicer.types, 2, .5)
10846
+ .center(holder)
10847
+ .animate({
10848
+ props:{slicesWidth:980},
10849
+ // props:{sH0:.31}, // alternatively, animate the first horizontal slice (vertical line)
10850
+ time:2,
10851
+ ease:"elasticInOut",
10852
+ rewind:true,
10853
+ rewindWait:1,
10854
+ loop:true,
10855
+ loopWait:1,
10856
+ animateCall:()=>{preview.center(holder)} // always recenter the SlicedBitmap in the container
10857
+ });
10858
+ END EXAMPLE
10859
+
10860
+ PARAMETERS
10861
+ ** supports DUO - parameters or single object with properties below
10862
+ ** supports OCT - parameter defaults can be set with STYLE control (like CSS)
10863
+ width - (default null) the width of the object - this will apply slices and types settings to keep fixed, scale or tile regions
10864
+ height - (default null) the height of the object - this will apply slices and types settings to keep fixed, scale or tile regions
10865
+ obj - (default null) a DisplayObject such as a ZIM Pic, Container, etc. or an HTML image or canvas
10866
+ slices - (default null) an array of horizontal and vertical arrays holding slice percentage
10867
+ [[.25,.75], [.1,.4,.5,.9]]
10868
+ three horizontal regions made from two vertical lines placed at 1/4 and 3/4 the width
10869
+ five vertical regions made from four horizontal lines with 1/10 the picture at left, middle and right
10870
+ types - (default null) an array of horizontal and vertical arrays holding slice types
10871
+ 0 - fix - keeps the original width and height of the region. Usually, good for corners.
10872
+ 1 - stretch - stretch the region to fill space as an object is stretched
10873
+ 2 - tile - tile the region at original scale - currently, will match the first side and sometimes the second side
10874
+ gap - (default 2) pixels to overlap on each side to avoid canvas ditthered edges
10875
+ scale - (default 1) a scale for the caching
10876
+ style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
10877
+ group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
10878
+ inherit - (default null) used internally but can receive an {} of styles directly
10879
+
10880
+ METHODS
10881
+ slicesSca() - like sca() but will call sclicesScaleX and slicesScaleY to operate on regions
10882
+ hasProp(property as String) - returns true if property exists on object else returns false
10883
+ clone() - makes a copy with properties such as x, y, etc. also copied - also copies file and src properties
10884
+ dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
10885
+ if this is a cloned bitmap then the original asset("image.png") will still exist unless it is disposed.
10886
+
10887
+ ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
10888
+ drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
10889
+ addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
10890
+ ALSO: see the ZIM Bitmap methods, such as:
10891
+ keyOut(), cache(), getColorAt(), etc.
10892
+ ALSO: see the CreateJS Easel Docs for Bitmap methods, such as:
10893
+ on(), off(), dispatchEvent(), etc.
10894
+
10895
+ PROPERTIES
10896
+ type - holds the class name as a String
10897
+ slices - get or set slices - see slices parameter and sH, sV properties
10898
+ types - get or set types - see types parameter and tH, tV properties
10899
+ gap - get or set the gap 0 see gap parameter
10900
+ slicesWidth - set the width so slices operate - different than width which will scale in general, not operating the slices
10901
+ slicesHeight - set the height so slices operate - different than height which will scale in general, not operating the slices
10902
+ slicesSale - set the scale so the slices operate - different than scale which will scale in general, not operating the slices
10903
+ slicesScaleX - set the scaleX so the slices operate - different than scaleX which will scale in general, not operating the slices
10904
+ slicesScaleY - set the scaleY so the slices operate - different than scaleY which will scale in general, not operating the slices
10905
+ exchange - set the [slices, types] in one array - used to recieve data from the ZIM Slicer
10906
+ sH - set an individual horizontal slice percent - these are sH0, sH1, sH2, etc. and are properties that can be animated and wiggled as well
10907
+ sV - set an individual vertical slice percent - these are sH0, sH1, sH2, etc. and are properties that can be animated and wiggled as well
10908
+ tH - set an individual horizontal slice type - also see types parameter
10909
+ tV - set an individual vertical slice type - also see types parameter
10910
+
10911
+ ALSO: see ZIM Docs for Bitmap properties, such as:
10912
+ width, height, widthOnly, heightOnly, draggable, level, blendMode, etc.
10913
+ ALSO: see the CreateJS Easel Docs for Bitmap properties, such as:
10914
+ x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
10915
+ alpha, cursor, shadow, mouseEnabled, etc.
10916
+
10917
+ EVENTS
10918
+ See the CreateJS Easel Docs for Bitmap events, such as:
10919
+ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
10920
+ --*///+50.7
10921
+ zim.SlicedBitmap = function(width, height, obj, slices, types, gap, scale, style, group, inherit) {
10922
+ var sig = "width, height, obj, slices, types, gap, scale, style, group, inherit";
10923
+ var duo; if (duo = zob(zim.SlicedBitmap, arguments, sig, this)) return duo;
10924
+ z_d("50.75");
10925
+
10926
+ this.group = group;
10927
+ var DS = style===false?{}:zim.getStyle("SlicedBitmap", this.group, inherit);
10928
+
10929
+ var objCanvas;
10930
+ var message = "ZIM SlicedBitmap needs DisplayObject";
10931
+ if (zot(obj)) obj = DS.obj!=null?DS.obj:null;
10932
+ if (!obj.getBounds) {zogy(message); return;}
10933
+ var b = obj.getBounds();
10934
+ var w = b.width;
10935
+ var h = b.height;
10936
+ if (zot(width)) width = DS.width!=null?DS.width:500;
10937
+ if (zot(height)) height = DS.height!=null?DS.height:500;
10938
+ if (!obj.cacheCanvas) {
10939
+ if (obj.cache) {
10940
+ obj.cache(b.x,b.y,w,h);
10941
+ objCanvas = obj.cacheCanvas;
10942
+ }
10943
+ else {zogy(message); return;}
10944
+ } else {
10945
+ objCanvas = obj.cacheCanvas;
10946
+ }
10947
+ if (zot(slices)) slices = DS.slices!=null?DS.slices:[[],[]];
10948
+ var defaults = [[1],[1]];
10949
+ zim.loop(slices,function(s,i) {
10950
+ zim.loop(s,function() {
10951
+ defaults[i].push(1);
10952
+ });
10953
+ });
10954
+ if (zot(types)) types = DS.types!=null?DS.types:defaults;
10955
+ if (zot(scale)) scale = DS.scale!=null?DS.scale:1;
10956
+
10957
+ // convert to createjs pixels rather than percent
10958
+ var slicesSend = zim.copy(slices);
10959
+ zim.loop(slicesSend[0], function(s,i) {
10960
+ slicesSend[0][i] = s*w;
10961
+ });
10962
+ zim.loop(slicesSend[1], function(s,i) {
10963
+ slicesSend[1][i] = s*h;
10964
+ });
10965
+ var sb = this.scaleBitmap = new createjs.ScaleBitmap(objCanvas, slicesSend, types, gap);
10966
+ slicesSend = null;
10967
+ sb.setDrawSize(width,height);
10968
+ sb.cache(0,0,width,height,scale);
10969
+
10970
+
10971
+ this.zimBitmap_constructor(sb.cacheCanvas);
10972
+ this.type = "SlicedBitmap";
10973
+ var that = this;
10974
+
10975
+ // METHODS
10976
+
10977
+ that.slicesSca = function(scale, scaleY) {
10978
+ if (zot(scale)) scale = that.slicesScaleX;
10979
+ if (zot(scaleY)) scaleY = scale;
10980
+ obj.slicesScaleX = scale; obj.slicesScaleY = scaleY;
10981
+ return that;
10982
+ };
10983
+
10984
+ // PROPERTIES
10985
+
10986
+ Object.defineProperty(that, 'slicesWidth', {
10987
+ get: function() {
10988
+ return width;
10989
+ },
10990
+ set: function(value) {
10991
+ width = value;
10992
+ sb.setDrawSize(width, height);
10993
+ sb.cache(0,0,width,height,scale);
10994
+ that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
10995
+ that.setBounds(null);
10996
+ if (that.transformControls) that.transformControls.resize();
10997
+ }
10998
+ });
10999
+ Object.defineProperty(that, 'ssW', { // no transformControls resize as was feeding back from transform
11000
+ get: function() {
11001
+ return width;
11002
+ },
11003
+ set: function(value) {
11004
+ width = value;
11005
+ sb.setDrawSize(width, height);
11006
+ sb.cache(0,0,width,height,scale);
11007
+ that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
11008
+ that.setBounds(null);
11009
+ }
11010
+ });
11011
+
11012
+ Object.defineProperty(that, 'slicesHeight', {
11013
+ get: function() {
11014
+ return height;
11015
+ },
11016
+ set: function(value) {
11017
+ height = value;
11018
+ sb.setDrawSize(width, height);
11019
+ sb.cache(0,0,width,height,scale);
11020
+ that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
11021
+ that.setBounds(null);
11022
+ if (that.transformControls) that.transformControls.resize();
11023
+ }
11024
+ });
11025
+ Object.defineProperty(that, 'ssH', { // no transformControls resize as was feeding back from transform
11026
+ get: function() {
11027
+ return height;
11028
+ },
11029
+ set: function(value) {
11030
+ height = value;
11031
+ sb.setDrawSize(width, height);
11032
+ sb.cache(0,0,width,height,scale);
11033
+ that.sourceRect = new createjs.Rectangle(0,0,width*scale,height*scale);
11034
+ that.setBounds(null);
11035
+ }
11036
+ });
11037
+
11038
+ var originalWidth = width;
11039
+ Object.defineProperty(that, 'slicesScaleX', {
11040
+ get: function() {
11041
+ return width/originalWidth;
11042
+ },
11043
+ set: function(value) {
11044
+ that.slicesWidth = value?originalWidth*value:0;
11045
+ }
11046
+ });
11047
+ Object.defineProperty(that, 'ssX', { // no transformControls resize as was feeding back from transform
11048
+ get: function() {
11049
+ return width/originalWidth;
11050
+ },
11051
+ set: function(value) {
11052
+ that.ssW = value?originalWidth*value:0;
11053
+ }
11054
+ });
11055
+
11056
+ var originalHeight = height;
11057
+ Object.defineProperty(that, 'slicesScaleY', {
11058
+ get: function() {
11059
+ return height/originalHeight;
11060
+ },
11061
+ set: function(value) {
11062
+ that.slicesHeight = value?originalHeight*value:0;
11063
+ }
11064
+ });
11065
+ Object.defineProperty(that, 'ssY', { // no transformControls resize as was feeding back from transform
11066
+ get: function() {
11067
+ return height/originalHeight;
11068
+ },
11069
+ set: function(value) {
11070
+ that.ssH = value?originalHeight*value:0;
11071
+ }
11072
+ });
11073
+
11074
+ Object.defineProperty(that, 'slicesScale', {
11075
+ get: function() {
11076
+ return width/originalWidth;
11077
+ },
11078
+ set: function(value) {
11079
+ that.slicesWidth = value?originalWidth*value:0;
11080
+ that.slicesHeight = value?originalHeight*value:0;
11081
+ }
11082
+ });
11083
+
11084
+
11085
+ Object.defineProperty(that, 'slices', {
11086
+ get: function() {
11087
+ return slices;
11088
+ },
11089
+ set: function(value) {
11090
+ if (zot(value) || !Array.isArray(value)) value = [[],[]];
11091
+ slices = value;
11092
+ var b = obj.getBounds();
11093
+ var w = b.width;
11094
+ var h = b.height;
11095
+ var slicesSend = zim.copy(slices);
11096
+ zim.loop(slicesSend[0], function(s,i) {
11097
+ slicesSend[0][i] = s*w;
11098
+ });
11099
+ zim.loop(slicesSend[1], function(s,i) {
11100
+ slicesSend[1][i] = s*h;
11101
+ });
11102
+ sb.slices = slicesSend;
11103
+ slicesSend = null;
11104
+ sb.updateCache();
11105
+ }
11106
+ });
11107
+
11108
+ Object.defineProperty(that, 'types', {
11109
+ get: function() {
11110
+ return types;
11111
+ },
11112
+ set: function(value) {
11113
+ if (zot(value) || !Array.isArray(value)) {
11114
+ var defaults = [[1],[1]];
11115
+ zim.loop(slices,function(s,i) {
11116
+ zim.loop(s,function() {
11117
+ defaults[i].push(1);
11118
+ });
11119
+ });
11120
+ value = defaults;
11121
+ }
11122
+ sb.types = types = value;
11123
+ sb.updateCache();
11124
+ }
11125
+ });
11126
+
11127
+ Object.defineProperty(that, 'gap', {
11128
+ get: function() {
11129
+ return gap;
11130
+ },
11131
+ set: function(value) {
11132
+ sb.gap = gap = value;
11133
+ }
11134
+ });
11135
+
11136
+ Object.defineProperty(that, 'exchange', {
11137
+ get: function() {
11138
+ return [slices, types];
11139
+ },
11140
+ set: function(value) {
11141
+ var b = obj.getBounds();
11142
+ var w = b.width;
11143
+ var h = b.height;
11144
+ slices = value[0];
11145
+ var slicesSend = zim.copy(slices);
11146
+ zim.loop(slicesSend[0], function(s,i) {
11147
+ slicesSend[0][i] = s*w;
11148
+ });
11149
+ zim.loop(slicesSend[1], function(s,i) {
11150
+ slicesSend[1][i] = s*h;
11151
+ });
11152
+ sb.slices = slicesSend;
11153
+ slicesSend = null;
11154
+ sb.types = types = value[1];
11155
+ sb.updateCache();
11156
+ }
11157
+ });
11158
+
11159
+ zim.loop(20, function(i) {
11160
+ Object.defineProperty(that, 'sH'+i, {
11161
+ get: function() {
11162
+ return slices[0][i];
11163
+ },
11164
+ set: function(value) {
11165
+ slices[0][i] = value;
11166
+ that.slices = slices;
11167
+ }
11168
+ });
11169
+ });
11170
+
11171
+ zim.loop(20, function(i) {
11172
+ Object.defineProperty(that, 'sV'+i, {
11173
+ get: function() {
11174
+ return slices[1][i];
11175
+ },
11176
+ set: function(value) {
11177
+ slices[1][i] = value;
11178
+ that.slices = slices;
11179
+ }
11180
+ });
11181
+ });
11182
+
11183
+ zim.loop(20, function(i) {
11184
+ Object.defineProperty(that, 'tH'+i, {
11185
+ get: function() {
11186
+ return types[0][i];
11187
+ },
11188
+ set: function(value) {
11189
+ types[0][i] = value;
11190
+ that.types = types;
11191
+ }
11192
+ });
11193
+ });
11194
+
11195
+ zim.loop(20, function(i) {
11196
+ Object.defineProperty(that, 'tV'+i, {
11197
+ get: function() {
11198
+ return types[1][i];
11199
+ },
11200
+ set: function(value) {
11201
+ types[1][i] = value;
11202
+ that.types = types;
11203
+ }
11204
+ });
11205
+ });
11206
+
11207
+ }
11208
+ zim.extend(zim.SlicedBitmap, zim.Bitmap, null, "zimBitmap", false);
11209
+ //-50.75
11210
+
10789
11211
  /*--
10790
11212
  zim.Sprite = function(image, cols, rows, count, offsetX, offsetY, spacingX, spacingY, width, height, animations, json, id, globalControl, spriteSheet, label, frame, style, group, inherit)
10791
11213
 
@@ -11516,6 +11938,7 @@ animationend, change, added, click, dblclick, mousedown, mouseout, mouseover, pr
11516
11938
  this.setBounds = function(a,b,c,d) {
11517
11939
  var n = normalizeBounds(a, b, c, d);
11518
11940
  that.cjsSprite_setBounds(n[0],n[1],n[2],n[3]);
11941
+ that.width;
11519
11942
  return that;
11520
11943
  };
11521
11944
  this.getBounds = function(targetSpace) {
@@ -11703,6 +12126,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
11703
12126
  this.setBounds = function(a,b,c,d) {
11704
12127
  var n = normalizeBounds(a, b, c, d);
11705
12128
  that.cjsMovieClip_setBounds(n[0],n[1],n[2],n[3]);
12129
+ that.width;
11706
12130
  return that;
11707
12131
  };
11708
12132
  this.getBounds = function(targetSpace) {
@@ -23083,8 +23507,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
23083
23507
 
23084
23508
  PROPERTIES
23085
23509
  type - the name of the class as a String
23086
- text - get the text of the original Label
23087
- See: https://zimjs.com/zapp/Z_VSR9X for updating text
23510
+ text - get or set the text
23088
23511
  labels - an array of ZIM Label objects for the letters
23089
23512
  numLetters - how many letters (same as numChildren)
23090
23513
 
@@ -23126,391 +23549,449 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
23126
23549
  this.type = "LabelLetters";
23127
23550
 
23128
23551
  var that = this;
23129
- var letterData = that.letterData = [];
23130
- var original, data;
23131
- if (label.type != "Label") {
23132
- data = parseHTML(label); // returns {text:text, data:data}
23133
- letterData = data.data;
23134
- label = new zim.Label(data.text);
23135
- } else {
23136
- data = parseHTML(label.text);
23137
- letterData = data.data;
23138
- label.text = data.text;
23139
- }
23140
- that.text = data.original;
23141
- that._color = label.color;
23142
-
23143
- // handle DIR effect
23144
- if ((WW.DIR && WW.DIR=="rtl") || (!WW.DIR && zim.DIR=="rtl")) {
23145
- if (lineAlign=="start") lineAlign="right";
23146
- else if (lineAlign=="end") lineAlign="left";
23147
- } else {
23148
- if (lineAlign=="start") lineAlign="left";
23149
- else if (lineAlign=="end") lineAlign="right";
23150
- }
23151
-
23152
- function parseHTML(html) {
23153
- var data = [];
23154
-
23155
- // var example = "LabelLetters()<br><br><font group=heading backgroundColor=yellow rollBackgroundColor=green><a href=https://zimjs.com target=_blank>Example</a></font>: <b>strong</b> <i>emphasis</i> <u>underline</u><br><font color=red size=50 family=verdana><strong>big</strong> red verdana</font><br>the next line"
23156
- // "LabelLetters()Example: strong emphasis underlinebig red verdanathe next line"
23157
- // "01234567890123456789012345678901234567890123456789012345678901234567890120123456789012"
23158
- // "0 1 2 3 4 5 6 7"
23159
- // html = "!Roger הגיע בשבילך משהו בדואר Dan אני לומד עברית";
23160
- // html = "הגיע בשבילך משהו בדואר.";
23161
-
23162
- function insert(data) {
23163
- return data.split("").reverse().join("")
23164
- }
23165
- if (rtl) {
23166
- count = -1;
23167
- html = html.replace(/[\u0591-\u07FF]+/ig, insert);
23168
-
23169
- // and there may be tags or LTR characters next to RTL without a space:
23170
- html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
23171
- html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space
23172
- html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
23173
- html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
23174
-
23175
- var sp = html.split(/-!!-/g);
23176
- zim.loop(sp, function(ssp, i){
23177
- if (ssp.match(/[\u0591-\u07FF]/i)) {
23178
- sp[i] = ssp.split(" ").reverse().join(" ");
23179
- }
23180
- });
23181
- html = sp.join("");
23182
- }
23183
-
23184
23552
 
23185
- // normalize tags
23186
- html = html.replace(/\n|\r/g,"<br>");
23187
- html = html.replace(/<strong>|<strong \/>|<strong\/>/gi,"<b>");
23188
- html = html.replace(/<\/strong>/gi,"</b>");
23189
- html = html.replace(/<em>|<em \/>|<em\/>/gi,"<i>");
23190
- html = html.replace(/<\/em>/gi,"</i>");
23191
- html = html.replace(/\\n|\\r/g,"<br>");
23192
- html = html.replace(/<br>|<br \/>|<br\/>(<\/br>)?/gi,"<br>");
23193
- html = html.replace(/<b/gi,"<b");
23194
- html = html.replace(/<i/gi,"<i");
23195
- html = html.replace(/<u/gi,"<u");
23196
- html = html.replace(/<br/gi,"<br");
23197
- html = html.replace(/<a/gi,"<a");
23198
- html = html.replace(/<font/gi,"<font");
23199
-
23200
- // turn all other tags into "" do split on tag and count index for tag
23201
- // process this and store in data so get index of tags in string with no tags counted
23202
-
23203
- var regs = [
23204
- /<(a|i|u|f|br|\/a|\/i|\/u|\/f|\/b)[^>]*>/g,
23205
- /<(a|i|u|f|br|\/a|\/i|\/u|\/f|b)[^>]*>/g,
23206
- /<(b|i|u|f|br|\/b|\/i|\/u|\/f|\/a)[^>]*>/g,
23207
- /<(b|i|u|f|br|\/b|\/i|\/u|\/f|a)[^>]*>/g,
23208
- /<(b|a|u|f|br|\/b|\/a|\/u|\/f|\/i)[^>]*>/g,
23209
- /<(b|a|u|f|br|\/b|\/a|\/u|\/f|i)[^>]*>/g,
23210
- /<(b|a|i|f|br|\/b|\/a|\/i|\/f|\/u)[^>]*>/g,
23211
- /<(b|a|i|f|br|\/b|\/a|\/i|\/f|u)[^>]*>/g,
23212
- /<(b|a|i|u|br|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,
23213
- /<(b|a|i|u|br|\/b|\/a|\/i|\/u|f)[^>]*>/g
23214
- ];
23215
- var types = ["b","a","i","u","font"];
23216
- var p;
23217
- zim.loop(types, function(type, i) {
23218
- p = html.replace(regs[i*2],"");
23219
- var arr;
23220
- if (type=="font") {
23221
- arr = p.split("<font ");
23222
- } else if (type=="a") {
23223
- arr = p.split("<a ");
23224
- } else {
23225
- arr = p.split("<"+type+">");
23226
- }
23227
- process(arr, type, 0); // 0 for add
23228
-
23229
- p = html.replace(regs[i*2+1],"");
23230
- arr = p.split("</"+type+">");
23231
- process(arr, type, 1); // 1 for remove
23232
- });
23233
-
23553
+ function make() {
23554
+
23555
+ that.disposeAllChildren();
23556
+
23557
+ var letterData = that.letterData = [];
23558
+ var original, data;
23559
+ if (label.type != "Label") {
23560
+ data = parseHTML(label); // returns {text:text, data:data}
23561
+ letterData = data.data;
23562
+ label = new zim.Label(data.text);
23563
+ } else {
23564
+ data = parseHTML(label.text);
23565
+ letterData = data.data;
23566
+ label.text = data.text;
23567
+ }
23568
+ that._text = data.original;
23569
+ that._color = label.color;
23234
23570
 
23235
- p = html.replace(/<br>/gi,"@^#");
23236
- p = p.replace(/<(b|a|i|u|f|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,"");
23237
- var arr = p.split("@^#");
23238
- original = arr.join("\n");
23239
- p = arr.join("");
23240
- process(arr, "br", 0); // 0 for add
23571
+ // handle DIR effect
23572
+ if ((WW.DIR && WW.DIR=="rtl") || (!WW.DIR && zim.DIR=="rtl")) {
23573
+ if (lineAlign=="start") lineAlign="right";
23574
+ else if (lineAlign=="end") lineAlign="left";
23575
+ } else {
23576
+ if (lineAlign=="start") lineAlign="left";
23577
+ else if (lineAlign=="end") lineAlign="right";
23578
+ }
23241
23579
 
23242
- function process(text, type, action) {
23243
- if (text.length > 1) {
23244
- if ((type=="font" || type=="a") && action==0) {
23245
- var length = text[0].length;
23246
- zim.loop(text, function(s, i) {
23247
-
23248
- if (i==0) return;
23249
- var d = data[length];
23250
- if (!d) data[length] = [];
23251
- d = data[length] ;
23252
-
23253
- var arr = s.split(">");
23580
+ function parseHTML(html) {
23581
+ var data = [];
23254
23582
 
23255
- if (d[action]) d[action].push(type + " " + arr[0]);
23256
- else d[action] = [type + " " + arr[0]];
23583
+ // var example = "LabelLetters()<br><br><font group=heading backgroundColor=yellow rollBackgroundColor=green><a href=https://zimjs.com target=_blank>Example</a></font>: <b>strong</b> <i>emphasis</i> <u>underline</u><br><font color=red size=50 family=verdana><strong>big</strong> red verdana</font><br>the next line"
23584
+ // "LabelLetters()Example: strong emphasis underlinebig red verdanathe next line"
23585
+ // "01234567890123456789012345678901234567890123456789012345678901234567890120123456789012"
23586
+ // "0 1 2 3 4 5 6 7"
23587
+ // html = "!Roger הגיע בשבילך משהו בדואר Dan אני לומד עברית";
23588
+ // html = "הגיע בשבילך משהו בדואר.";
23257
23589
 
23258
- length += arr[1].length;
23259
- });
23260
- } else {
23261
- text.pop();
23262
- var running = 0;
23263
- zim.loop(text, function(s) {
23264
- running += s.length;
23265
- var d = data[running];
23266
- if (!d) data[running] = [];
23267
- d = data[running];
23268
- if (d[action]) d[action].push(type);
23269
- else d[action] = [type];
23270
- });
23271
- }
23590
+ function insert(data) {
23591
+ return data.split("").reverse().join("")
23272
23592
  }
23273
- }
23274
-
23275
- // [[adds at index], [removes at index]]
23276
- // b,i,u,br,a,font
23277
- // var da = [,, [["b","i"]] ,[,["b"]],,,[["br","font color=red size=10 family=courier"]],["i"]],...];
23278
- return {text:p, data:data, original:original};
23279
- }
23280
-
23281
- that.numLetters = label.text.length;
23282
-
23283
- // NORMALIZE SPACINGS
23284
- var letterSpacingsOriginal = !zot(letterSpacings);
23285
- if (letterSpacings && !Array.isArray(letterSpacings)) letterSpacings = null;
23286
- var i;
23287
- if (!letterSpacings) {
23288
- letterSpacings = [];
23289
- for (i = 0; i < that.numLetters; i++) {
23290
- letterSpacings.push(letterSpacing);
23291
- }
23292
- } else {
23293
- for (i = 0; i < that.numLetters; i++) {
23294
- if (zot(letterSpacings[i])) letterSpacings[i] = letterSpacing;
23295
- }
23296
- }
23297
- that.letterSpacings = letterSpacings;
23298
-
23299
- if (lineSpacings && !Array.isArray(lineSpacings)) lineSpacings = null;
23300
- if (!lineSpacings) {
23301
- lineSpacings = [];
23302
- for (i = 0; i < that.numLetters - 1; i++) {
23303
- lineSpacings.push(lineSpacing);
23304
- }
23305
- } else {
23306
- for (i = 0; i < that.numLetters - 1; i++) {
23307
- if (zot(lineSpacings[i])) lineSpacings[i] = lineSpacing;
23308
- }
23309
- }
23310
- that.lineSpacings = lineSpacings;
23311
-
23312
- // LINE CONTROL
23313
- that.labels = [];
23314
- that.lines = [[]];
23315
- var lineWidths = [];
23316
- var lineHeights = [];
23317
- var linePositionsY = [0];
23318
- var lineY = 0;
23319
- var lineW = 0;
23320
- var lineH = 0;
23321
- var lineNum = 0;
23322
- var maxW = 0;
23323
-
23324
- // HTML CONTROL
23325
- var d = letterData;
23326
- var bCheck = false;
23327
- var iCheck = false;
23328
- var uCheck = false;
23329
- var brCheck = false;
23330
- var colorCheck = false;
23331
- var sizeCheck = false;
23332
- var groupCheck = false;
23333
- var familyCheck = false;
23334
- var urlCheck = false;
23335
- var targetCheck = false;
23336
- var backgroundColorCheck = false;
23337
- var rollBackgroundColorCheck = false;
23338
-
23339
- // ROLLOVER CONTROL
23340
- that.rolls = [[]];
23341
-
23342
- for (i=0; i<that.numLetters; i++) {
23343
-
23344
- // PARSE TAG CHECKS
23593
+ if (rtl) {
23594
+ count = -1;
23595
+ html = html.replace(/[\u0591-\u07FF]+/ig, insert);
23596
+
23597
+ // and there may be tags or LTR characters next to RTL without a space:
23598
+ html = html.replace(/([^\u0591-\u07FF ])([\u0591-\u07FF])/ig, "$1-!!-$2"); // note the not space
23599
+ html = html.replace(/([\u0591-\u07FF])([^\u0591-\u07FF ])/ig, "$1-!!-$2"); // note the not space
23600
+ html = html.replace(/([^\u0591-\u07FF]) ([\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
23601
+ html = html.replace(/([\u0591-\u07FF]) ([^\u0591-\u07FF])/ig, "$1-!!- -!!-$2");
23602
+
23603
+ var sp = html.split(/-!!-/g);
23604
+ zim.loop(sp, function(ssp, i){
23605
+ if (ssp.match(/[\u0591-\u07FF]/i)) {
23606
+ sp[i] = ssp.split(" ").reverse().join(" ");
23607
+ }
23608
+ });
23609
+ html = sp.join("");
23610
+ }
23611
+
23612
+
23613
+ // normalize tags
23614
+ html = html.replace(/\n|\r/g,"<br>");
23615
+ html = html.replace(/<strong>|<strong \/>|<strong\/>/gi,"<b>");
23616
+ html = html.replace(/<\/strong>/gi,"</b>");
23617
+ html = html.replace(/<em>|<em \/>|<em\/>/gi,"<i>");
23618
+ html = html.replace(/<\/em>/gi,"</i>");
23619
+ html = html.replace(/\\n|\\r/g,"<br>");
23620
+ html = html.replace(/<br>|<br \/>|<br\/>(<\/br>)?/gi,"<br>");
23621
+ html = html.replace(/<b/gi,"<b");
23622
+ html = html.replace(/<i/gi,"<i");
23623
+ html = html.replace(/<u/gi,"<u");
23624
+ html = html.replace(/<br/gi,"<br");
23625
+ html = html.replace(/<a/gi,"<a");
23626
+ html = html.replace(/<font/gi,"<font");
23627
+
23628
+ // turn all other tags into "" do split on tag and count index for tag
23629
+ // process this and store in data so get index of tags in string with no tags counted
23630
+
23631
+ var regs = [
23632
+ /<(a|i|u|f|br|\/a|\/i|\/u|\/f|\/b)[^>]*>/g,
23633
+ /<(a|i|u|f|br|\/a|\/i|\/u|\/f|b)[^>]*>/g,
23634
+ /<(b|i|u|f|br|\/b|\/i|\/u|\/f|\/a)[^>]*>/g,
23635
+ /<(b|i|u|f|br|\/b|\/i|\/u|\/f|a)[^>]*>/g,
23636
+ /<(b|a|u|f|br|\/b|\/a|\/u|\/f|\/i)[^>]*>/g,
23637
+ /<(b|a|u|f|br|\/b|\/a|\/u|\/f|i)[^>]*>/g,
23638
+ /<(b|a|i|f|br|\/b|\/a|\/i|\/f|\/u)[^>]*>/g,
23639
+ /<(b|a|i|f|br|\/b|\/a|\/i|\/f|u)[^>]*>/g,
23640
+ /<(b|a|i|u|br|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,
23641
+ /<(b|a|i|u|br|\/b|\/a|\/i|\/u|f)[^>]*>/g
23642
+ ];
23643
+ var types = ["b","a","i","u","font"];
23644
+ var p;
23645
+ zim.loop(types, function(type, i) {
23646
+ p = html.replace(regs[i*2],"");
23647
+ var arr;
23648
+ if (type=="font") {
23649
+ arr = p.split("<font ");
23650
+ } else if (type=="a") {
23651
+ arr = p.split("<a ");
23652
+ } else {
23653
+ arr = p.split("<"+type+">");
23654
+ }
23655
+ process(arr, type, 0); // 0 for add
23345
23656
 
23346
- brCheck = false;
23347
- if (d[i]) {
23657
+ p = html.replace(regs[i*2+1],"");
23658
+ arr = p.split("</"+type+">");
23659
+ process(arr, type, 1); // 1 for remove
23660
+ });
23661
+
23348
23662
 
23349
- // end tags - do ends first just in case tag ends at same letter it starts
23350
- if (d[i][1]) {
23351
- if (d[i][1].indexOf("b") >= 0) bCheck = false;
23352
- if (d[i][1].indexOf("i") >= 0) iCheck = false;
23353
- if (d[i][1].indexOf("u") >= 0) uCheck = false;
23354
- zim.loop(d[i][1], function (item) {
23355
- if (item.match(/^font/i)) {
23356
- colorCheck = false;
23357
- backgroundColorCheck = false;
23358
- if (rollBackgroundColorCheck) that.rolls.push([]);
23359
- rollBackgroundColorCheck = false;
23360
- sizeCheck = false;
23361
- familyCheck = false;
23362
- groupCheck = false;
23363
- return;
23364
- }
23365
- if (item.match(/^a/i)) {
23366
- urlCheck = false;
23367
- targetCheck = false;
23368
- return;
23663
+ p = html.replace(/<br>/gi,"@^#");
23664
+ p = p.replace(/<(b|a|i|u|f|\/b|\/a|\/i|\/u|\/f)[^>]*>/g,"");
23665
+ var arr = p.split("@^#");
23666
+ original = arr.join("\n");
23667
+ p = arr.join("");
23668
+ process(arr, "br", 0); // 0 for add
23669
+
23670
+ function process(text, type, action) {
23671
+ if (text.length > 1) {
23672
+ if ((type=="font" || type=="a") && action==0) {
23673
+ var length = text[0].length;
23674
+ zim.loop(text, function(s, i) {
23675
+
23676
+ if (i==0) return;
23677
+ var d = data[length];
23678
+ if (!d) data[length] = [];
23679
+ d = data[length] ;
23680
+
23681
+ var arr = s.split(">");
23682
+
23683
+ if (d[action]) d[action].push(type + " " + arr[0]);
23684
+ else d[action] = [type + " " + arr[0]];
23685
+
23686
+ length += arr[1].length;
23687
+ });
23688
+ } else {
23689
+ text.pop();
23690
+ var running = 0;
23691
+ zim.loop(text, function(s) {
23692
+ running += s.length;
23693
+ var d = data[running];
23694
+ if (!d) data[running] = [];
23695
+ d = data[running];
23696
+ if (d[action]) d[action].push(type);
23697
+ else d[action] = [type];
23698
+ });
23369
23699
  }
23370
- });
23371
- }
23700
+ }
23701
+ }
23372
23702
 
23373
- // start tags
23374
- if (d[i][0]) {
23375
- if (d[i][0].indexOf("b") >= 0) bCheck = true;
23376
- if (d[i][0].indexOf("i") >= 0) iCheck = true;
23377
- if (d[i][0].indexOf("u") >= 0) uCheck = true;
23378
- brCheck = 0;
23379
- zim.loop(d[i][0], function (item) {
23380
- if (item=="br") brCheck++;
23381
- });
23382
- zim.loop(d[i][0], function (item) {
23383
- var r, ind;
23384
- if (item.match(/^font/i)) {
23385
- r = item.match(/ color\s?=\s?(\S*)/i);
23386
- if (r) {
23387
- colorCheck = r[1];
23388
- ind = zim.colors.indexOf(colorCheck);
23389
- if (ind>=0) colorCheck = zim.colorsHex[ind];
23390
- colorCheck = colorCheck.replace(/'/g,"");
23391
- }
23392
- r = item.match(/size\s?=\s?(\S*)/i);
23393
- if (r) sizeCheck = r[1];
23394
- r = item.match(/backgroundColor\s?=\s?(\S*)/i);
23395
- if (r) {
23396
- backgroundColorCheck = r[1];
23397
- ind = zim.colors.indexOf(backgroundColorCheck);
23398
- if (ind>=0) backgroundColorCheck = zim.colorsHex[ind];
23399
- backgroundColorCheck = backgroundColorCheck.replace(/'/g,"");
23400
- }
23401
- r = item.match(/rollBackgroundColor\s?=\s?(\S*)/i);
23402
- if (r) {
23403
- rollBackgroundColorCheck = r[1];
23404
- ind = zim.colors.indexOf(rollBackgroundColorCheck);
23405
- if (ind>=0) rollBackgroundColorCheck = zim.colorsHex[ind];
23406
- rollBackgroundColorCheck = rollBackgroundColorCheck.replace(/'/g,"");
23407
- }
23408
- r = item.match(/group\s?=\s?(\S*)/i);
23409
- if (r) groupCheck = r[1];
23410
- r = item.match(/family\s?=\s?(.*)/i);
23411
- if (r) {
23412
- familyCheck = r[1];
23413
- familyCheck = familyCheck.split(/\ssize\s?=|\scolor\s?=|\sgroup\s?=/i)[0];
23414
- }
23415
- return;
23416
- }
23417
- if (item.match(/^a/i)) {
23418
- r = item.match(/href\s?=\s?(\S*)/i);
23419
- if (r) urlCheck = r[1];
23420
- r = item.match(/target\s?=\s?(\S*)/i);
23421
- if (r) targetCheck = r[1];
23422
- return;
23423
- }
23424
- });
23425
- } // end start tag
23426
-
23427
- } // end all tags
23703
+ // [[adds at index], [removes at index]]
23704
+ // b,i,u,br,a,font
23705
+ // var da = [,, [["b","i"]] ,[,["b"]],,,[["br","font color=red size=10 family=courier"]],["i"]],...];
23706
+ return {text:p, data:data, original:original};
23707
+ }
23708
+
23709
+ that.numLetters = label.text.length;
23428
23710
 
23429
- // HANDLE CHECKS AND STORE MAX SIZES
23430
- var letter;
23431
- if (groupCheck) {
23432
- letter = new zim.Label({text:label.text[i], group:groupCheck})
23711
+ // NORMALIZE SPACINGS
23712
+ var letterSpacingsOriginal = !zot(letterSpacings);
23713
+ if (letterSpacings && !Array.isArray(letterSpacings)) letterSpacings = null;
23714
+ var i;
23715
+ if (!letterSpacings) {
23716
+ letterSpacings = [];
23717
+ for (i = 0; i < that.numLetters; i++) {
23718
+ letterSpacings.push(letterSpacing);
23719
+ }
23433
23720
  } else {
23434
- letter = label.clone();
23435
- letter.text = label.text[i];
23721
+ for (i = 0; i < that.numLetters; i++) {
23722
+ if (zot(letterSpacings[i])) letterSpacings[i] = letterSpacing;
23723
+ }
23436
23724
  }
23437
- that.labels.push(letter);
23438
-
23439
- if (bCheck) letter.bold = true;
23440
- if (iCheck) letter.italic = true;
23441
- if (colorCheck) letter.color = colorCheck;
23442
- if (backgroundColorCheck) letter.backgroundColor = backgroundColorCheck;
23443
-
23444
- var s = letterSpacingsOriginal?letterSpacings[i]:zot(letter.backgroundColor)?letterSpacings[i]:-.5;
23445
-
23446
- if (rollBackgroundColorCheck) {
23447
- letter.rollIndex = that.rolls.length-1;
23448
- letter.zrbc = rollBackgroundColorCheck;
23449
- letter.zobc = letter.backgroundColor;
23450
- that.rolls[letter.rollIndex].push(letter);
23451
- letter.expand(0);
23452
- letter.on("mouseover", rollOn);
23453
- letter.on("mouseout", rollOff);
23725
+ that.letterSpacings = letterSpacings;
23726
+
23727
+ if (lineSpacings && !Array.isArray(lineSpacings)) lineSpacings = null;
23728
+ if (!lineSpacings) {
23729
+ lineSpacings = [];
23730
+ for (i = 0; i < that.numLetters - 1; i++) {
23731
+ lineSpacings.push(lineSpacing);
23732
+ }
23733
+ } else {
23734
+ for (i = 0; i < that.numLetters - 1; i++) {
23735
+ if (zot(lineSpacings[i])) lineSpacings[i] = lineSpacing;
23736
+ }
23454
23737
  }
23738
+ that.lineSpacings = lineSpacings;
23455
23739
 
23456
- if (urlCheck) {
23457
- letter.expand(s,0);
23458
- letter.zurl = urlCheck;
23459
- letter.ztar = targetCheck;
23460
- letter.cur();
23461
- letter.on("click", function (e) {
23462
- var letter = e.currentTarget;
23463
- rollOff(e);
23464
- if (!letter.ztar) letter.ztar = "_self";
23465
- zgo(letter.zurl, letter.ztar);
23466
- });
23467
- }
23468
- if (familyCheck) letter.font = familyCheck;
23469
- if (sizeCheck) letter.size = sizeCheck;
23740
+ // LINE CONTROL
23741
+ that.labels = [];
23742
+ that.lines = [[]];
23743
+ var lineWidths = [];
23744
+ var lineHeights = [];
23745
+ var linePositionsY = [0];
23746
+ var lineY = 0;
23747
+ var lineW = 0;
23748
+ var lineH = 0;
23749
+ var lineNum = 0;
23750
+ var maxW = 0;
23470
23751
 
23752
+ // HTML CONTROL
23753
+ var d = letterData;
23754
+ var bCheck = false;
23755
+ var iCheck = false;
23756
+ var uCheck = false;
23757
+ var brCheck = false;
23758
+ var colorCheck = false;
23759
+ var sizeCheck = false;
23760
+ var groupCheck = false;
23761
+ var familyCheck = false;
23762
+ var urlCheck = false;
23763
+ var targetCheck = false;
23764
+ var backgroundColorCheck = false;
23765
+ var rollBackgroundColorCheck = false;
23471
23766
 
23472
- if (brCheck) {
23473
- lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
23474
- linePositionsY.push(lineY);
23475
- lineHeights.push(zot(lineHeight)?lineH:lineHeight);
23476
- lineWidths.push(lineW);
23477
- maxW = Math.max(maxW, lineW);
23478
- }
23767
+ // ROLLOVER CONTROL
23768
+ that.rolls = [[]];
23479
23769
 
23480
- if (brCheck) {
23481
- if (brCheck > 1) {
23482
- zim.loop(brCheck-1, function () {
23483
- that.lines.push([]);
23484
- lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
23485
- linePositionsY.push(lineY);
23486
- lineHeights.push(zot(lineHeight)?lineH:lineHeight);
23487
- lineWidths.push(0);
23488
- lineNum++;
23489
- });
23770
+ for (i=0; i<that.numLetters; i++) {
23771
+
23772
+ // PARSE TAG CHECKS
23773
+
23774
+ brCheck = false;
23775
+ if (d[i]) {
23776
+
23777
+ // end tags - do ends first just in case tag ends at same letter it starts
23778
+ if (d[i][1]) {
23779
+ if (d[i][1].indexOf("b") >= 0) bCheck = false;
23780
+ if (d[i][1].indexOf("i") >= 0) iCheck = false;
23781
+ if (d[i][1].indexOf("u") >= 0) uCheck = false;
23782
+ zim.loop(d[i][1], function (item) {
23783
+ if (item.match(/^font/i)) {
23784
+ colorCheck = false;
23785
+ backgroundColorCheck = false;
23786
+ if (rollBackgroundColorCheck) that.rolls.push([]);
23787
+ rollBackgroundColorCheck = false;
23788
+ sizeCheck = false;
23789
+ familyCheck = false;
23790
+ groupCheck = false;
23791
+ return;
23792
+ }
23793
+ if (item.match(/^a/i)) {
23794
+ urlCheck = false;
23795
+ targetCheck = false;
23796
+ return;
23797
+ }
23798
+ });
23799
+ }
23800
+
23801
+ // start tags
23802
+ if (d[i][0]) {
23803
+ if (d[i][0].indexOf("b") >= 0) bCheck = true;
23804
+ if (d[i][0].indexOf("i") >= 0) iCheck = true;
23805
+ if (d[i][0].indexOf("u") >= 0) uCheck = true;
23806
+ brCheck = 0;
23807
+ zim.loop(d[i][0], function (item) {
23808
+ if (item=="br") brCheck++;
23809
+ });
23810
+ zim.loop(d[i][0], function (item) {
23811
+ var r, ind;
23812
+ if (item.match(/^font/i)) {
23813
+ r = item.match(/ color\s?=\s?(\S*)/i);
23814
+ if (r) {
23815
+ colorCheck = r[1];
23816
+ ind = zim.colors.indexOf(colorCheck);
23817
+ if (ind>=0) colorCheck = zim.colorsHex[ind];
23818
+ colorCheck = colorCheck.replace(/'/g,"");
23819
+ }
23820
+ r = item.match(/size\s?=\s?(\S*)/i);
23821
+ if (r) sizeCheck = r[1];
23822
+ r = item.match(/backgroundColor\s?=\s?(\S*)/i);
23823
+ if (r) {
23824
+ backgroundColorCheck = r[1];
23825
+ ind = zim.colors.indexOf(backgroundColorCheck);
23826
+ if (ind>=0) backgroundColorCheck = zim.colorsHex[ind];
23827
+ backgroundColorCheck = backgroundColorCheck.replace(/'/g,"");
23828
+ }
23829
+ r = item.match(/rollBackgroundColor\s?=\s?(\S*)/i);
23830
+ if (r) {
23831
+ rollBackgroundColorCheck = r[1];
23832
+ ind = zim.colors.indexOf(rollBackgroundColorCheck);
23833
+ if (ind>=0) rollBackgroundColorCheck = zim.colorsHex[ind];
23834
+ rollBackgroundColorCheck = rollBackgroundColorCheck.replace(/'/g,"");
23835
+ }
23836
+ r = item.match(/group\s?=\s?(\S*)/i);
23837
+ if (r) groupCheck = r[1];
23838
+ r = item.match(/family\s?=\s?(.*)/i);
23839
+ if (r) {
23840
+ familyCheck = r[1];
23841
+ familyCheck = familyCheck.split(/\ssize\s?=|\scolor\s?=|\sgroup\s?=/i)[0];
23842
+ }
23843
+ return;
23844
+ }
23845
+ if (item.match(/^a/i)) {
23846
+ r = item.match(/href\s?=\s?(\S*)/i);
23847
+ if (r) urlCheck = r[1];
23848
+ r = item.match(/target\s?=\s?(\S*)/i);
23849
+ if (r) targetCheck = r[1];
23850
+ return;
23851
+ }
23852
+ });
23853
+ } // end start tag
23854
+
23855
+ } // end all tags
23856
+
23857
+ // HANDLE CHECKS AND STORE MAX SIZES
23858
+ var letter;
23859
+ if (groupCheck) {
23860
+ letter = new zim.Label({text:label.text[i], group:groupCheck})
23861
+ } else {
23862
+ letter = label.clone();
23863
+ letter.text = label.text[i];
23864
+ }
23865
+ that.labels.push(letter);
23866
+
23867
+ if (bCheck) letter.bold = true;
23868
+ if (iCheck) letter.italic = true;
23869
+ if (colorCheck) letter.color = colorCheck;
23870
+ if (backgroundColorCheck) letter.backgroundColor = backgroundColorCheck;
23871
+
23872
+ var s = letterSpacingsOriginal?letterSpacings[i]:zot(letter.backgroundColor)?letterSpacings[i]:-.5;
23873
+
23874
+ if (rollBackgroundColorCheck) {
23875
+ letter.rollIndex = that.rolls.length-1;
23876
+ letter.zrbc = rollBackgroundColorCheck;
23877
+ letter.zobc = letter.backgroundColor;
23878
+ that.rolls[letter.rollIndex].push(letter);
23879
+ letter.expand(0);
23880
+ letter.on("mouseover", rollOn);
23881
+ letter.on("mouseout", rollOff);
23882
+ }
23883
+
23884
+ if (urlCheck) {
23885
+ letter.expand(s,0);
23886
+ letter.zurl = urlCheck;
23887
+ letter.ztar = targetCheck;
23888
+ letter.cur();
23889
+ letter.on("click", function (e) {
23890
+ var letter = e.currentTarget;
23891
+ rollOff(e);
23892
+ if (!letter.ztar) letter.ztar = "_self";
23893
+ zgo(letter.zurl, letter.ztar);
23894
+ });
23895
+ }
23896
+ if (familyCheck) letter.font = familyCheck;
23897
+ if (sizeCheck) letter.size = sizeCheck;
23898
+
23899
+
23900
+ if (brCheck) {
23901
+ lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
23902
+ linePositionsY.push(lineY);
23903
+ lineHeights.push(zot(lineHeight)?lineH:lineHeight);
23904
+ lineWidths.push(lineW);
23905
+ maxW = Math.max(maxW, lineW);
23906
+ }
23907
+
23908
+ if (brCheck) {
23909
+ if (brCheck > 1) {
23910
+ zim.loop(brCheck-1, function () {
23911
+ that.lines.push([]);
23912
+ lineY += (zot(lineHeight)?lineH:lineHeight) + lineSpacings[lineNum];
23913
+ linePositionsY.push(lineY);
23914
+ lineHeights.push(zot(lineHeight)?lineH:lineHeight);
23915
+ lineWidths.push(0);
23916
+ lineNum++;
23917
+ });
23918
+ }
23919
+ lineH = 0;
23920
+ lineW = 0;
23921
+ that.lines.push([]);
23922
+ lineNum++;
23490
23923
  }
23491
- lineH = 0;
23492
- lineW = 0;
23493
- that.lines.push([]);
23494
- lineNum++;
23495
- }
23496
-
23497
- lineW += letter.width + s;
23498
- lineH = Math.max(lineH, letter.height);
23924
+
23925
+ lineW += letter.width + s;
23926
+ lineH = Math.max(lineH, letter.height);
23927
+
23928
+ if (i==that.numLetters-1) {
23929
+ lineWidths.push(lineW);
23930
+ lineHeights.push(lineH);
23931
+ maxW = Math.max(maxW, lineW);
23932
+ }
23933
+
23934
+ that.lines[lineNum].push(letter);
23935
+
23936
+ if (uCheck) letter.underline = new zim.Line(letter.width+s+1,1,letter.color).center(letter,that).mov(0,letter.height/2);
23937
+
23938
+ } // end checks
23499
23939
 
23500
- if (i==that.numLetters-1) {
23501
- lineWidths.push(lineW);
23502
- lineHeights.push(lineH);
23503
- maxW = Math.max(maxW, lineW);
23504
- }
23940
+
23505
23941
 
23506
- that.lines[lineNum].push(letter);
23507
23942
 
23508
- if (uCheck) letter.underline = new zim.Line(letter.width+s+1,1,letter.color).center(letter,this).mov(0,letter.height/2);
23943
+ // LOOP THROUGH LINES AND APPLY POSITIONS
23944
+ var count = 0;
23945
+ for (var j=0; j<that.lines.length; j++) {
23946
+ var ll = that.lines[j];
23947
+ lineW = lineWidths[j];
23948
+ lineH = lineHeights[j];
23949
+ lineY = linePositionsY[j];
23950
+
23951
+ var startX, startY;
23952
+ if (lineAlign=="left") startX = 0;
23953
+ else if (lineAlign=="right") startX = maxW-lineW;
23954
+ else startX = (maxW-lineW)/2;
23955
+ startY = lineY;
23956
+
23957
+ for (i=0; i<ll.length; i++) {
23958
+ count++;
23959
+ if (cache) letter.cache();
23960
+ letter = ll[i];
23961
+ letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
23962
+ letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
23509
23963
 
23510
- } // end checks
23511
-
23964
+ var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
23965
+ if (lineValign=="center" || lineValign=="middle") {
23966
+ sY += (lineHeights[j]-letter.height)/2;
23967
+ } else if (lineValign=="bottom") {
23968
+ sY += lineHeights[j]-letter.height;
23969
+ }
23970
+ s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
23971
+ if (align=="left") {
23972
+ letter.loc(startX, sY, that);
23973
+ startX = letter.x+letter.width+s;
23974
+ } else if (align=="right") {
23975
+ letter.loc(startX+letter.width, sY, that);
23976
+ startX = letter.x+s;
23977
+ } else {
23978
+ letter.loc(startX+letter.width/2, sY, that);
23979
+ startX = letter.x+letter.width/2+s;
23980
+ }
23981
+
23982
+ } // end lines letters
23983
+ } // end lines
23984
+
23985
+ if (!that.getBounds()) that.setBounds(0,0,0,0);
23986
+ that.regX = that.getBounds().x;
23987
+ that.regY = that.getBounds().y;
23988
+
23989
+ }
23990
+
23991
+ make();
23992
+
23512
23993
  // ROLL FUNCTIONS
23513
-
23994
+
23514
23995
  function rollOn(e) {
23515
23996
  var letter = e.currentTarget;
23516
23997
  var rolls = that.rolls[letter.rollIndex]
@@ -23527,58 +24008,22 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
23527
24008
  });
23528
24009
  if (letter.stage) letter.stage.update();
23529
24010
  }
23530
-
23531
-
23532
- // LOOP THROUGH LINES AND APPLY POSITIONS
23533
- var count = 0;
23534
- for (var j=0; j<that.lines.length; j++) {
23535
- var ll = that.lines[j];
23536
- lineW = lineWidths[j];
23537
- lineH = lineHeights[j];
23538
- lineY = linePositionsY[j];
23539
-
23540
- var startX, startY;
23541
- if (lineAlign=="left") startX = 0;
23542
- else if (lineAlign=="right") startX = maxW-lineW;
23543
- else startX = (maxW-lineW)/2;
23544
- startY = lineY;
23545
-
23546
- for (i=0; i<ll.length; i++) {
23547
- count++;
23548
- if (cache) letter.cache();
23549
- letter = ll[i];
23550
- letter.regX = align=="left"?0:(align=="right"?letter.width:letter.width/2);
23551
- letter.regY = valign=="top"?0:(valign=="bottom"?letter.height:letter.height/2);
23552
-
23553
- var sY = startY+(valign=="top"?0:valign=="bottom"?letter.height:letter.height/2);
23554
- if (lineValign=="center" || lineValign=="middle") {
23555
- sY += (lineHeights[j]-letter.height)/2;
23556
- } else if (lineValign=="bottom") {
23557
- sY += lineHeights[j]-letter.height;
23558
- }
23559
- s = letterSpacingsOriginal?letterSpacings[count-1]:zot(letter.backgroundColor)?letterSpacings[count-1]:-.5;
23560
- if (align=="left") {
23561
- letter.loc(startX, sY, this);
23562
- startX = letter.x+letter.width+s;
23563
- } else if (align=="right") {
23564
- letter.loc(startX+letter.width, sY, this);
23565
- startX = letter.x+s;
23566
- } else {
23567
- letter.loc(startX+letter.width/2, sY, this);
23568
- startX = letter.x+letter.width/2+s;
23569
- }
23570
-
23571
- } // end lines letters
23572
- } // end lines
23573
24011
 
23574
- if (!this.getBounds()) this.setBounds(0,0,0,0);
23575
- this.regX = this.getBounds().x;
23576
- this.regY = this.getBounds().y;
23577
24012
 
23578
24013
  this.setProps = function(props) {
23579
24014
  zim.setProps(this.labels, props);
23580
24015
  return this;
23581
24016
  }
24017
+
24018
+ Object.defineProperty(this, 'text', {
24019
+ get: function () {
24020
+ return this._text;
24021
+ },
24022
+ set: function (value) {
24023
+ label = value;
24024
+ make();
24025
+ }
24026
+ });
23582
24027
 
23583
24028
  Object.defineProperty(this, 'color', {
23584
24029
  get: function () {
@@ -23738,7 +24183,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
23738
24183
 
23739
24184
  PROPERTIES
23740
24185
  type - the name of the class as a String
23741
- text - get the text of the original Label
24186
+ text - get or set the text
23742
24187
  labels - an array of ZIM Label objects for the letters
23743
24188
  numWords - how many words in labels (same as numChildren)
23744
24189
 
@@ -23778,28 +24223,42 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
23778
24223
  if (zot(spacingH)) spacingH = DS.spacingH != null ? DS.spacingH : size/2;
23779
24224
  if (zot(spacingV)) spacingV = DS.spacingV != null ? DS.spacingV : size/2;
23780
24225
 
23781
- var sentence;
23782
- if (label.type == "Label") sentence = label.text;
23783
- else sentence = label;
24226
+ var that = this;
23784
24227
 
23785
- var that = this;
23786
- that.text = sentence;
23787
- var words = sentence.split(' ').filter(Boolean);
23788
- var labels = that.labels = [];
23789
- zim.loop(words, function(word) {
23790
- var lab = label.type=="Label"?label.clone():new zim.Label();
23791
- lab.text = word;
23792
- lab.size = zik(size);
23793
- lab.font = zik(font);
23794
- lab.color = zik(color);
23795
- if (!zot(backgroundColor)) lab.backgroundColor = zik(backgroundColor);
23796
- lab.reg(zik(itemRegX), zik(itemRegY));
23797
- if (itemCache) lab.cache();
23798
- labels.push(lab);
23799
- });
24228
+ function make(label) {
24229
+ var sentence;
24230
+ if (label.type == "Label") sentence = label.text;
24231
+ else sentence = label;
24232
+ that._text = sentence;
24233
+ var words = sentence.split(' ').filter(Boolean);
24234
+ var labels = that.labels = [];
24235
+ zim.loop(words, function(word) {
24236
+ var lab = label.type=="Label"?label.clone():new zim.Label();
24237
+ lab.text = word;
24238
+ lab.size = zik(size);
24239
+ lab.font = zik(font);
24240
+ lab.color = zik(color);
24241
+ if (!zot(backgroundColor)) lab.backgroundColor = zik(backgroundColor);
24242
+ lab.reg(zik(itemRegX), zik(itemRegY));
24243
+ if (itemCache) lab.cache();
24244
+ labels.push(lab);
24245
+ });
24246
+ }
24247
+ make(label);
23800
24248
 
23801
- this.zimWrapper_constructor(labels, width, spacingH, spacingV, wrapperType, align, valign, alignInner, valignInner, flip, reverse, bottomFull, colSize, rowSize, height, minSpreadNum, minStretchNum, percentVoidH, offsetVoidH, percentVoidV, offsetVoidV, minStretchFirst, style, group, inherit);
24249
+ this.zimWrapper_constructor(that.labels, width, spacingH, spacingV, wrapperType, align, valign, alignInner, valignInner, flip, reverse, bottomFull, colSize, rowSize, height, minSpreadNum, minStretchNum, percentVoidH, offsetVoidH, percentVoidV, offsetVoidV, minStretchFirst, style, group, inherit);
23802
24250
 
24251
+ Object.defineProperty(this, 'text', {
24252
+ get: function () {
24253
+ return this._text;
24254
+ },
24255
+ set: function (label) {
24256
+ that.remove();
24257
+ make(label);
24258
+ that.add(that.labels);
24259
+ }
24260
+ });
24261
+
23803
24262
  if (style!==false) zim.styleTransforms(this, DS);
23804
24263
  this.clone = function () {
23805
24264
  return that.cloneProps(new zim.LabelWords(label, width, size, font, color, backgroundColor, itemCache, itemRegX, itemRegY, spacingH, spacingV, wrapperType, align, valign, alignInner, valignInner, flip, reverse, bottomFull, colSize, rowSize, height, minSpreadNum, minStretchNum, percentVoidH, offsetVoidH, percentVoidV, offsetVoidV, minStretchFirst, style, this.group, inherit));
@@ -24757,13 +25216,13 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
24757
25216
  if (that.rolled) return;
24758
25217
  });
24759
25218
 
24760
- this.on("pressup", function () {
25219
+ this.on("pressup", function (e) {
24761
25220
  that.pressed = onCheck = pressCheck = false;
24762
-
25221
+
24763
25222
  if (reallyOn) buttonOn(); // will recall the roll ZIM01
24764
25223
  else if (that.rollPersist) removeRoll();
24765
25224
 
24766
- if (WW.M) { // touch screen
25225
+ if (e.nativeEvent && (e.nativeEvent.type == "touchend" || e.nativeEvent == "touchcancel")) { // touch screen
24767
25226
  buttonOff();
24768
25227
  }
24769
25228
  });
@@ -27190,6 +27649,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
27190
27649
  if (replace) that.contentContainer.removeAllChildren();
27191
27650
  if (center) obj.center(that.contentContainer, index);
27192
27651
  else obj.addTo(that.contentContainer, index);
27652
+ addHTML(that.contentContainer);
27193
27653
  return that;
27194
27654
  }
27195
27655
 
@@ -27334,7 +27794,6 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
27334
27794
  });
27335
27795
  }
27336
27796
 
27337
-
27338
27797
  this.on("removed", hide2);
27339
27798
  function hide2() {
27340
27799
  var ch,i;
@@ -27443,6 +27902,8 @@ NOTE: to add ZIM Swipe() to objects in window set the overrideNoSwipe parameter
27443
27902
  NOTE: if animating the window off screen then either turn optimize:false
27444
27903
  or use window.update() in the "animation" event with the animate({events:true})
27445
27904
 
27905
+ NOTE: if window content has items set to visible false then set optimize false to avoid conflict
27906
+
27446
27907
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
27447
27908
 
27448
27909
  EXAMPLE
@@ -27563,6 +28024,7 @@ optimize - (default true) set to false to not turn DisplayObjects visible false
27563
28024
  as the Window is scrolled, any objects within the content and any objects within one level of those objects
27564
28025
  are set to visible false if their bounds are not hitting the the window bounds + 300 - thanks Ami Hanya for the suggestion
27565
28026
  also see optimize property
28027
+ if window content has items set to visible false then set optimize false to avoid conflict
27566
28028
  resizeBoundary - (default null) add a ZIM Boundary() object for the resize handle - relative to the resize handle start position
27567
28029
  new Boundary(-100, 0, 200, 0) - would allow the resize handle to move to the left or right 100 pixels but not up or down
27568
28030
  new Boundary(0, -100, 0, 200) - would allow the resize handle to move to up or down 100 pixels but not left or right
@@ -27617,7 +28079,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
27617
28079
 
27618
28080
  PROPERTIES
27619
28081
  type - holds the class name as a String
27620
- backing - CreateJS Shape used for backing of Window
28082
+ backing - ZIM Shape used for backing of Window
27621
28083
  backgroundColor - the color of the backing
27622
28084
  borderColor - the color of the border
27623
28085
  borderWidth - the width of the border
@@ -27632,6 +28094,7 @@ content - gives access to the content provided as a parameter to the Window()
27632
28094
  buttons - an array of the Button objects if provided
27633
28095
  config - the original content config object {}
27634
28096
  optimize - see optimize parameter - set to true (default) or false to optimize scrolling of Window
28097
+ if window content has items set to visible false then set optimize false to avoid conflict
27635
28098
  enabled - get or set whether the Window is enabled
27636
28099
  scrollEnabled - get or set whether the Window can be scrolled
27637
28100
  scrollBar - data object that holds the following properties (with defaults):
@@ -27764,6 +28227,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
27764
28227
  var backing = this.backing = new zim.Shape({style:false});
27765
28228
  this.addChild(backing);
27766
28229
 
28230
+ var htmlList = new zim.Dictionary(true);
28231
+
27767
28232
  var mask = new createjs.Shape();
27768
28233
  mask.type = "WindowBacking";
27769
28234
  var mg = mask.graphics;
@@ -28163,7 +28628,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28163
28628
  titleBarRect.sha(null);
28164
28629
  if (resizeHandle) that.resizeHandle.visible = true;
28165
28630
  that.setBounds(ob.x, ob.y, ob.width, ob.height);
28166
- that.dispatchEvent("expand");
28631
+ show2();
28632
+ that.dispatchEvent("expand");
28167
28633
  } else {
28168
28634
  collapseIcon.rot(180);
28169
28635
  that.backing.visible = false;
@@ -28176,6 +28642,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28176
28642
  titleBarRect.sha(shadowColor, 5,5, shadowBlur);
28177
28643
  if (resizeHandle) that.resizeHandle.visible = false;
28178
28644
  that.setBounds(ob.x, ob.y, ob.width, titleBar.height);
28645
+ hide2();
28179
28646
  that.dispatchEvent("collapse");
28180
28647
  }
28181
28648
  if (that.stage) that.stage.update();
@@ -28202,6 +28669,34 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28202
28669
  that.collapse(true);
28203
28670
  }
28204
28671
  });
28672
+
28673
+ }
28674
+ }
28675
+ this.on("removed", hide2);
28676
+ function hide2() {
28677
+ var ch,i;
28678
+ var tar = that.content||that.contentContainer||that;
28679
+ if (tar.type != "Container") tar = that.contentContainer||that;
28680
+ for (i=0; i<tar.numChildren; i++) { // record depths first
28681
+ ch = tar.getChildAt(i);
28682
+ if (ch.type == "TextArea" || ch.type == "Loader" || ch.type == "Tag") {
28683
+ var obj = {obj:ch, depth:tar.getChildIndex(ch)};
28684
+ htmlList.add(ch, obj);
28685
+ }
28686
+ }
28687
+ for (i=tar.numChildren-1; i>=0; i--) { // remove textareas and loaders second
28688
+ ch = tar.getChildAt(i);
28689
+ if (ch.type == "TextArea" || ch.type == "Loader" || ch.type == "Tag") {
28690
+ tar.removeChild(ch);
28691
+ }
28692
+ }
28693
+ }
28694
+ this.on("added", show2);
28695
+ function show2() {
28696
+ var tar = that.content||that.contentContainer||that;
28697
+ if (tar.type != "Container") tar = that.contentContainer||that;
28698
+ for (var i=0; i<htmlList.length; i++) {
28699
+ tar.addChildAt(htmlList.values[i].obj, htmlList.values[i].depth);
28205
28700
  }
28206
28701
  }
28207
28702
 
@@ -28270,7 +28765,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28270
28765
  var duo; if (duo = zob(that.add, arguments, sig, that)) return duo;
28271
28766
 
28272
28767
  var c = obj;
28273
- if (!c.getBounds()) {zogy("Window.add() - please add content with bounds set"); return;}
28768
+ if (!c.getBounds()) {zogy("Window.add() - please add content with bounds set"); return;}
28274
28769
  makeDamp(c);
28275
28770
  if (zot(index)) index = content.numChildren;
28276
28771
  if (replace) {
@@ -28297,7 +28792,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28297
28792
  });
28298
28793
  }
28299
28794
  if (c.x == 0) c.x = paddingH;
28300
- if (c.y == 0) c.y = paddingV;
28795
+ if (c.y == 0) c.y = paddingV;
28301
28796
  that.update();
28302
28797
  return that;
28303
28798
  };
@@ -30737,7 +31232,7 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
30737
31232
  }
30738
31233
  align = handleDIR(align);
30739
31234
 
30740
- this.zimWindow_constructor(width, height, null, backgroundColor, borderColor, borderWidth, padding, corner, false, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, false, null, null, false, true, shadowColor, shadowBlur, paddingH, paddingV, true, null, null, null, null, null, false, null, null, null, null, null, null, null, null, null, null, null, null, style, group, zim.copy(DS));
31235
+ this.zimWindow_constructor(width, height, null, backgroundColor, borderColor, borderWidth, padding, corner, false, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, false, null, null, false, true, shadowColor, shadowBlur, paddingH, paddingV, true, null, null, null, null, null, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, style, group, zim.copy(DS));
30741
31236
  this.type = "TextInput";
30742
31237
  var that = this;
30743
31238
 
@@ -30813,7 +31308,16 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
30813
31308
  label.onDblclick(e);
30814
31309
  e.stopImmediatePropagation();
30815
31310
  });
30816
-
31311
+
31312
+
31313
+ function vvp() {
31314
+ if (M && !zot(lastHeight) && WW.visualViewport.height > lastHeight) {
31315
+ that.tiBlur();
31316
+ WW.visualViewport.removeEventListener('resize', vvp);
31317
+ }
31318
+ lastHeight = WW.visualViewport.height;
31319
+ }
31320
+ var lastHeight;
30817
31321
  that.label.on("focus", function () {
30818
31322
  if (WW.M && keyboardShift) {
30819
31323
  if (that.re) that.stage.frame.off("resize", that.re);
@@ -30823,6 +31327,10 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
30823
31327
  that.stage.update();
30824
31328
  }
30825
31329
  });
31330
+ if (WW.visualViewport) {
31331
+ WW.visualViewport.removeEventListener('resize', vvp);
31332
+ WW.visualViewport.addEventListener('resize', vvp);
31333
+ }
30826
31334
  var h = that.label.localToGlobal(0,0).y;
30827
31335
  if (that.stage && h>that.stage.height/4) {
30828
31336
  that.stage.y = that.stage.scaleY*(that.stage.height/4-h);
@@ -30836,10 +31344,11 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
30836
31344
  that.dispatchEvent("focus");
30837
31345
  });
30838
31346
 
30839
- that.label.on("blur", function () {
31347
+ that.tiBlur = function() {
30840
31348
  if (WW.M && keyboardShift) {
30841
31349
  if (that.stage) {
30842
31350
  if (that.re) that.stage.frame.off("resize", that.re);
31351
+ that.label.hiddenInput.blur();
30843
31352
  that.stage.y = sYO;
30844
31353
  that.stage.update();
30845
31354
  }
@@ -30849,7 +31358,8 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
30849
31358
  if (that.stage) that.stage.update();
30850
31359
  }
30851
31360
  that.dispatchEvent("blur");
30852
- });
31361
+ }
31362
+ that.label.on("blur", that.tiBlur);
30853
31363
 
30854
31364
  that.label.on("input", function (e) {
30855
31365
  doPlaceholder();
@@ -35879,6 +36389,988 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
35879
36389
  zim.extend(zim.Selector, zim.Container, ["clone","dispose"], "zimContainer", false);
35880
36390
  //-62.5
35881
36391
 
36392
+ /*--
36393
+ zim.Slicer = function(obj, objScale, slices, types, titleBar, remember, upload, selection, multiple, proportion, resize, style, group, inherit);
36394
+
36395
+ Slicer
36396
+ zim class - extends a zim.Window which extends a zim.Container which extends a createjs.Container
36397
+
36398
+ DESCRIPTION
36399
+ A Slicer provides a tool to break a DisplayObject such as a Pic() into horizontal and vertical regions.
36400
+
36401
+ See: https://zimjs.com/slicer which shows how a Slicer can be used to create data for a ZIM SlicedBitmap
36402
+
36403
+ The component has a horizontal track at the top which can be pressed to make editable vertical lines
36404
+ and a vertical track at the left that can be pressed to make editable horizontal lines.
36405
+ The sections can be selected or multiple selected and properties applied.
36406
+ The lines can be dragged and deleted and their percentages retrieved with the slices property.
36407
+ A new picture can be uploaded with the pic icon at the bottom right.
36408
+ The interface can be hidden, the window resized at bottom right and collapsed at top right.
36409
+
36410
+ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
36411
+
36412
+ EXAMPLE
36413
+ // slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
36414
+ const pic = new Pic("car.png"); // preload this in Frame() or loadAssets()
36415
+ const slicer = new Slicer({
36416
+ obj:pic.clone(), // slicer will adjust obj so clone the pic so can use it unaffected later
36417
+ scale:.5,
36418
+ upload:false
36419
+ })
36420
+ .pos(30,50)
36421
+ .change(()=>{preview.exchange = slicer.exchange;); // this will update the picture below
36422
+
36423
+ slicer.on("loaded", ()=>{
36424
+ if (preview) preview.dispose();
36425
+ preview = new zim.SlicedBitmap(1600, 600, slicer.obj.clone(), slicer.slices, slicer.types, 2, .5)
36426
+ .pos(0,100,CENTER,BOTTOM)
36427
+ .transform({minScaleX:.05, minScaleY:.05});
36428
+ });
36429
+
36430
+ // this will provide slice type options
36431
+ new SlicerTypes(slicer).pos(30,120,RIGHT,TOP);
36432
+
36433
+ // slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
36434
+ let preview = new SlicedBitmap(1600, pic.height, pic)
36435
+ .center()
36436
+ .transform({minScaleX:.05, minScaleY:.05});
36437
+ END EXAMPLE
36438
+
36439
+ PARAMETERS
36440
+ ** supports DUO - parameters or single object with properties below
36441
+ ** supports OCT - parameter defaults can be set with STYLE control (like CSS)
36442
+ obj - (default new Tile()) a DisplayObject to slice
36443
+ objScale - (default 1) set the scale of the object in the Slicer
36444
+ slices - (default null) an array of horizontal and vertical arrays holding slice percentage
36445
+ [[.25,.75], [.1,.4,.5,.9]]
36446
+ three horizontal regions made from two vertical lines placed at 1/4 and 3/4 the width
36447
+ five vertical regions made from four horizontal lines with 1/10 the picture at left, middle and right
36448
+ types - (default null) an array of horizontal and vertical arrays holding slice types
36449
+ 0 - fix - keeps the original width and height of the region. Usually, good for corners.
36450
+ 1 - stretch - stretch the region to fill space as an object is stretched
36451
+ 2 - tile - tile the region at original scale - currently, will match the first side and sometimes the second side
36452
+ titleBar - (default "Slicer") the title of the window as a String or ZIM Label
36453
+ remember - (default true) use localStorage(zimSlicer) to store the last settings of the lines - see clear() method
36454
+ upload - (default true) provide a pic button at bottom right to upload a pic
36455
+ selection - (default true) let the sliced regions be selected
36456
+ multiple - (default true) if selection then let shift or the multiple button be used to select multiple regions - set to false for single selection
36457
+ proportion - (default true) when resized (or on upload) keep the percentages - set to false to keep lines at pixel setting
36458
+ resize - (default true) roll over bottom right corner to resize - set to false to not provide resizing - also can use resizeVisible as STYLE to keep visible
36459
+ style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
36460
+ group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
36461
+ inherit - (default null) used internally but can receive an {} of styles directly
36462
+
36463
+ METHODS
36464
+ hasProp(property as String) - returns true if property exists on object else returns false
36465
+ setObject(newObj, scale) - change the object in the slicer and set the scale of the object
36466
+ updateLines(slices) - remake lines with slices data - see slices parameter
36467
+ setSlicerTypes(slicerTypes) - add a ZIM SlicerTypes object to control slicer types
36468
+ clearSelection() - clears all highlights - not the line selections but the region selections
36469
+ clear() - clears remembered data stored in localStorage(zimSlicer)
36470
+ clone() - makes a copy with properties such as x, y, etc. also copied
36471
+ dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
36472
+
36473
+ ALSO: All Window methods such as resize()
36474
+
36475
+ ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
36476
+ drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
36477
+ addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
36478
+ ALSO: see the CreateJS Easel Docs for Container methods, such as:
36479
+ on(), off(), getBounds(), setBounds(), cache(), uncache(), updateCache(), dispatchEvent(),
36480
+ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChildren(), etc.
36481
+
36482
+ PROPERTIES
36483
+ type - holds the class name as a String
36484
+ obj - get a reference to the object being sliced - see setObject() to set the object
36485
+ slices - get or set the slices array - see the slices parameter
36486
+ types - get or set the types array - see the types parameter
36487
+ exchange - get or set [slices, types] as a single array - used to set a SlicedBitmap
36488
+ selectedIndexH - get the selected index of the current horizontal slice
36489
+ selectedIndexV - get the selected index of the current vertical slice
36490
+ currentLineH - get the selected horizontal slice line (a vertical line)
36491
+ currentLineV - get the selected vertical slice line (a horizontal line)
36492
+ selection - get an array of currently highlighted regions - also see highLightContainer
36493
+ box - a reference to the box Rectangle that directly surrounds the obj
36494
+ trackH - a reference to the top track Rectangle
36495
+ trackV - a reference to the left track Rectangle
36496
+ deleteH - a reference to the delete Button at top right
36497
+ deleteV - a reference to the delete Button at bottom left
36498
+ hide - a reference to the hide Button at top left
36499
+ loader - a reference to the Loader button at bottom right
36500
+ linesHContainer - a reference to the Container of horizontal slice lines (vertical lines)
36501
+ linesVContainer - a reference to the Container of vertical slice lines (vertical lines)
36502
+ highlightContainer - a reference to the left track Rectangle
36503
+
36504
+ ALSO: see ZIM Window for properties - like titleBar, titleBarLabel, resizeHandle, etc.
36505
+
36506
+ ALSO: see ZIM Container for properties such as:
36507
+ width, height, widthOnly, heightOnly, draggable, level, depth, group
36508
+ blendMode, hue, saturation, brightness, contrast, etc.
36509
+
36510
+ ALSO: see the CreateJS Easel Docs for Container properties, such as:
36511
+ x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
36512
+ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, etc.
36513
+
36514
+ EVENTS
36515
+ change - dispatched when a line is added, deleted or moved
36516
+ selection - dispatched when a region is selected or deselected
36517
+ delete - dispatched when a line is deleted
36518
+ loaded - dispatched when an image is loaded
36519
+
36520
+ ALSO: all Window events including "collapse", "expand", "resize"
36521
+
36522
+ ALSO: see the CreateJS Easel Docs for Container events such as:
36523
+ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
36524
+ --*///+62.7
36525
+ zim.Slicer = function(obj, objScale, slices, types, titleBar, remember, upload, selection, multiple, proportion, resize, style, group, inherit) {
36526
+ var sig = "obj, objScale, slices, types, titleBar, remember, upload, selection, multiple, proportion, resize, style, group, inherit";
36527
+ var duo; if (duo = zob(zim.Slicer, arguments, sig, this)) return duo;
36528
+ z_d("62.7");
36529
+ this.group = group;
36530
+ var DS = style===false?{}:zim.getStyle("Slicer", this.group, inherit);
36531
+
36532
+ if (zot(obj)) obj = DS.obj!=null?DS.obj:new zim.Tile();
36533
+ if (zot(objScale)) objScale = DS.objScale!=null?DS.objScale:1;
36534
+ var scale = objScale;
36535
+ var empty = slices;
36536
+ if (zot(slices)) slices = DS.slices!=null?DS.slices:[[0,1],[0,1]];
36537
+ var defaults = [[1],[1]];
36538
+ zim.loop(slices,function(s,i) {
36539
+ zim.loop(s,function() {
36540
+ defaults[i].push(1);
36541
+ });
36542
+ });
36543
+ slices = zim.copy(slices);
36544
+ if (zot(types)) types = DS.slices!=null?DS.slices:defaults;
36545
+ types = zim.copy(types);
36546
+ if (zot(titleBar)) titleBar = DS.titleBar!=null?DS.titleBar:"Slicer";
36547
+ if (zot(remember)) remember = DS.remember!=null?DS.remember:true;
36548
+ if (zot(upload)) upload = DS.upload!=null?DS.upload:true;
36549
+ if (zot(selection)) selection = DS.selection!=null?DS.selection:true;
36550
+ if (zot(multiple)) multiple = DS.multiple!=null?DS.multiple:true;
36551
+ if (zot(proportion)) proportion = DS.proportion!=null?DS.proportion:true;
36552
+ if (zot(resize)) resize = DS.resize!=null?DS.resize:true;
36553
+
36554
+ // WINDOW
36555
+ var wW = obj.width*scale+60;
36556
+ var wH = obj.height*scale+60+(titleBar?30:0);
36557
+ var oWW = wW;
36558
+ var oWH = wH;
36559
+ this.zimWindow_constructor(wW, wH,
36560
+ null, null, null, null, null, null, false, null, null, null, null, null, false, false, false, null, null, null, null, null, null, null, null, null, null,
36561
+ titleBar, dark, moon, null, true, null, null, null, null, null, null, null, resize, true
36562
+ );
36563
+ this.type = "Slicer";
36564
+ var that = this;
36565
+ if (that.collapseIcon) that.collapseIcon.mov(2);
36566
+ if (that.titleBar) {
36567
+ that.titleBarLabel.mov(26,1);
36568
+ zdf.makeIcon(tin, clear, [tin, tin, tin, tin, tin]).scaleTo(that.titleBar,87,87).loc(5,2,that.titleBar);
36569
+ }
36570
+
36571
+ that.obj = obj;
36572
+ that.data = slices;
36573
+ that.dataTypes = types;
36574
+ // CONTAINERS
36575
+ var hh = that.height-(titleBar?30:0);
36576
+ var content = new zim.Container(that.width, hh);
36577
+ var sc = that.splitterContent = new zim.Container(that.width-60, hh-60).pos(30,30,LEFT,TOP,content);
36578
+
36579
+ // OBJECT
36580
+ var w = obj.width*scale;
36581
+ var h = obj.height*scale;
36582
+ obj.sca(scale).addTo(sc);
36583
+
36584
+
36585
+ // CONTENT
36586
+ var box = that.box = new zim.Rectangle({width:w, height:h, borderColor:black, scaleDimensions:false}).alp(.5).pos(30,30,LEFT,TOP,content).expand(0)
36587
+ box.on("mousedown", doClear);
36588
+ function doClear() {
36589
+ linesH.loop(function(l) {
36590
+ l.triangle.color = faint;
36591
+ });
36592
+ currentH = null;
36593
+ linesV.loop(function(l) {
36594
+ l.triangle.color = faint;
36595
+ });
36596
+ currentV = null;
36597
+ that.stage.update();
36598
+ }
36599
+
36600
+ var hide = that.hide = new zim.Button({width:30, height:30, label:"-", toggle:"+", color:silver, backgroundColor:darker, rollBackgroundColor:lighter, rollColor:granite, corner:0, shadowColor:-1, style:false}).sca(1).loc(0,0,content);
36601
+ hide.label.mov(0,-2)
36602
+ hide.on("click", function(){
36603
+ if (hide.toggled) {
36604
+ hide.label.mov(0,3);
36605
+ box.visible = trackH.visible = trackV.visible = linesH.visible = linesV.visible = deleteH.visible = deleteV.visible = highlights.visible = false;
36606
+ if (multi) multi.vis(false);
36607
+ if (upload) loader.removeFrom();
36608
+ } else {
36609
+ hide.label.mov(0,-3);
36610
+ box.visible = trackH.visible = trackV.visible = linesH.visible = linesV.visible = deleteH.visible = deleteV.visible = highlights.visible = true;
36611
+ if (multi) multi.vis(true);
36612
+ if (upload) loader.addTo(that.contentContainer);
36613
+ }
36614
+ });
36615
+
36616
+ var trackH = that.trackH = new zim.Rectangle(w, 30, white).alp(.1).loc(box.x, box.y-30, content).cur();
36617
+ var trackV = that.trackV = new zim.Rectangle(30, h, white).alp(.1).loc(box.x-30, box.y, content).cur();
36618
+ var deleteH = that.deleteH = new zim.Button({width:60, height:60, label:"X", backgroundColor:red, corner:0, shadowColor:-1, style:false}).sca(.5).pos(0,0,RIGHT,TOP,content);
36619
+ var deleteV = that.deleteV = deleteH.clone().pos(0,0,LEFT,BOTTOM,content);
36620
+
36621
+ if (selection && multiple) var multi = that.toggle = new zim.Toggle({height:18, width:30, backgroundColor:grey, corner:9, label:"multiple", color:tin})
36622
+ .loc(deleteV.x + 45, deleteV.y+6, content);
36623
+
36624
+ if (upload) {
36625
+ var icon1 = new zim.Circle(6,silver).reg(CENTER,3);
36626
+ new zim.Circle({radius:9, color:silver, percent:40}).center(icon1).mov(0,8);
36627
+ var icon2 = new zim.Circle(6,grey).reg(CENTER,3);
36628
+ new zim.Circle({radius:9, color:grey, percent:40}).center(icon2).mov(0,8);
36629
+ var loader = that.loader = new zim.Loader({
36630
+ width:30,
36631
+ height:30,
36632
+ backgroundColor:darker,
36633
+ rollBackgroundColor:lighter,
36634
+ corner:3,
36635
+ borderColor:-1,
36636
+ label:"",
36637
+ icon:icon1,
36638
+ rollIcon:icon2
36639
+ });
36640
+ loader.on("loaded", function(e) {
36641
+ obj.dispose();
36642
+ loader.removeRoll();
36643
+ var f = e.bitmap.fit(0,0,oWW-60, oWH-60-(titleBar?30:0));
36644
+ scale = f.scale;
36645
+ e.bitmap.sca(1);
36646
+ wW = e.bitmap.width*scale+60;
36647
+ wH = e.bitmap.height*scale+60;
36648
+ that.resize(wW, wH);
36649
+ obj = e.bitmap.sca(scale).loc(0,0,sc,0);
36650
+ that.obj = obj;
36651
+ doResize();
36652
+ that.dispatchEvent("loaded");
36653
+ });
36654
+ }
36655
+
36656
+ var instruct = that.instruct = new zim.Container(content.width, content.height).addTo(content).animate({
36657
+ wait:1,
36658
+ from:true,
36659
+ props:{alpha:0},
36660
+ rewind:true,
36661
+ rewindWait:2,
36662
+ call:function(){instruct.dispose(); instruct=null;}
36663
+ }).noMouse();
36664
+ new zim.Label("Add slices here", 15, null, blue).pos(0,8,CENTER,TOP,instruct);
36665
+ new zim.Label("Add slices here", 15, null, blue).rot(-90).pos(8,0,LEFT,CENTER,instruct);
36666
+
36667
+ // ADD CONTENT TO WINDOW
36668
+ that.add(content);
36669
+ that.add(loader, null, true);
36670
+ loader.pos(0,0,RIGHT,BOTTOM)
36671
+
36672
+
36673
+ // LINES
36674
+ var linesH = that.linesHContainer = new zim.Container(w,h).loc(box, null, content);
36675
+ var linesV = that.linesVContainer = new zim.Container(w,h).loc(box, null, content);
36676
+ var currentH;
36677
+ var currentV;
36678
+
36679
+ // axis is direction of line, so VERTICAL will use linesH, etc.
36680
+ that.makeLine = function(axis, ratio, selected) {
36681
+ if (ratio > 1) ratio /= 100;
36682
+ var line;
36683
+ if (axis == "vertical") {
36684
+ var x = ratio*box.width;
36685
+ line = new zim.Container(30,h+30).reg(15,30).loc(x, 0, linesH);
36686
+ line.triangle = new zim.Triangle(30,30,30,selected?blue:faint,blue).rot(180).pos(0,4,CENTER,TOP,line);
36687
+ line.line = new zim.Rectangle(1,box.height,red).ble().expand(3).reg(0,0).pos(0,30,CENTER,TOP,line);
36688
+ line.drag({all:true, boundary:new zim.Boundary(0,0,box.width,0), localBoundary:true});
36689
+ line.on("mousedown", function() {
36690
+ linesH.loop(function(l) {
36691
+ if (l==line) l.triangle.color = blue;
36692
+ else l.triangle.color = faint;
36693
+ });
36694
+ currentH = that.currentLineH = line;
36695
+ that.stage.update();
36696
+ });
36697
+ line.on("pressmove", dataLinesH);
36698
+ } else {
36699
+ var y = ratio*box.height;
36700
+ line = new zim.Container(w+30,30).reg(30,15).loc(0, y, linesV);
36701
+ line.triangle = new zim.Triangle(30,30,30,selected?blue:faint,blue).rot(90).pos(4,0,LEFT,CENTER,line);
36702
+ line.line = new zim.Rectangle(box.width,1,red).ble().expand(3).reg(0,0).pos(30,0,LEFT,CENTER,line);
36703
+ line.drag({all:true, boundary:new zim.Boundary(0,0,0,box.height), localBoundary:true});
36704
+ line.on("mousedown", function() {
36705
+ linesV.loop(function(l) {
36706
+ if (l==line) l.triangle.color = blue;
36707
+ else l.triangle.color = faint;
36708
+ });
36709
+ currentV = that.currentLineV = line;
36710
+ that.stage.update();
36711
+ });
36712
+ line.on("pressmove", dataLinesV);
36713
+ }
36714
+ return line;
36715
+ }
36716
+
36717
+ // HORIZONTAL
36718
+ // across the top - will make vertical lines but slices into horizontal regions
36719
+ trackH.on("mousedown", function() {
36720
+ if (instruct) instruct.dispose();
36721
+ linesH.loop(function(l) {
36722
+ l.triangle.color = faint;
36723
+ });
36724
+ var point = linesH.globalToLocal(F.mouseX, F.mouseY);
36725
+ that.currentLineH = currentH = that.makeLine(VERTICAL, point.x/box.width, true);
36726
+
36727
+ // move any selections past the line forward one
36728
+ var c = that.selectedIndexH = getIndexH(currentH);
36729
+ selected.sort(function (a, b) {
36730
+ return a[0] - b[0];
36731
+ });
36732
+ loop(selected, function (s, i) {
36733
+ if (s[0] >= c) s[0]++;
36734
+ }, true); // true for backwards
36735
+
36736
+ // adding dataTypes to columns in each row
36737
+ if (that.dataTypes) {
36738
+ that.dataTypes[0].splice(c-1, 0, that.dataTypes[0][c-1]); // take types from next door
36739
+ // zim.loop(that.dataTypes, function(row,j){
36740
+ // row.splice(c-1, 0, [row[c-1][0], row[c-1][1]]); // take types from next door
36741
+ // });
36742
+ }
36743
+
36744
+ dataLinesH();
36745
+ that.stage.update();
36746
+ })
36747
+
36748
+ deleteH.on("click", function(){
36749
+ if (currentH) {
36750
+
36751
+ // move any selections past the line including the line back one
36752
+ var c = getIndexH(currentH);
36753
+ selected.sort(function (a, b) {
36754
+ return a[0] - b[0];
36755
+ });
36756
+ loop(selected, function (s, i) {
36757
+ if (s[0] >= c - 1) s[0]--;
36758
+ }, true); // true for backwards
36759
+
36760
+ // remove duplicates of one less than c
36761
+ var already = [];
36762
+ loop(selected, function(s, i) {
36763
+ if (s[0] == c-2 && already.indexOf(JSON.stringify(s)) >= 0) selected.splice(i,1);
36764
+ else already.push(JSON.stringify(s));
36765
+ }, true);
36766
+ already = null;
36767
+
36768
+ // remove data from types
36769
+ if (that.dataTypes) that.dataTypes[0].splice(c-1, 1);
36770
+
36771
+ currentH.dispose();
36772
+ that.currentLineH = currentH = null;
36773
+
36774
+ dataLinesH();
36775
+ that.dispatchEvent("delete");
36776
+ that.stage.update();
36777
+ }
36778
+ });
36779
+
36780
+ function dataLinesH() {
36781
+ that.data[0] = [0,1];
36782
+ linesH.loop(function(l) {
36783
+ that.data[0].push(zim.decimals(l.x/box.width,3));
36784
+ })
36785
+ that.data[0].sort(function(a, b){return a-b});
36786
+ adjustBoxes();
36787
+ }
36788
+
36789
+ function getIndexH(line) {
36790
+ var c = zim.loop(that.data[0], function(x,i) {
36791
+ if (zim.decimals(line.x/box.width,3) < x) return i;
36792
+ });
36793
+ return c;
36794
+ }
36795
+
36796
+ // VERTICAL
36797
+ // same as horizontal but along left will make vertical lines but slices into vertical regions
36798
+ trackV.on("mousedown", function() {
36799
+ if (instruct) instruct.dispose();
36800
+ linesV.loop(function(l) {
36801
+ l.triangle.color = faint;
36802
+ });
36803
+ var point = linesV.globalToLocal(F.mouseX, F.mouseY);
36804
+
36805
+ var point = linesH.globalToLocal(F.mouseX, F.mouseY);
36806
+ that.currentLineV = currentV = that.makeLine(HORIZONTAL, point.y/box.height, true);
36807
+
36808
+ // move any selections past the line forward one
36809
+ var r = that.selectedIndexV = getIndexV(currentV);
36810
+ selected.sort(function (a, b) {
36811
+ return a[1] - b[1];
36812
+ });
36813
+ loop(selected, function (s, i) {
36814
+ if (s[1] >= r) s[1]++;
36815
+ }, true); // true for backwards
36816
+
36817
+ // adding row with columns
36818
+ if (that.dataTypes) that.dataTypes[1].splice(r-1, 0, that.dataTypes[1][r-1]); // take types from next door
36819
+
36820
+ dataLinesV();
36821
+ that.stage.update();
36822
+ })
36823
+
36824
+ deleteV.on("click", function(){
36825
+ if (currentV) {
36826
+ // move any selections past the line including the line back one
36827
+ var r = getIndexV(currentV);
36828
+ selected.sort(function (a, b) {
36829
+ return a[1] - b[1];
36830
+ });
36831
+ loop(selected, function (s, i) {
36832
+ if (s[1] >= r - 1) s[1]--;
36833
+ }, true); // true for backwards
36834
+
36835
+ // remove duplicates of less than r
36836
+ var already = [];
36837
+ loop(selected, function(s, i) {
36838
+ if (s[1] == r-2 && already.indexOf(JSON.stringify(s)) >= 0) selected.splice(i,1);
36839
+ else already.push(JSON.stringify(s));
36840
+ }, true);
36841
+ already = null;
36842
+
36843
+ // remove data from types
36844
+ if (that.dataTypes) that.dataTypes[1].splice(r-1, 1);
36845
+
36846
+ currentV.dispose();
36847
+ that.currentLineV = currentV = null;
36848
+
36849
+ dataLinesV();
36850
+ that.dispatchEvent("delete");
36851
+ that.stage.update();
36852
+ }
36853
+ });
36854
+
36855
+ function dataLinesV() {
36856
+ that.data[1] = [0,1];
36857
+ linesV.loop(function(l) {
36858
+ that.data[1].push(zim.decimals(l.y/box.height,3));
36859
+ })
36860
+ that.data[1].sort(function(a, b){return a-b});
36861
+ adjustBoxes();
36862
+ }
36863
+
36864
+ function getIndexV(line) {
36865
+ var r = zim.loop(that.data[1], function(y,i) {
36866
+ if (zim.decimals(line.y/box.height,3) < y) return i;
36867
+ });
36868
+ return r;
36869
+ }
36870
+
36871
+ // HIGHLIGHTS
36872
+ function adjustBoxes(dispatch) {
36873
+ if (zot(dispatch)) dispatch = true;
36874
+ highlights.disposeAllChildren();
36875
+ zim.loop(selected, function(s) {
36876
+ that.selectTile(s[0],s[1]);
36877
+ });
36878
+ if (dispatch) that.dispatchEvent("change");
36879
+ if (localStorage) localStorage.zimSlicer = JSON.stringify(that.exchange);
36880
+ }
36881
+
36882
+ var selected = that.selected = [];
36883
+
36884
+ var highlights = that.highlightsContainer = new zim.Container(W,H).loc(box, null, content).noMouse();
36885
+ var gap = 5;
36886
+ that.selectTile = function(c,r,d) {
36887
+ if (d) highlights.disposeAllChildren();
36888
+ c = zim.constrain(c,0,that.data[0].length-1);
36889
+ r = zim.constrain(r,0,that.data[1].length-1);
36890
+ that.selection = new zim.Rectangle(that.data[0][c+1]*box.width-that.data[0][c]*box.width-gap*2, that.data[1][r+1]*box.height-that.data[1][r]*box.height-gap*2, white.toAlpha(.2), white, 2, 0, true)
36891
+ .loc(that.data[0][c]*box.width+gap, that.data[1][r]*box.height+gap, highlights)
36892
+ .ble();
36893
+ }
36894
+
36895
+ if (selection) {
36896
+ box.cur();
36897
+ box.on("mousedown", function(){
36898
+ var point = box.globalToLocal(that.stage.frame.mouseX, that.stage.frame.mouseY);
36899
+ var c = zim.loop(that.data[0], function(x,i) {
36900
+ if (point.x < x*box.width) return i-1;
36901
+ });
36902
+ var r = zim.loop(that.data[1], function(y,i) {
36903
+ if (point.y < y*box.height) return i-1;
36904
+ });
36905
+
36906
+ var empty = zim.loop(selected, function(s,i) {
36907
+ if (JSON.stringify(s) == JSON.stringify([c,r])) {
36908
+ if (selected.length > 1 && multiple && !F.shiftKey && !multi.toggled) return true; // if others just clear others
36909
+ selected.splice(i,1); // else toggling a selected
36910
+ return false;
36911
+ }
36912
+ });
36913
+
36914
+ if (!multiple || (!F.shiftKey && !multi.toggled)) selected = that.selected = [];
36915
+ if (empty) {
36916
+ selected.push([c,r]); // could put the above like in this conditional
36917
+ }
36918
+
36919
+ adjustBoxes(false);
36920
+ that.dispatchEvent("selection");
36921
+ });
36922
+ }
36923
+
36924
+ // RESIZE
36925
+ that.on("resize", doResize);
36926
+ function doResize() {
36927
+ hh = that.height-(titleBar?30:0);
36928
+ var boxH = box.width;
36929
+ var boxV = box.height;
36930
+ that.box.siz(that.width-60, hh-60).expand(0);
36931
+ deleteH.loc(box.x+box.width,box.y-30);
36932
+ deleteV.loc(box.x-30,box.y+box.height);
36933
+ trackH.widthOnly = box.width;
36934
+ trackV.heightOnly = box.height;
36935
+ linesH.loop(function(line, i) {
36936
+ line.line.heightOnly = box.height;
36937
+ if (proportion) line.x = line.x*box.width/boxH;
36938
+ line.dragBoundary(new zim.Boundary(0,0,box.width,0));
36939
+ });
36940
+ linesV.loop(function(line) {
36941
+ line.line.widthOnly = box.width;
36942
+ if (proportion) line.y = line.y*box.height/boxV;
36943
+ line.dragBoundary(new zim.Boundary(0,0,0,box.height));
36944
+ });
36945
+ if (multi) multi.loc(deleteV.x + 45, deleteV.y+6, content);
36946
+ if (upload) {
36947
+ loader.loc(that.box.width+30,that.box.height+30);
36948
+ loader.resize();
36949
+ }
36950
+ adjustBoxes();
36951
+ setTimeout(function(){
36952
+ obj.scaleTo(that.box,100,100).loc(0,0,sc,0);
36953
+ that.stage.update();
36954
+ },20);
36955
+ }
36956
+ if (resize) {
36957
+ that.resizeHandle.on("pressup", function() {
36958
+ var wW = obj.width+60;
36959
+ var wH = obj.height+60;
36960
+ that.resize(wW,wH);
36961
+ that.stage.update()
36962
+ });
36963
+ }
36964
+
36965
+
36966
+
36967
+ // METHODS
36968
+ that.setObject = function(newObj, scale) {
36969
+ obj.dispose();
36970
+ obj = newObj;
36971
+ if (zot(scale)) {
36972
+ var f = e.bitmap.fit(0,0,oWW-60, oWH-60-(titleBar?30:0));
36973
+ scale = f.scale;
36974
+ }
36975
+ obj.sca(1);
36976
+ wW = obj.width*scale+60;
36977
+ wH = obj.height*scale+60;
36978
+ that.resize(wW, wH);
36979
+ obj = obj.sca(scale).loc(0,0,sc,0);
36980
+ that.obj = obj;
36981
+ doResize();
36982
+ that.dispatchEvent("loaded");
36983
+ return that;
36984
+ }
36985
+
36986
+ that.updateLines = function(slices) {
36987
+ that.data = slices;
36988
+ // clear all lines and remake them to the data
36989
+ linesH.disposeAllChildren();
36990
+ linesV.disposeAllChildren();
36991
+ zim.loop(slices[0], function(x,i,t) {if (i!=0 && i!=t-1) {that.makeLine(VERTICAL, x)};});
36992
+ zim.loop(slices[1], function(y,i,t) {if (i!=0 && i!=t-1) {that.makeLine(HORIZONTAL, y)};});
36993
+ that.selectedIndexH = that.selectedIndexV = that.currentLineH = that.currentLineV = null;
36994
+ if (that.stage) that.stage.update();
36995
+ return that;
36996
+ }
36997
+
36998
+ that.setSlicerTypes = function(slicerTypes) {
36999
+ if (!that.dataTypes) that.dataTypes = [[1],[1]];
37000
+ var st = that.slicerTypes = slicerTypes;
37001
+ that.on("select", function() {
37002
+ if (selected.length > 0) {
37003
+ st.shield.vis(false);
37004
+
37005
+ // loop through all selected and if the same types
37006
+ var lastH;
37007
+ var lastV;
37008
+ zim.loop(selected, function(s) {
37009
+ var type = that.dataTypes[0][s[0]];
37010
+ if (lastH != "bad" && (lastH==null || lastH==type)) lastH = type;
37011
+ else lastH = "bad";
37012
+ type = that.dataTypes[1][s[1]];
37013
+ if (lastV != "bad" && (lastV==null || lastV==type)) lastV = type;
37014
+ else lastV = "bad";
37015
+ if (lastH == "bad" && lastV == "bad") return false; // exits loop
37016
+ });
37017
+
37018
+ // if not the same types then yellow the box and remove selection
37019
+ if (lastH == "bad") {
37020
+ st.radioH.selectedIndex = -1;
37021
+ st.tile.backgrounds[1].color = brown;
37022
+ } else {
37023
+ st.radioH.selectedIndex = lastH;
37024
+ st.tile.backgrounds[1].color = light;
37025
+ }
37026
+
37027
+ if (lastV == "bad") {
37028
+ st.radioV.selectedIndex = -1;
37029
+ st.tile.backgrounds[3].color = brown;
37030
+ } else {
37031
+ st.radioV.selectedIndex = lastV;
37032
+ st.tile.backgrounds[3].color = light;
37033
+ }
37034
+
37035
+ } else {
37036
+ st.radioH.selectedIndex = -1;
37037
+ st.radioV.selectedIndex = -1;
37038
+ st.shield.vis(true);
37039
+ }
37040
+ });
37041
+ that.stage.update();
37042
+ return that;
37043
+ }
37044
+
37045
+ that.clearSelection = function() {
37046
+ selected = that.selected = [];
37047
+ highlights.disposeAllChildren();
37048
+ if (that.slicerTypes) {
37049
+ var st = that.slicerTypes;
37050
+ st.radioH.selectedIndex = -1;
37051
+ st.radioV.selectedIndex = -1;
37052
+ st.shield.vis(true);
37053
+ }
37054
+ that.stage.update();
37055
+ return that;
37056
+ }
37057
+
37058
+ that.clear = function() {
37059
+ if (localStorage) localStorage.removeItem("zimSlicer");
37060
+ that.exchange = [[[],[]],[[1],[1]]];
37061
+ that.clearSelection();
37062
+ that.dispatchEvent("change");
37063
+ return that;
37064
+ }
37065
+
37066
+
37067
+ // PROPERTIES
37068
+ Object.defineProperty(that, 'slices', {
37069
+ get: function() {
37070
+ var temp = zim.copy(that.data);
37071
+ temp[0].shift();
37072
+ temp[0].pop();
37073
+ temp[1].shift();
37074
+ temp[1].pop();
37075
+ return temp;
37076
+ },
37077
+ set: function(value) {
37078
+ var slices = zim.copy(value);
37079
+ slices[0].unshift(0);
37080
+ slices[0].push(1);
37081
+ slices[1].unshift(0);
37082
+ slices[1].push(1);
37083
+ that.updateLines(slices);
37084
+ }
37085
+ });
37086
+
37087
+ Object.defineProperty(that, 'types', {
37088
+ get: function() {
37089
+ return zim.copy(that.dataTypes);
37090
+ },
37091
+ set: function(value) {
37092
+ that.dataTypes = zim.copy(value);
37093
+ }
37094
+ });
37095
+
37096
+ Object.defineProperty(that, 'exchange', {
37097
+ get: function() {
37098
+ var temp = zim.copy(that.data);
37099
+ temp[0].shift();
37100
+ temp[0].pop();
37101
+ temp[1].shift();
37102
+ temp[1].pop();
37103
+ return [temp, zim.copy(that.dataTypes)];
37104
+ },
37105
+ set: function(value) {
37106
+ var slices = zim.copy(value[0]);
37107
+ var types = zim.copy(value[1]);
37108
+ slices[0].unshift(0);
37109
+ slices[0].push(1);
37110
+ slices[1].unshift(0);
37111
+ slices[1].push(1);
37112
+ that.updateLines(slices);
37113
+ that.dataTypes = types;
37114
+ }
37115
+ });
37116
+
37117
+ // MEMORY
37118
+ if (remember && localStorage && localStorage.zimSlicer) {
37119
+ that.exchange = JSON.parse(localStorage.zimSlicer);
37120
+ instruct.dispose();
37121
+ } else if (empty) {
37122
+ that.exchange =[slices, types];
37123
+ instruct.dispose();
37124
+ }
37125
+ setTimeout(function(){that.dispatchEvent("change");},20);
37126
+
37127
+ if (style!==false) zim.styleTransforms(this, DS);
37128
+ this.clone = function() {
37129
+ return that.cloneProps(new zim.Slicer(obj.clone(), objScale, zim.copy(slices), zim.copy(types), titleBar, remember, upload, selection, multiple, proportion, resize, style, this.group, inherit));
37130
+ };
37131
+
37132
+ }
37133
+ zim.extend(zim.Slicer, zim.Window, ["clone"], "zimWindow", false);
37134
+ //-62.7
37135
+
37136
+ //
37137
+ /*--
37138
+ zim.SlicerTypes = function(slicer, titleBar, sliceType, style, group, inherit);
37139
+
37140
+ SlicerTypes
37141
+ zim class - extends a zim.Window which extends a zim.Container which extends a createjs.Container
37142
+
37143
+ DESCRIPTION
37144
+ SlicerTypes works with ZIM Slicer to provide slice types for ZIM SlicedBitmap.
37145
+ The component is not to be used on its own.
37146
+ Pass a ZIM Slicer object to the slicer parameter - the Slicer should be made first.
37147
+ There are fixed, stretch and tile radio buttons for horizontal and vertical
37148
+ and import and export buttons to work with [slices, types] used in Slicer and SlicedBitmap parameters and exchange property.
37149
+
37150
+ See: https://zimjs.com/slicer which shows how a Slicer can be used to create data for a ZIM SlicedBitmap
37151
+
37152
+ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
37153
+
37154
+ EXAMPLE
37155
+ // slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
37156
+ const pic = new Pic("car.png"); // preload this in Frame() or loadAssets()
37157
+ const slicer = new Slicer({
37158
+ obj:pic.clone(), // slicer will adjust obj so clone the pic so can use it unaffected later
37159
+ scale:.5,
37160
+ upload:false
37161
+ })
37162
+ .pos(30,50)
37163
+ .change(()=>{preview.exchange = slicer.exchange;); // this will update the picture below
37164
+
37165
+ slicer.on("loaded", ()=>{
37166
+ if (preview) preview.dispose();
37167
+ preview = new zim.SlicedBitmap(1600, 600, slicer.obj.clone(), slicer.slices, slicer.types, 2, .5)
37168
+ .pos(0,100,CENTER,BOTTOM)
37169
+ .transform({minScaleX:.05, minScaleY:.05});
37170
+ });
37171
+
37172
+ // this will provide slice type options
37173
+ new SlicerTypes(slicer).pos(30,120,RIGHT,TOP);
37174
+
37175
+ // slice a pic in four at 25% from the edges, scale the middle and keep the sides and corners not scaled.
37176
+ let preview = new SlicedBitmap(1600, pic.height, pic)
37177
+ .center()
37178
+ .transform({minScaleX:.05, minScaleY:.05});
37179
+ END EXAMPLE
37180
+
37181
+ PARAMETERS
37182
+ ** supports DUO - parameters or single object with properties below
37183
+ ** supports OCT - parameter defaults can be set with STYLE control (like CSS)
37184
+ slicer - (default null) pass in the ZIM Slicer object to work with - required
37185
+ titleBar - (default "Slicer Types") string or Label for slicerTypes
37186
+ sliceType - (default "stretch") set the default slice type - fixed, stretch, tile
37187
+ style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
37188
+ group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
37189
+ inherit - (default null) used internally but can receive an {} of styles directly
37190
+
37191
+ METHODS
37192
+ hasProp(property as String) - returns true if property exists on object else returns false
37193
+ clone() - makes a copy with properties such as x, y, etc. also copied
37194
+ dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
37195
+
37196
+ ALSO: All Window methods such as resize()
37197
+
37198
+ ALSO: ZIM 4TH adds all the methods listed under Container (see above), such as:
37199
+ drag(), hitTestRect(), animate(), sca(), reg(), mov(), center(), centerReg(),
37200
+ addTo(), removeFrom(), loop(), outline(), place(), pos(), alp(), rot(), setMask(), etc.
37201
+ ALSO: see the CreateJS Easel Docs for Container methods, such as:
37202
+ on(), off(), getBounds(), setBounds(), cache(), uncache(), updateCache(), dispatchEvent(),
37203
+ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChildren(), etc.
37204
+
37205
+ PROPERTIES
37206
+ type - holds the class name as a String
37207
+ slicer - read slicer used
37208
+ sliceType - get or set default slice type - fixed, stretch, tile
37209
+ radioH - access RadioButtons for horizontal
37210
+ radioV - access RadioButtons for horizontal
37211
+ importButton - access import Button
37212
+ exportButton - access export Button
37213
+ importPane - access import Pane
37214
+ exportPane - access export Pane
37215
+ submitButton - access import pane submit Button
37216
+ shield - access shield that darkens radio buttons
37217
+
37218
+ ALSO: see ZIM Window for properties - like titleBar, titleBarLabel, resizeHandle, etc.
37219
+
37220
+ ALSO: see ZIM Container for properties such as:
37221
+ width, height, widthOnly, heightOnly, draggable, level, depth, group
37222
+ blendMode, hue, saturation, brightness, contrast, etc.
37223
+
37224
+ ALSO: see the CreateJS Easel Docs for Container properties, such as:
37225
+ x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
37226
+ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, etc.
37227
+
37228
+ EVENTS
37229
+ ALSO: all Window events including "collapse", "expand", "resize"
37230
+
37231
+ ALSO: see the CreateJS Easel Docs for Container events such as:
37232
+ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
37233
+ --*///+62.75
37234
+ zim.SlicerTypes = function(slicer, titleBar, sliceType, style, group, inherit) {
37235
+ var sig = "slicer, titleBar, sliceType, style, group, inherit";
37236
+ var duo; if (duo = zob(zim.SlicerTypes, arguments, sig, this)) return duo;
37237
+ z_d("62.75");
37238
+ this.group = group;
37239
+ var DS = style===false?{}:zim.getStyle("SlicerTypes", this.group, inherit);
37240
+
37241
+ if (zot(slicer)) slicer = DS.slicer!=null?DS.slicer:null;
37242
+ if (zot(slicer)) {zogy("ZIM SlicerTypes - needs a Slicer Object"); return;}
37243
+
37244
+ if (zot(titleBar)) titleBar = DS.titleBar!=null?DS.titleBar:"Slicer Types";
37245
+ if (zot(sliceType)) sliceType = DS.sliceType!=null?DS.sliceType:"stretch";
37246
+
37247
+ var types = ["fixed", "stretch", "tile"];
37248
+ if (types.indexOf(sliceType) < 0) sliceType = "stretch";
37249
+
37250
+ this.zimWindow_constructor(470,150, null, null, null, null, null, null, false, null, null, null, null, null, false, false, null, null, null, null, null, null, null, null, null, null, null,
37251
+ titleBar, dark, moon, null, true, null, null, null, null, null, null, null, null, true);
37252
+ var that = this;
37253
+ that.collapseIcon.mov(2);
37254
+ that.titleBarLabel.mov(25,1)
37255
+ zdf.makeIcon(tin, clear, [tin, tin, tin, tin, tin]).scaleTo(that.titleBar,87,87).loc(5,2,that.titleBar);
37256
+
37257
+ that.slicer = slicer;
37258
+ that.sliceType = sliceType;
37259
+ that.defaultIndex = types.indexOf(sliceType);
37260
+
37261
+ var holder = new zim.Container();
37262
+ var radioH = that.radioH = new zim.RadioButtons({size:20, buttons:["fixed","stretch","tile"], vertical:false, selectedIndex:-1}).change(doChangeH);
37263
+ var radioV = that.radioV = radioH.clone().change(doChangeV);
37264
+ Style.remember("slicer");
37265
+ STYLE = {align:CENTER, valign:CENTER, backgroundColor:light, backgroundPaddingH:5};
37266
+ var tile = that.tile = new zim.Tile([new Label("Horizontal", 20).alp(.5), radioH, new Label("Vertical", 20).alp(.5),radioV], 2,2, 5,5, true)
37267
+ .sca(.8)
37268
+ .addTo(holder);
37269
+ Style.recall("slicer");
37270
+
37271
+ function doChangeH() {
37272
+ zim.loop(slicer.selected, function(s) {
37273
+ slicer.dataTypes[0][s[0]] = radioH.selectedIndex;
37274
+ });
37275
+ slicer.dispatchEvent("change");
37276
+ tile.backgrounds[1].color = light;
37277
+ that.stage.update();
37278
+ if (localStorage) localStorage.zimSlicer = JSON.stringify(slicer.exchange);
37279
+ }
37280
+ function doChangeV() {
37281
+ zim.loop(slicer.selected, function(s) {
37282
+ slicer.dataTypes[1][s[1]] = radioV.selectedIndex;
37283
+ });
37284
+ slicer.dispatchEvent("change");
37285
+ tile.backgrounds[3].color = light;
37286
+ that.stage.update();
37287
+ if (localStorage) localStorage.zimSlicer = JSON.stringify(slicer.exchange);
37288
+ }
37289
+
37290
+ var importText = new zim.TextArea({width:600, height:300, wrap:true, spellCheck:false})
37291
+ var importPane = that.importPane = new zim.Pane({content:importText, close:true, closeColor:red});
37292
+ importPane.content.mov(0,-20);
37293
+ var submit = that.submitButton = new zim.Button({
37294
+ width:220,
37295
+ label:"IMPORT",
37296
+ wait:"CONFIRM",
37297
+ waitTime:2,
37298
+ waitBackgroundColor:red,
37299
+ rollWaitBackgroundColor:red
37300
+ }).sca(.6).pos(0,-60,CENTER,BOTTOM,importPane.content);
37301
+ submit.on("mousedown", function(){
37302
+ if (submit.waiting) {
37303
+ importPane.hide();
37304
+ submit.clearWait();
37305
+ slicer.clearSelection();
37306
+ var data = importText.text.trim().split("\n");
37307
+ // JSON does not accept decimals without a leading 0 - sigh
37308
+ data = data.pop().replace(/([^0])\./g, "$10."); // $1 is the match of whatever is before the .
37309
+ data = JSON.parse("[" + data + "]");
37310
+ that.updateData(data[0], data[1]);
37311
+ }
37312
+ });
37313
+ submit.on("close", function() {
37314
+ submit.clearWait();
37315
+ });
37316
+
37317
+ var exportText = new zim.TextArea({width:600, height:300, wrap:true, spellCheck:false});
37318
+ var exportPane = that.exportPane = new zim.Pane({content:exportText, close:true, closeColor:red});
37319
+
37320
+ var importButton = that.importButton = new zim.Button({width:220, label:"IMPORT"}).tap(function() {
37321
+ var temp = zim.copy(slicer.data);
37322
+ temp[0].shift();
37323
+ temp[0].pop();
37324
+ temp[1].shift();
37325
+ temp[1].pop();
37326
+ importText.text = "// replace this current data with desired slices, types data:\n\n" + JSON.stringify(temp) +", "+ JSON.stringify(slicer.dataTypes);
37327
+ importPane.show();
37328
+ });
37329
+ var exportButton = that.exportButton = new zim.Button({width:220, label:"EXPORT"}).tap(function() {
37330
+ var temp = zim.copy(slicer.data);
37331
+ temp[0].shift();
37332
+ temp[0].pop();
37333
+ temp[1].shift();
37334
+ temp[1].pop();
37335
+ exportText.text = "// use as slices, types parameters in ZIM SlicedBitmap()\n// can also modify and IMPORT into Slicer Types tool\n\n" + JSON.stringify(temp) +", "+ JSON.stringify(slicer.dataTypes);
37336
+ exportPane.show();
37337
+ })
37338
+ new zim.Tile([importButton,exportButton],1,2,0,20,true).siz(null,tile.height).loc(tile.width+4*5+20, 0, holder);
37339
+ that.add(holder, 0, true);
37340
+
37341
+ that.shield = new zim.Rectangle(tile.width+20, tile.height, dark).alp(.7).loc(tile, null, tile.parent);
37342
+
37343
+ Object.defineProperty(that, 'sliceType', {
37344
+ get: function() {
37345
+ return sliceType;
37346
+ },
37347
+ set: function(value) {
37348
+ sliceType = value;
37349
+ if (types.indexOf(sliceType) < 0) sliceType = "stretch";
37350
+ that.defaultIndex = types.indexOf(sliceType);
37351
+ }
37352
+ });
37353
+
37354
+ if (slicer) slicer.setSlicerTypes(that);
37355
+
37356
+ that.updateData = function(slices, types) {
37357
+ slices[0].unshift(0);
37358
+ slices[0].push(1);
37359
+ slices[1].unshift(0);
37360
+ slices[1].push(1);
37361
+ slicer.updateLines(slices);
37362
+ slicer.dataTypes = types;
37363
+ }
37364
+
37365
+ if (style!==false) zim.styleTransforms(this, DS);
37366
+ this.clone = function() {
37367
+ return that.cloneProps(new zim.SlicerTypes(slicer, titleBar, sliceType, style, this.group, inherit));
37368
+ };
37369
+
37370
+ }
37371
+ zim.extend(zim.SlicerTypes, zim.Window, ["clone"], "zimWindow", false);
37372
+ //-62.75
37373
+
35882
37374
  /*--
35883
37375
  zim.Dial = function(min, max, step, width, backgroundColor, indicatorColor, indicatorScale, indicatorType, useTicks, innerTicks, tickColor, tickStep, semiTicks, tickScale, semiTickScale, innerCircle, innerScale, innerColor, inner2Color, accentSize, accentOffset, accentColor, accentBackgroundColor, accentDifference, sound, linear, gap, limit, keyArrows, keyArrowsStep, keyArrowsH, keyArrowsV, continuous, continuousMin, continuousMax, damp, value, useLabels, labelMargin, addZero, currentValue, style, group, inherit);
35884
37376
 
@@ -37166,7 +38658,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
37166
38658
  if (b && currentSelected) {
37167
38659
  var ti = b.tabInfo;
37168
38660
  if (ti && zot(ti.wait)) {
37169
- // should be rollBackgroundColor but if setting it seems to stick after rolloff
38661
+ // should be rollBackgroundColor but setting it seems to stick after rolloff
37170
38662
  if (ti.selectedBackgroundColor) b.backgroundColor = that.selected==b?ti.selectedBackgroundColor:ti.backgroundColor
37171
38663
  if (ti.selectedColor && b.label) b.color = that.selected==b?ti.selectedColor:ti.color;
37172
38664
  }
@@ -40338,8 +41830,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
40338
41830
  if (zot(collapseColor)) collapseColor = DS.collapseColor!=null?DS.collapseColor:!zot(titleBarColor)?titleBarColor:zim.grey;
40339
41831
  if (zot(collapsed)) collapsed=DS.collapsed!=null?DS.collapsed:false;
40340
41832
 
40341
- // width, height, content, backgroundColor, borderColor, borderWidth, padding, corner, swipe, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, slide, slideFactor, slideSnap, slideSnapDamp, interactive, shadowColor, shadowBlur, paddingH, paddingV, scrollWheel, damp, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, draggable, boundary, onTop, close, closeColor, cancelCurrentDrag, fullSize, fullSizeColor, resizeHandle, collapse, collapseColor, collapsed, optimize, resizeBoundary, resizeVisible, continuous, continuous, style, group, inherit
40342
- this.zimWindow_constructor(width, height, null, backgroundColor, null, DS.borderWidth!=null?DS.borderWidth:2, DS.padding!=null?DS.padding:10, DS.corner!=null?DS.corner:10, null, DS.scrollBarActive!=null?DS.scrollBarActive:true, DS.scrollBarDrag!=null?DS.scrollBarDrag:true, null, null, null, false, null, null, null, null, null, true, null, null, null, null, null, null, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, DS.draggable!=null?DS.draggable:true, null, null, DS.close!=null?DS.close:true, null, null, DS.fullSize!=null?DS.fullSize:false, null, DS.resizeHandle!=null?DS.resizeHandle:false, collapse, collapseColor, collapsed, null, null, style, group, zim.copy(DS));
41833
+ // width, height, content, backgroundColor, borderColor, borderWidth, padding, corner, swipe, scrollBarActive, scrollBarDrag, scrollBarColor, scrollBarAlpha, scrollBarFade, scrollBarH, scrollBarV, slide, slideFactor, slideSnap, slideSnapDamp, interactive, shadowColor, shadowBlur, paddingH, paddingV, scrollWheel, damp, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, draggable, boundary, onTop, close, closeColor, cancelCurrentDrag, fullSize, fullSizeColor, resizeHandle, collapse, collapseColor, collapsed, optimize, resizeBoundary, resizeVisible, continuous, style, group, inherit
41834
+ this.zimWindow_constructor(width, height, null, backgroundColor, null, DS.borderWidth!=null?DS.borderWidth:2, DS.padding!=null?DS.padding:10, DS.corner!=null?DS.corner:10, null, DS.scrollBarActive!=null?DS.scrollBarActive:true, DS.scrollBarDrag!=null?DS.scrollBarDrag:true, null, null, null, false, null, null, null, null, null, true, null, null, null, null, null, null, titleBar, titleBarColor, titleBarBackgroundColor, titleBarHeight, DS.draggable!=null?DS.draggable:true, null, null, DS.close!=null?DS.close:true, null, null, DS.fullSize!=null?DS.fullSize:false, null, DS.resizeHandle!=null?DS.resizeHandle:false, collapse, collapseColor, collapsed, null, null, null, null, style, group, zim.copy(DS));
40343
41835
  this.type = "EmojiPicker";
40344
41836
  var that = this;
40345
41837
 
@@ -45382,7 +46874,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45382
46874
  if (accept) uploadTag.setAttribute("accept", accept);
45383
46875
  uploadTag.hidden = true;
45384
46876
  uploadTag.zimDisplay = uploadTag.style.display || "inline-block";
45385
- uploadTag.style.cssText = "border:thin solid grey; z-index:2; width:" + width + "px; height:" + height + "px; overflow:hidden; outline:none;"
46877
+ uploadTag.style.cssText = "border:thin solid grey; z-index:2; width:" + 0 + "px; height:" + 0 + "px; overflow:hidden; outline:none;"
45386
46878
  + "position:absolute; left:0px; top:0px; display:none; cursor:pointer; opacity: 0; filter: alpha(opacity=0);";
45387
46879
 
45388
46880
  this.addEventListener('mousedown', function() { // added for zim.Accessibility
@@ -45975,19 +47467,48 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45975
47467
  }
45976
47468
  var lastText = that.text;
45977
47469
  var sYO = that.y;
47470
+ var lastHeight;
47471
+ that.taBlur = function() {
47472
+ if (WW.M && keyboardShift) {
47473
+ if (that.stage) {
47474
+ if (that.re) that.stage.frame.off("resize", that.re);
47475
+ that.stage.y = sYO;
47476
+ textareaTag.blur();
47477
+ that.resize();
47478
+ that.stage.update();
47479
+ }
47480
+ }
47481
+ if (that.stage) frame = that.stage.frame;
47482
+ if (frame.zil) WW.addEventListener("keydown", frame.zil[0]);
47483
+ that.dispatchEvent("blur");
47484
+ if (that.text != lastText) that.dispatchEvent("change");
47485
+ }
47486
+ function vvp() {
47487
+ if (M && !zot(lastHeight) && WW.visualViewport.height > lastHeight) {
47488
+ that.taBlur();
47489
+ WW.visualViewport.removeEventListener('resize', vvp);
47490
+ }
47491
+ lastHeight = WW.visualViewport.height;
47492
+ }
45978
47493
  that.taFocus = function() {
45979
- lastText = that.text;
47494
+ lastText = that.text;
45980
47495
  if (WW.M && keyboardShift) {
45981
47496
  if (that.re) that.stage.frame.off("resize", that.re);
45982
47497
  that.re = that.stage.frame.on("resize", function(){
45983
47498
  if (that.stage && h>that.stage.height/4) {
45984
47499
  that.stage.y = that.stage.scaleY*(that.stage.height/4-h);
47500
+ that.resize();
45985
47501
  that.stage.update();
45986
47502
  }
45987
- });
47503
+ });
47504
+ if (WW.visualViewport) {
47505
+ WW.visualViewport.removeEventListener('resize', vvp);
47506
+ WW.visualViewport.addEventListener('resize', vvp);
47507
+ }
45988
47508
  var h = that.localToGlobal(0,0).y;
45989
47509
  if (that.stage && h>that.stage.height/4) {
45990
47510
  that.stage.y = that.stage.scaleY*(that.stage.height/4-h);
47511
+ that.resize();
45991
47512
  that.stage.update();
45992
47513
  }
45993
47514
  }
@@ -45995,19 +47516,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
45995
47516
  if (frame.zil) WW.removeEventListener("keydown", frame.zil[0]);
45996
47517
  that.dispatchEvent("focus");
45997
47518
  }
45998
- that.taBlur = function() {
45999
- if (WW.M && keyboardShift) {
46000
- if (that.stage) {
46001
- if (that.re) that.stage.frame.off("resize", that.re);
46002
- that.stage.y = sYO;
46003
- that.stage.update();
46004
- }
46005
- }
46006
- if (that.stage) frame = that.stage.frame;
46007
- if (frame.zil) WW.addEventListener("keydown", frame.zil[0]);
46008
- that.dispatchEvent("blur");
46009
- if (that.text != lastText) that.dispatchEvent("change");
46010
- }
47519
+
46011
47520
  textareaTag.addEventListener('input', that.taInput);
46012
47521
  textareaTag.addEventListener('focus', that.taFocus);
46013
47522
  textareaTag.addEventListener('blur', that.taBlur);
@@ -46041,13 +47550,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
46041
47550
  var displayProps = that.getConcatenatedMatrix().decompose();
46042
47551
  var point = that.localToGlobal(padding, padding);
46043
47552
  if (frame.retina) {
46044
- var sc = zim.browserZoom();
47553
+ var sc = zim.browserZoom();
46045
47554
  if (frame.tag) {
46046
47555
  textarea.x = point.x/pRatio/sc;
46047
47556
  textarea.y = point.y/pRatio/sc;
46048
47557
  } else {
46049
- textarea.x = frame.x/stage.scaleX + point.x/pRatio/sc;
46050
- textarea.y = frame.y/stage.scaleY + point.y/pRatio/sc;
47558
+ var shiftX = (stage.x-stage.x/pRatio/sc)/frame.scale;
47559
+ var shiftY = (stage.y-stage.y/pRatio/sc)/frame.scale;
47560
+ textarea.x = frame.x/stage.scaleX + point.x/pRatio/sc - shiftX;
47561
+ textarea.y = frame.y/stage.scaleY + point.y/pRatio/sc - shiftY;
46051
47562
  }
46052
47563
  // CreateJS DOMElement is scaling tag as stage scales
46053
47564
  zim.sca(textarea, displayProps.scaleX/pRatio/stage.scaleX/sc, displayProps.scaleY/pRatio/stage.scaleY/sc);
@@ -50546,7 +52057,7 @@ RETURNS obj for chaining
50546
52057
  };//-33.18
50547
52058
 
50548
52059
  /*--
50549
- obj.transform = function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container)
52060
+ obj.transform = function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY)
50550
52061
 
50551
52062
  transform
50552
52063
  zim DisplayObject method
@@ -50639,6 +52150,12 @@ container (default stage) - set to a container to keep transforms within that co
50639
52150
  normally leave as default so transforms will stay above other objects
50640
52151
  but on occasion such as when using with ZIM TextureActives, a container is required
50641
52152
  as the container is cached and used on a texture
52153
+ minScaleX (default null) - set a min scale in the x for the transform
52154
+ maxScaleX (default null) - set a max scale in the x for the transform
52155
+ minScaleY (default null) - set a min scale in the y for the transform
52156
+ maxScaleY (default null) - set a max scale in the y for the transform
52157
+ sliceX (default true) - this is for transforming ScaledBitmap objects in x - to use slicesWidth on edges. Set to false to use width.
52158
+ sliceY (default true) - this is for transforming ScaledBitmap objects in y - to use slicesWidth on edges. Set to false to use width.
50642
52159
 
50643
52160
  PROPERTIES
50644
52161
  toggled - adds a read-only Boolean to the object that is true if controls are showing otherwise false
@@ -50698,8 +52215,8 @@ If TransformManager() is used there are more events available such as "persistse
50698
52215
 
50699
52216
  RETURNS obj for chaining
50700
52217
  --*///+33.5
50701
- zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container) {
50702
- var sig = "obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container";
52218
+ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY) {
52219
+ var sig = "obj, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY";
50703
52220
  var duo; if (duo = zob(zim.transform, arguments, sig)) return duo;
50704
52221
  if (obj.type=="AC"&&WW.zdf) {WW.zdf.ac("transform", arguments); return obj;}
50705
52222
  z_d("33.5");
@@ -50745,6 +52262,14 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
50745
52262
  if (zot(events)) events = false;
50746
52263
  if (obj.type == "Tag" || obj.type == "TextArea" || obj.type == "Loader") events = true;
50747
52264
 
52265
+ if (zot(minScaleX)) minScaleX = -Number.MAX_VALUE;
52266
+ if (zot(maxScaleX)) maxScaleX = Number.MAX_VALUE;
52267
+ if (zot(minScaleY)) minScaleY = -Number.MAX_VALUE;
52268
+ if (zot(maxScaleY)) maxScaleY = Number.MAX_VALUE;
52269
+
52270
+ if (zot(sliceX)) sliceX = true;
52271
+ if (zot(sliceY)) sliceY = true;
52272
+
50748
52273
  obj.zimMCO = obj.mouseChildren;
50749
52274
  obj.mouseChildren = false;
50750
52275
  var con = obj.getConcatenatedMatrix().decompose();
@@ -51034,6 +52559,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51034
52559
  if (frame.ctrlKey && obj.transformControls.visible) {
51035
52560
  obj.scaleX = 1;
51036
52561
  obj.scaleY = 1;
52562
+ if (obj.type=="SlicedBitmap") {
52563
+ if (sliceX) obj.slicesScaleX = 1;
52564
+ if (sliceY) obj.slicesScaleY = 1;
52565
+ }
51037
52566
  obj.rotation = 0;
51038
52567
  // if (customCursors) moveCursor.rot(obj.rotation);
51039
52568
  makeControls();
@@ -51090,6 +52619,8 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51090
52619
  var startY; // target start y
51091
52620
  var startSX;
51092
52621
  var startSY;
52622
+ var startSSX; // for SlicedBitmap
52623
+ var startSSY;
51093
52624
  var startR; // rotation of object to start
51094
52625
  var startAngle; // angle of mouse down to x axis
51095
52626
  var diffX;
@@ -51212,6 +52743,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51212
52743
  objStartY = obj.y;
51213
52744
  startSX = obj.scaleX;
51214
52745
  startSY = obj.scaleY;
52746
+ if (obj.type=="SlicedBitmap") {
52747
+ startSSX = obj.slicesScaleX;
52748
+ startSSY = obj.slicesScaleY;
52749
+ }
51215
52750
  var pp = container.globalToLocal(e.stageX/zim.scaX, e.stageY/zim.scaY);
51216
52751
  if (e.target.controlType == "rotate") {
51217
52752
  rotateCheck = true;
@@ -51264,11 +52799,13 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51264
52799
  }
51265
52800
 
51266
52801
  if (e.target.controlType == "corner") {
51267
- obj.scaleX = scale * startSX;
51268
- obj.scaleY = scale * startSY;
52802
+ obj.scaleX = zim.constrain(scale * startSX, minScaleX, maxScaleX);
52803
+ obj.scaleY = zim.constrain(scale * startSY, minScaleY, maxScaleY);
51269
52804
  } else {
51270
- obj.scaleX = (e.target.cu == "e-resize") ? scale * startSX : startSX;
51271
- obj.scaleY = (e.target.cu == "n-resize") ? scale * startSY : startSY;
52805
+ if (obj.type != "SlicedBitmap" || !sliceX) obj.scaleX = zim.constrain((e.target.cu == "e-resize") ? scale * startSX : startSX, minScaleX, maxScaleX);
52806
+ else obj.ssX = zim.constrain((e.target.cu == "e-resize") ? scale * startSSX : startSSX, minScaleX, maxScaleX);
52807
+ if (obj.type != "SlicedBitmap" || !sliceY) obj.scaleY = zim.constrain((e.target.cu == "n-resize") ? scale * startSY : startSY, minScaleY, maxScaleY);
52808
+ else obj.ssY = zim.constrain((e.target.cu == "n-resize") ? scale * startSSY : startSSY, minScaleY, maxScaleY);
51272
52809
  }
51273
52810
  makeControls();
51274
52811
  var pp = container.globalToLocal(e.stageX/zim.scaX, e.stageY/zim.scaY);
@@ -51343,7 +52880,12 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51343
52880
  }
51344
52881
  if (cursors) tCheck = squares.hitTestPoint(pp.x, pp.y);
51345
52882
  } else if (type == "side") {
51346
- if (obj.scaleX != startProperties.scaleX || obj.scaleY != startProperties.scaleY) {
52883
+ if (
52884
+ obj.scaleX != startProperties.scaleX ||
52885
+ obj.scaleY != startProperties.scaleY ||
52886
+ (sliceX && obj.type=="SlicedBitmap" && obj.slicesScaleX != startProperties.slicesScaleX) ||
52887
+ (sliceY && obj.type=="SlicedBitmap" && obj.slicesScaleY != startProperties.slicesScaleY)
52888
+ ) {
51347
52889
  transformEvent = new createjs.Event("transformed");
51348
52890
  transformEvent.transformType = "stretch";
51349
52891
  }
@@ -51573,6 +53115,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51573
53115
 
51574
53116
  function getStartProperies() {
51575
53117
  startProperties = {x:obj.x, y:obj.y, rotation:obj.rotation, regX:obj.regX, regY:obj.regY, scaleX:obj.scaleX, scaleY:obj.scaleY};
53118
+ if (obj.type=="SlicedBitmap") {
53119
+ if (sliceX) startProperties.slicesScaleX = obj.slicesScaleX;
53120
+ if (sliceY) startProperties.slicesScaleY = obj.slicesScaleY;
53121
+ }
51576
53122
  }
51577
53123
  var startProperties;
51578
53124
  getStartProperies();
@@ -51710,6 +53256,10 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51710
53256
  regY:obj.regY,
51711
53257
  controls:obj.transformControls.visible
51712
53258
  };
53259
+ if (obj.type=="SlicedBitmap") {
53260
+ if (sliceX) data.slicesScaleX = obj.slicesScaleX;
53261
+ if (sliceY) data.slicesScaleY = obj.slicesScaleY;
53262
+ }
51713
53263
  return toJSON ? JSON.stringify(data) : data;
51714
53264
  },
51715
53265
  setData:function(data, fromJSON) {
@@ -51770,7 +53320,7 @@ zim.transform = function(obj, move, stretchX, stretchY, scale, rotate, allowTogg
51770
53320
  makeControls();
51771
53321
  drawDragger();
51772
53322
  setRotators();
51773
- if (visible) obj.transformControls.show(); // bring on top
53323
+ if (obj.transformControls.visible) obj.transformControls.show(); // bring on top
51774
53324
  if (dispatch) {
51775
53325
  var transformEvent = new createjs.Event("transformed");
51776
53326
  transformEvent.pressup = true;
@@ -54189,6 +55739,11 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
54189
55739
  }
54190
55740
  sequenceTarget = target;
54191
55741
  target = newTarget;
55742
+ sequenceTarget.animating = true;
55743
+ }
55744
+ function sequenceDone() {
55745
+ sequenceTarget.animating = false;
55746
+ if (call) call(params||sequenceTarget);
54192
55747
  }
54193
55748
 
54194
55749
  // PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
@@ -54232,8 +55787,10 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
54232
55787
  rrr = rate + (tar.ratio?tar.ratio:0);
54233
55788
  }
54234
55789
  var seqTime = i*sequence;
54235
- if (i==0 && sequence!=0) seqTime = timeType=="s"?.02:20; // patched in 10.7.0 and 10.7.1
54236
- zim.animate(tar, tar.zimObj, time, ease, (i==target.length-1?call:null), (i==target.length-1?params:null), wait, waitedCall, waitedParams, null, null, null, null, null, null, null, loopPick, null, null, null, null, null, null, rewindTime, rewindEase, startCall, startParams, animateCall, animateParams, null, sequenceCall, sequenceParams, null, null, ticker, zim.copy(cjsProps), css, protect, override, null, set, id, events, sequenceTarget, dynamic, drag, clamp, startPaused, clean, obj, seriesWait, seqTime, rrr, pauseOnBlur, easeAmount, easeFrequency, timeUnit, timeCheck, noAnimateCall, pathDamp); // do not send from!
55790
+ if (i==0 && sequence!=0) seqTime = timeType=="s"?.02:20; // patched in 10.7.0 and 10.7.1
55791
+
55792
+ // zim.animate(tar, tar.zimObj, time, ease, (i==target.length-1?call:null), (i==target.length-1?params:null)
55793
+ zim.animate(tar, tar.zimObj, time, ease, (i==target.length-1?sequenceDone:null), null, wait, waitedCall, waitedParams, null, null, null, null, null, null, null, loopPick, null, null, null, null, null, null, rewindTime, rewindEase, startCall, startParams, animateCall, animateParams, null, sequenceCall, sequenceParams, null, null, ticker, zim.copy(cjsProps), css, protect, override, null, set, id, events, sequenceTarget, dynamic, drag, clamp, startPaused, clean, obj, seriesWait, seqTime, rrr, pauseOnBlur, easeAmount, easeFrequency, timeUnit, timeCheck, noAnimateCall, pathDamp); // do not send from!
54237
55794
 
54238
55795
  }
54239
55796
  return sequenceTarget;
@@ -54645,7 +56202,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
54645
56202
  if (typeof target.zimLastObj[o] == "string" && o != "transform") {
54646
56203
  target.zimLastObj[o] = target[o] + Number(target.zimLastObj[o].replace(/\s/g,""));
54647
56204
  }
54648
- setValue(target, o, target.zimLastObj[o]);
56205
+ setValue(target, o, target.zimLastObj[o]);
54649
56206
  });
54650
56207
  // zim.loop(obj, function (o) {
54651
56208
  // if (typeof obj[o] == "string") {
@@ -54770,6 +56327,22 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
54770
56327
  }
54771
56328
  }
54772
56329
 
56330
+
56331
+ // moved these to before protect (to catch scale convert) - ZIM Cat
56332
+ // PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
56333
+ // moved to before color code - ZIM 017
56334
+ var savedPicks = {};
56335
+ for (i in obj) {
56336
+ // zogb(i)
56337
+ if (extraTypes.indexOf(i) >= 0) continue; // skip for extras
56338
+ savedPicks[i] = zim.copy(obj[i]); // store pre picked to use if loopPick is true
56339
+ obj[i] = zim.Pick.choose(obj[i], null, target);
56340
+ }
56341
+ if (!zot(obj.scale)) {
56342
+ obj.scaleX = obj.scaleY = zim.Pick.choose(obj.scale, null, target);
56343
+ delete obj.scale;
56344
+ }
56345
+
54773
56346
  // convert color tween - added protect for colorRange in ZIM 016
54774
56347
  var colorBusy = target.zimBusy && target.zimBusy.colorRange;
54775
56348
  if (!colorBusy) {
@@ -54822,19 +56395,6 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
54822
56395
  }
54823
56396
 
54824
56397
 
54825
- // moved these to before protect (to catch scale convert) - ZIM Cat
54826
- // PREPARE ZIK RANDOM VALUES PASSED IN AS ARRAY OR RAND OBJECT {min, max, integer, negative}
54827
- var savedPicks = {};
54828
- for (i in obj) {
54829
- // zogb(i)
54830
- if (extraTypes.indexOf(i) >= 0) continue; // skip for extras
54831
- savedPicks[i] = zim.copy(obj[i]); // store pre picked to use if loopPick is true
54832
- obj[i] = zim.Pick.choose(obj[i], null, target);
54833
- }
54834
- if (!zot(obj.scale)) {
54835
- obj.scaleX = obj.scaleY = zim.Pick.choose(obj.scale, null, target);
54836
- delete obj.scale;
54837
- }
54838
56398
 
54839
56399
 
54840
56400
  // PROTECT LOOPS AND REWINDS WITH BUSY
@@ -56265,18 +57825,24 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
56265
57825
  return;
56266
57826
  } else {
56267
57827
  if (rewind) {
56268
- if (target.set) target.set(startObj);
57828
+ if (target.set) target.set(startObj);
56269
57829
  } else {
56270
57830
  if (target.set) target.set(obj);
56271
57831
  }
56272
57832
  }
56273
- } else {
57833
+ } else {
56274
57834
  if (wait3>0) target.waiting = true;
56275
57835
  doLoopWaitCall();
56276
57836
  return;
56277
57837
  }
56278
- }
56279
-
57838
+ } else {
57839
+ if (rewind) {
57840
+ if (target.set) target.set(startObj);
57841
+ } else {
57842
+ if (target.set) target.set(obj);
57843
+ }
57844
+ }
57845
+
56280
57846
  // ZIM 015 - this was the first thing we tried to scrub a series with percentComplete
56281
57847
  // there were lots of other things too to make it work.
56282
57848
  // Leaving the seriesTween test in here... but probably not doing much
@@ -56299,7 +57865,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
56299
57865
 
56300
57866
  function getStart() {
56301
57867
  // for rewind, we need to know the start value
56302
- // which could be modified by the set parameter
57868
+ // which could be modified by the set parameter
56303
57869
  for (var i in obj) {
56304
57870
  if (css && target.style) {
56305
57871
  if (!zot(set[i]) && !from) {
@@ -56310,7 +57876,6 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
56310
57876
  }
56311
57877
  } else {
56312
57878
  if (!zot(set[i]) && !from) {
56313
- // !!!!!! maybe fix for dot plugin
56314
57879
  startObj[i] = set[i];
56315
57880
  } else {
56316
57881
  if (i.substr(0,1) == ".") {
@@ -60774,13 +62339,20 @@ EXAMPLE
60774
62339
  new Arrow({type:"thick"}).pos(30,30,RIGHT,BOTTOM).tap(next);
60775
62340
  END EXAMPLE
60776
62341
 
60777
- EXAMPLE
60778
- // Assuming a pages variable that points to a ZIM Pages object
60779
- // These will go through the pages in order
60780
- // and default to remove themselves if not needed at start or end
60781
-
60782
- new Arrow(blue, green, pages, RIGHT).pos(30,30,RIGHT,BOTTOM);
60783
- new Arrow(blue, green, pages, LEFT).pos(30,30,LEFT,BOTTOM);
62342
+ EXAMPLE
62343
+ const page2 = new Page(W,H,orange);
62344
+ const page3 = new Page(W,H,yellow);
62345
+ const pages = new Pages([page1,page2,page3], "slide").addTo();
62346
+
62347
+ const left = new Arrow({
62348
+ pages:pages,
62349
+ direction:LEFT
62350
+ }).rot(180).pos(50,50,LEFT,BOTTOM);
62351
+
62352
+ const right = new Arrow({
62353
+ pages:pages,
62354
+ direction:RIGHT
62355
+ }).pos(50,50,RIGHT,BOTTOM);
60784
62356
  END EXAMPLE
60785
62357
 
60786
62358
  PARAMETERS supports DUO - parameters or single object with properties below
@@ -62243,10 +63815,13 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
62243
63815
  return that;
62244
63816
  };
62245
63817
  this.remove = function(obj) {
62246
- if (!Array.isArray(obj)) obj = [obj];
62247
- zim.loop(obj, function(o) {
62248
- if (o && o.removeFrom) o.removeFrom();
62249
- }, true);
63818
+ if (zot(obj)) that.removeAllChildren();
63819
+ else {
63820
+ if (!Array.isArray(obj)) obj = [obj];
63821
+ zim.loop(obj, function(o) {
63822
+ if (o && o.removeFrom) o.removeFrom();
63823
+ }, true);
63824
+ }
62250
63825
  that.resize();
62251
63826
  return that;
62252
63827
  };
@@ -63120,7 +64695,7 @@ current2DCols ** - read only array the current order of columns each containing
63120
64695
  tileNum - this property is added to each object in the tile to give its number in the tile
63121
64696
  tileCol - this property is added to each object in the tile to give its column number in the tile
63122
64697
  tileRow - this property is added to each object in the tile to give its row number in the tile
63123
- backgrounds - an array of ZIM Rectangle objects set by the backdroundColor parameter
64698
+ backgrounds - an array of ZIM Rectangle objects set by the backgroundColor parameter
63124
64699
  backings - an array of DisplayObjects set by the backing parameter
63125
64700
  backdrop - a ZIM Rectangle set by the backdropColor parameter
63126
64701
  mat - a DisplayObject set by the mat parameter
@@ -70666,32 +72241,35 @@ new MotionController({
70666
72241
  END EXAMPLE
70667
72242
 
70668
72243
  EXAMPLE
70669
- const background = new Pic("background.png").addTo(); // assuming loaded in Frame
70670
- const ball = new Circle().centerReg();
70671
- const scroller = new Scroller(background);
70672
- const accelerator = new Accelerator(scroller);
70673
-
70674
- // control speed of Accelerator with MotionController
70675
- new MotionController({
70676
- target:accelerator,
70677
- type:"mousemove", // or "pressmove"
70678
- axis:HORIZONTAL,
70679
- // the Scroller makes two backings - backing1 and backing2
70680
- // allow pressing on both backings and ball to control scroller
70681
- mousedownIncludes:[scroller.backing1, scroller.backing2, ball],
70682
- speed:30,
70683
- minPercentSpeed:-1000,
70684
- maxPercentSpeed:1000,
70685
- boundary:new Boundary(0,0,W,0) // setting a boundary and speed will balance the control
70686
- });
72244
+ F.loadAssets(["beach02.jpg", "playbeachball.png"], "https://zimjs.org/assets/"); // or load in Frame()
72245
+ F.on("complete", ()=>{
72246
+ const background = new Pic("beach02.jpg").scaleTo().center();
72247
+ const ball = new Pic("playbeachball.png").siz(100).centerReg();
72248
+ const scroller = new Scroller(background);
72249
+ const accelerator = new Accelerator(scroller);
72250
+
72251
+ // control speed of Accelerator with MotionController
72252
+ new MotionController({
72253
+ target:accelerator,
72254
+ type:"mousemove", // or "pressmove"
72255
+ axis:HORIZONTAL,
72256
+ // the Scroller makes two backings - backing1 and backing2
72257
+ // allow pressing on both backings and ball to control scroller
72258
+ mousedownIncludes:[scroller.backing1, scroller.backing2, ball],
72259
+ speed:30,
72260
+ minPercentSpeed:-1000,
72261
+ maxPercentSpeed:1000,
72262
+ boundary:new Boundary(0,0,W,0) // setting a boundary and speed will balance the control
72263
+ });
70687
72264
 
70688
- // control position of ball with MotionController
70689
- new MotionController({
70690
- target:ball,
70691
- type:"mousemove",
70692
- // allow press on Scroller backings
70693
- mousedownIncludes:[scroller.backing1, scroller.backing2],
70694
- speed:10
72265
+ // control position of ball with MotionController
72266
+ new MotionController({
72267
+ target:ball,
72268
+ type:"mousemove",
72269
+ // allow press on Scroller backings
72270
+ mousedownIncludes:[scroller.backing1, scroller.backing2],
72271
+ speed:10
72272
+ });
70695
72273
  });
70696
72274
  END EXAMPLE
70697
72275
 
@@ -73390,6 +74968,7 @@ veeObj - an object with ZIM VEE original parameters:value allowing the ZIM VEE v
73390
74968
 
73391
74969
  blurX = zik(blurX); // inherits these properties
73392
74970
  blurY = zik(blurY);
74971
+ if (blurX === 0 && blurY === 0) blurX = 1;
73393
74972
  quality = zik(quality);
73394
74973
 
73395
74974
  color = zik(color); // will convert after setting color getter setter
@@ -76295,19 +77874,18 @@ and animate and swap the backgrounds when needed.
76295
77874
 
76296
77875
  NOTE: A scroller can be added to a Accelerator object
76297
77876
  this will allow the percentSpeed to be synched with other Scroller and Dynamo objects
76298
- See https://zimjs.com/zide/
76299
- See https://zimjs.com/explore/sidescroller.html (with keys)
77877
+ See https://zimjs.com/zide/ - full scene
77878
+ See https://zimjs.com/zapp/E_EPRSP - Flinstones
77879
+ See https://zimjs.com/zapp/Z_6EEB5 - beach
77880
+ See https://zimjs.com/zapp/Z_ZCDQN - spaceguy
77881
+ See https://zimjs.com/zapp/Z_UC7DN - keyboard
76300
77882
 
76301
77883
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
76302
77884
 
76303
77885
  EXAMPLE
76304
- const one = new Rectangle(1200, 400, red);
77886
+ const one = new Rectangle(1100, 400, red).center();
76305
77887
  F.makeCircles().center(one);
76306
- S.addChild(one);
76307
-
76308
- const scroller = new Scroller(one);
76309
-
76310
- S.update();
77888
+ const scroller = new Scroller(one,20);
76311
77889
  END EXAMPLE
76312
77890
 
76313
77891
  PARAMETERS
@@ -88415,9 +89993,9 @@ function zimify(obj, a, b, c, d, list) {
88415
89993
  dragRect:function(boundary) {
88416
89994
  return zim.dragBoundary(this, boundary);
88417
89995
  },
88418
- transform:function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container) {
89996
+ transform:function(move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY) {
88419
89997
  if (isDUO(arguments)) {arguments[0].obj = this; return zim.transform(arguments[0]);}
88420
- else {return zim.transform(this, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container);}
89998
+ else {return zim.transform(this, move, stretchX, stretchY, scale, rotate, allowToggle, visible, onTop, showStretch, showRotate, showScale, showReg, showBorder, borderColor, borderWidth, dashed, customCursors, handleSize, regSize, snapDistance, snapRotation, cache, events, ghostColor, ghostWidth, ghostDashed, ghostHidden, frame, container, minScaleX, maxScaleX, minScaleY, maxScaleY, sliceX, sliceY);}
88421
89999
  },
88422
90000
  setSwipe:function(swipe) {
88423
90001
  return zim.setSwipe(this, swipe);
@@ -93724,16 +95302,16 @@ for (z_i = 0; z_i < globalFunctions.length; z_i++) {
93724
95302
  ["RAD", zim.RAD],
93725
95303
  ["PHI", zim.PHI],
93726
95304
  ["IGNORE", zim.ignore]
93727
- ];
93728
-
93729
- for (z_i = 0; z_i < globalsConstants.length; z_i++) {
95305
+ ];
95306
+
95307
+ for (z_i = 0; z_i < globalsConstants.length; z_i++) {
93730
95308
  var pair = globalsConstants[z_i];
93731
95309
  WW[pair[0]] = pair[1];
93732
- }
93733
-
93734
- for (z_i = 0; z_i < zim.colors.length; z_i++) {
95310
+ }
95311
+
95312
+ for (z_i = 0; z_i < zim.colors.length; z_i++) {
93735
95313
  WW[zim.colors[z_i]] = zim.colorsHex[z_i];
93736
- }
95314
+ }
93737
95315
 
93738
95316
 
93739
95317
  WW.zim = zim;
@@ -93837,6 +95415,7 @@ export let StageGL = zim.StageGL;
93837
95415
  export let Container = zim.Container;
93838
95416
  export let Shape = zim.Shape;
93839
95417
  export let Bitmap = zim.Bitmap;
95418
+ export let SlicedBitmap = zim.SlicedBitmap;
93840
95419
  export let Sprite = zim.Sprite;
93841
95420
  export let MovieClip = zim.MovieClip;
93842
95421
  export let SVGContainer = zim.SVGContainer;
@@ -93881,6 +95460,8 @@ export let List = zim.List;
93881
95460
  export let Stepper = zim.Stepper;
93882
95461
  export let Slider = zim.Slider;
93883
95462
  export let Selector = zim.Selector;
95463
+ export let Slicer = zim.Slicer;
95464
+ export let SlicerTypes = zim.SlicerTypes;
93884
95465
  export let Dial = zim.Dial;
93885
95466
  export let Tabs = zim.Tabs;
93886
95467
  export let Pad = zim.Pad;