rsence-pre 2.3.0.2 → 2.3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/js/foundation/control/eventresponder/eventresponder.js +4 -4
- data/js/foundation/locale_settings/locale_settings.js +67 -0
- data/js/tables/table/table.coffee +235 -17
- data/js/tables/table/themes/default/table.css +25 -0
- data/js/tables/table/themes/default/table.html +2 -19
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.0.
|
1
|
+
2.3.0.3.pre
|
@@ -774,18 +774,18 @@ HEventResponder = HClass.extend({
|
|
774
774
|
**/
|
775
775
|
selected: false,
|
776
776
|
select: function(){
|
777
|
-
|
778
|
-
console.warn("HControl#select not supported yet.");
|
777
|
+
// console.warn("HControl#select not supported yet.");
|
779
778
|
},
|
780
779
|
deSelect: function(){
|
781
|
-
|
782
|
-
console.warn("HControl#deSelect not supported yet.");
|
780
|
+
// console.warn("HControl#deSelect not supported yet.");
|
783
781
|
},
|
784
782
|
setSelected: function(_state){
|
785
783
|
if( _state ){
|
784
|
+
this.selected = true;
|
786
785
|
this.select();
|
787
786
|
}
|
788
787
|
else {
|
788
|
+
this.selected = false;
|
789
789
|
this.deSelect();
|
790
790
|
}
|
791
791
|
}
|
@@ -10,6 +10,73 @@ var
|
|
10
10
|
HLocale = {
|
11
11
|
components: {
|
12
12
|
|
13
|
+
},
|
14
|
+
compUnits: {
|
15
|
+
strings: {
|
16
|
+
bit: ' b',
|
17
|
+
'byte': ' B',
|
18
|
+
kilobyte: ' kB',
|
19
|
+
kibibyte: ' KiB',
|
20
|
+
megabyte: ' MB',
|
21
|
+
mebibyte: ' MiB',
|
22
|
+
gigabyte: ' GB',
|
23
|
+
gibibyte: ' GiB',
|
24
|
+
terabyte: ' TB',
|
25
|
+
tebibyte: ' TiB',
|
26
|
+
petabyte: ' PB',
|
27
|
+
pebibyte: ' PiB'//,
|
28
|
+
// exabyte: ' EB',
|
29
|
+
// ebibyte: ' EiB',
|
30
|
+
// zettabyte: ' ZB',
|
31
|
+
// zebibyte: ' ZiB',
|
32
|
+
// yottabyte: ' YB',
|
33
|
+
// yobibyte: ' YiB'
|
34
|
+
},
|
35
|
+
units: {
|
36
|
+
SI: [
|
37
|
+
[ 1000, 'byte' ],
|
38
|
+
[ 1000000, 'kilobyte' ],
|
39
|
+
[ 1000000000, 'megabyte' ],
|
40
|
+
[ 1000000000000, 'gigabyte' ],
|
41
|
+
[ 1000000000000000, 'terabyte' ],
|
42
|
+
[ 1000000000000000000, 'petabyte' ]
|
43
|
+
],
|
44
|
+
IEC: [
|
45
|
+
[ 1024, 'byte' ],
|
46
|
+
[ 1048576, 'kibibyte' ],
|
47
|
+
[ 1073741824, 'mebibyte' ],
|
48
|
+
[ 1099511627776, 'gibibyte' ],
|
49
|
+
[ 1125899906842624, 'tebibyte' ],
|
50
|
+
[ 1152921504606846976, 'pebibyte' ]
|
51
|
+
]
|
52
|
+
},
|
53
|
+
defaultUnitSystem: 'SI',
|
54
|
+
formatBytes: function( _value, _decimals, _unitSystem ){
|
55
|
+
var _this = HLocale.compUnits;
|
56
|
+
if(!_decimals){ _decimals = 0; }
|
57
|
+
if(!_unitSystem){ _unitSystem = _this.defaultUnitSystem; }
|
58
|
+
var
|
59
|
+
_strings = _this.strings,
|
60
|
+
_decMul = Math.pow(10,_decimals),
|
61
|
+
_conv = _this.units[_unitSystem],
|
62
|
+
i = 0,
|
63
|
+
_lim, _div=1, _num, _suffix;
|
64
|
+
for( ; i < _conv.length; i++ ){
|
65
|
+
_lim = _conv[i][0];
|
66
|
+
_suffix = _strings[_conv[i][1]];
|
67
|
+
if( _value < _lim ){
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
_div = _lim;
|
71
|
+
}
|
72
|
+
if( i && _decimals ){
|
73
|
+
_num = Math.round((_value*_decMul)/_div)/_decMul;
|
74
|
+
}
|
75
|
+
else {
|
76
|
+
_num = Math.round(_value/_div);
|
77
|
+
}
|
78
|
+
return _num+_suffix;
|
79
|
+
}
|
13
80
|
},
|
14
81
|
dateTime: {
|
15
82
|
strings: {
|
@@ -1,19 +1,237 @@
|
|
1
|
-
HTable = HControl.extend
|
1
|
+
HTable = HControl.extend
|
2
2
|
componentName: 'table'
|
3
|
-
markupElemNames: ['
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@
|
3
|
+
markupElemNames: [ 'header', 'subview' ]
|
4
|
+
defaultEvents:
|
5
|
+
resize: true
|
6
|
+
controlDefaults: HControlDefaults.extend
|
7
|
+
tableType: 'rows'
|
8
|
+
constructor: (_opt)->
|
9
|
+
@headerCols = false unless @headerCols?
|
10
|
+
@sortDescending = [] unless @sortDescending?
|
11
|
+
@colWidths = [] unless @colWidths?
|
12
|
+
@colOptions = {} unless @colOptions?
|
13
|
+
sortCol: 0
|
14
|
+
_destroyHeader: ->
|
15
|
+
if @headerCols?
|
16
|
+
_table = @
|
17
|
+
for _elemId, i in @headerCols
|
18
|
+
Event.stopObserving(ELEM.get(_elemId),'click',@sortFns[i])
|
19
|
+
ELEM.del(_elemId)
|
20
|
+
delete @headerCols
|
21
|
+
delete @headerSizes
|
22
|
+
delete @sortFns
|
23
|
+
sortByCol: (_col)->
|
24
|
+
if @options.sortCol == _col
|
25
|
+
if @options.sortDescending[_col]?
|
26
|
+
@options.sortDescending[_col] = !@options.sortDescending[_col]
|
27
|
+
else
|
28
|
+
@options.sortDescending[_col] = false
|
29
|
+
else
|
30
|
+
@options.sortCol = _col
|
31
|
+
@drawHeader()
|
32
|
+
@refreshTable()
|
33
|
+
# if @colViews?
|
34
|
+
# for _size, i in @headerSizes
|
35
|
+
# _colView = @colViews[i]
|
36
|
+
# _colView.rect.setLeft(_size[0])
|
37
|
+
# _colView.rect.setWidth(_size[1])
|
38
|
+
# _colView.drawRect()
|
39
|
+
drawHeader: ->
|
40
|
+
_elemIds = []
|
41
|
+
_sizes = []
|
42
|
+
_autoWidths = []
|
43
|
+
_sortFns = []
|
44
|
+
_left = 6
|
45
|
+
_table = @
|
46
|
+
for _headerCol, i in @options.headerCols
|
47
|
+
_left += 6
|
48
|
+
_elemId = ELEM.make( @markupElemIds.header, 'div' )
|
49
|
+
@options.sortDescending[i] = false unless @options.sortDescending[i]?
|
50
|
+
ELEM.addClassName(_elemId,'table_header_column')
|
51
|
+
ELEM.flush()
|
52
|
+
if @options.sortCol == i
|
53
|
+
_headerCol += '<div class="sort">'
|
54
|
+
if @options.sortDescending[i]
|
55
|
+
_headerCol += '▼'
|
56
|
+
else
|
57
|
+
_headerCol += '▲'
|
58
|
+
_headerCol += '</div>'
|
59
|
+
_width = -6 #26
|
60
|
+
else
|
61
|
+
_width = -6 #26
|
62
|
+
# ELEM.setStyle(_elemId,'font-weight','normal',true)
|
63
|
+
if @options.colWidths[i]?
|
64
|
+
if @options.colWidths[i] == 'auto'
|
65
|
+
_autoWidths.push(i)
|
66
|
+
else
|
67
|
+
_width += @options.colWidths[i]
|
68
|
+
else
|
69
|
+
_width += @stringWidth(_headerCol, null, _elemId)
|
70
|
+
_sizes.push([_left,_width])
|
71
|
+
ELEM.setAttr(_elemId,'sortcol',i)
|
72
|
+
ELEM.setHTML(_elemId,_headerCol)
|
73
|
+
_sortFns.push((e)->
|
74
|
+
_table.sortByCol(@sortcol)
|
75
|
+
e.preventDefault()
|
76
|
+
true
|
77
|
+
)
|
78
|
+
Event.observe(ELEM.get(_elemId),'click',_sortFns[i])
|
79
|
+
_left += _width
|
80
|
+
_elemIds.push( _elemId )
|
81
|
+
if _autoWidths.length > 0
|
82
|
+
_autoWidth = Math.floor(( @rect.width - _left )/_autoWidths.length)
|
83
|
+
_plusLeft = 0
|
84
|
+
for [_left, _width], i in _sizes
|
85
|
+
_elemId = _elemIds[i]
|
86
|
+
ELEM.setStyle(_elemId,'left',_left+_plusLeft+'px')
|
87
|
+
_sizes[i][0] = _left+_plusLeft
|
88
|
+
if _autoWidths.indexOf(i) != -1
|
89
|
+
_width = _autoWidth - 6
|
90
|
+
# _width += 20 if i == @options.sortCol
|
91
|
+
_sizes[i][1] = _width
|
92
|
+
_plusLeft += _autoWidth
|
93
|
+
ELEM.setStyle(_elemId,'width',_width+'px')
|
94
|
+
@_destroyHeader()
|
95
|
+
ELEM.flush()
|
96
|
+
@headerCols = _elemIds
|
97
|
+
@headerSizes = _sizes
|
98
|
+
@sortFns = _sortFns
|
99
|
+
resize: ->
|
100
|
+
@drawHeader()
|
101
|
+
for _colNum in [0..@headerCols.length-1]
|
102
|
+
_left = @headerSizes[_colNum][0]
|
103
|
+
_width = @headerSizes[_colNum][1]
|
104
|
+
@colViews[_colNum].rect.offsetTo( _left, 0 )
|
105
|
+
@colViews[_colNum].rect.setWidth( _width )
|
106
|
+
@colViews[_colNum].drawRect()
|
107
|
+
drawSubviews: ->
|
108
|
+
if @options.headerCols
|
109
|
+
@drawHeader()
|
110
|
+
else
|
111
|
+
@setStyleOfPart('body','top',0)
|
112
|
+
_findClassInNameSpace: (_className)->
|
113
|
+
if typeof _className == 'function' and _className.hasAncestor? and _className.hasAncestor( HControl )
|
114
|
+
return _className
|
115
|
+
else if typeof _className == 'string' and window[_className]?
|
116
|
+
return window[_className] # should have more elegant lookup
|
117
|
+
console.warn( 'HTable#'+'_'+'findClassNameInNamespace: No such className => ', _className, ', using default => ',@options.defaultColClass )
|
118
|
+
return @options.defaultColClass
|
119
|
+
_getClassNameAndValueOfCol: (_col, _colNum)->
|
120
|
+
if @options.colOptions[_colNum]?
|
121
|
+
_colOption = @options.colOptions[_colNum]
|
122
|
+
else
|
123
|
+
_colOption = {}
|
124
|
+
if @options.colClasses[_colNum]?
|
125
|
+
_colClass = @options.colClasses[_colNum]
|
126
|
+
if typeof _colClass == 'function' and _colClass.hasAncestor? and _colClass.hasAncestor( HControl )
|
127
|
+
return [ _colClass, _colOption ]
|
128
|
+
else if _colClass instanceof Object and not _colClass.hasAncestor?
|
129
|
+
for _className of _colClass
|
130
|
+
if typeof _className == 'string'
|
131
|
+
return [ @_findClassInNameSpace( _className ), _colClass[_className] ]
|
132
|
+
else if typeof _colClass == 'string'
|
133
|
+
return [ @_findClassInNameSpace( _colClass ), _colOption ]
|
134
|
+
return [ @_findClassInNameSpace( @options.defaultColClass ), _colOption ]
|
135
|
+
_destroyRows: ->
|
136
|
+
for _row, _rowNum in @_rows
|
137
|
+
for _col, _colNum in _row
|
138
|
+
_col.die()
|
139
|
+
_row[_colNum]
|
140
|
+
@_rows = []
|
141
|
+
@_rowsDrawn = false
|
142
|
+
filterRow: (_value)->
|
143
|
+
return false
|
144
|
+
sortTableRows: ->
|
145
|
+
_rowsVisible = 0
|
146
|
+
_col = @options.sortCol
|
147
|
+
_sortDescending = @options.sortDescending
|
148
|
+
_desc = _sortDescending[_col]
|
149
|
+
_rowSort = []
|
150
|
+
for _row, i in @_rows
|
151
|
+
_rowSort.push( [ @value[i], _row ] )
|
152
|
+
_nextCols = []
|
153
|
+
if @options.sortOrder[_col]?
|
154
|
+
if @options.sortOrder[_col] instanceof Array
|
155
|
+
_nextCols = HVM.clone( @options.sortOrder[_col] )
|
156
|
+
else
|
157
|
+
_nextCols = [ @options.sortOrder[_col] ]
|
158
|
+
else
|
159
|
+
_nextCols = []
|
160
|
+
_rowSorter = (_row1, _row2, _col, _nextCols, _desc)->
|
161
|
+
_r1 = _row1[0][_col]
|
162
|
+
_r2 = _row2[0][_col]
|
163
|
+
while _r1 == _r2 and _nextCols.length > 0
|
164
|
+
_nextCol = _nextCols.shift()
|
165
|
+
_desc = _sortDescending[_nextCol]
|
166
|
+
_r1 = _row1[0][_nextCol]
|
167
|
+
_r2 = _row2[0][_nextCol]
|
168
|
+
return 0 if _r1 == _r2
|
169
|
+
if _desc
|
170
|
+
return 1 if _r1 < _r2
|
171
|
+
else
|
172
|
+
return 1 if _r1 > _r2
|
173
|
+
return -1
|
174
|
+
_rowSort.sort( (_row1,_row2)->
|
175
|
+
_rowSorter(_row1, _row2, _col, HVM.clone(_nextCols), _desc)
|
176
|
+
)
|
177
|
+
_top = 0
|
178
|
+
_rowHeight = 24
|
179
|
+
for [ _value, _row ], _rowNum in _rowSort
|
180
|
+
if @filterRow(_value)
|
181
|
+
for _col in _row
|
182
|
+
_col.hide()
|
183
|
+
else
|
184
|
+
_rowsVisible += 1
|
185
|
+
for _col in _row
|
186
|
+
_col.show()
|
187
|
+
_col.rect.offsetTo( 0, _top )
|
188
|
+
_col.drawRect()
|
189
|
+
_top += _rowHeight
|
190
|
+
@_rowsVisible = _rowsVisible
|
191
|
+
refreshTableRows: (_newData)->
|
192
|
+
return unless @headerCols?
|
193
|
+
_top = 0
|
194
|
+
_rowHeight = 24
|
195
|
+
if @colViews?
|
196
|
+
_colViews = @colViews
|
197
|
+
else
|
198
|
+
_colViews = []
|
199
|
+
for _colNum in [0..@headerCols.length-1]
|
200
|
+
_left = @headerSizes[_colNum][0]
|
201
|
+
_width = @headerSizes[_colNum][1]
|
202
|
+
_colViews[_colNum] = HView.nu( [ _left, 0, _width, 1 ], @ )
|
203
|
+
@colViews = _colViews
|
204
|
+
if @_rowsDrawn and not _newData
|
205
|
+
@sortTableRows()
|
206
|
+
else if @_rowsDrawn and _newData and @_rows.length == @value.length
|
207
|
+
for _row, _rowNum in @value
|
208
|
+
for _col, _colNum in _row
|
209
|
+
@_rows[_rowNum][_colNum].setValue( _col )
|
210
|
+
@sortTableRows()
|
211
|
+
else
|
212
|
+
if @_rowsDrawn
|
213
|
+
@_destroyRows()
|
214
|
+
_rows = []
|
215
|
+
for _row, _rowNum in @value
|
216
|
+
_rows[_rowNum] = []
|
217
|
+
for _col, _colNum in _row
|
218
|
+
[ _colClass, _colOpts ] = @_getClassNameAndValueOfCol(_col, _colNum)
|
219
|
+
_colOpts.value = _col
|
220
|
+
_rows[_rowNum][_colNum] = _colClass.nu( [0,_top,null,_rowHeight,0,null], @colViews[_colNum], _colOpts )
|
221
|
+
_top += _rowHeight
|
222
|
+
for _colView in _colViews
|
223
|
+
_colView.rect.setHeight(_top)
|
224
|
+
_colView.drawRect()
|
225
|
+
@_rows = _rows
|
226
|
+
@_rowsDrawn = true
|
227
|
+
@sortTableRows()
|
228
|
+
refreshTableCols: (_newData)->
|
229
|
+
console.warn('HTable#refreshTableCols is not implemented yet!')
|
230
|
+
refreshTable: (_newData)->
|
231
|
+
if @options.tableType == 'rows'
|
232
|
+
@refreshTableRows(_newData)
|
233
|
+
else if @options.tableType == 'cols'
|
234
|
+
@refreshTableCols(_newData)
|
16
235
|
refreshValue: ->
|
17
|
-
|
18
|
-
|
19
|
-
|
236
|
+
if @value instanceof Array
|
237
|
+
@refreshTable( true )
|
@@ -0,0 +1,25 @@
|
|
1
|
+
.default > .table_header {
|
2
|
+
position:absolute;
|
3
|
+
left: 0; top: 0; right: 0; height: 22px;
|
4
|
+
border: 1px solid #333;
|
5
|
+
background: #eee;
|
6
|
+
font-family: Helvetica, Arial, sans-serif;
|
7
|
+
font-size: 13px; line-height: 20px;
|
8
|
+
vertical-align: middle;
|
9
|
+
color: #000;
|
10
|
+
-webkit-user-select: none;
|
11
|
+
-moz-user-select: none;
|
12
|
+
-khtml-user-select: none;
|
13
|
+
}
|
14
|
+
.default > .table_header > .table_header_column {
|
15
|
+
top: 1px; height: 20px; position: absolute;
|
16
|
+
cursor: pointer; border-right: 1px solid #ccc;
|
17
|
+
font-weight: bold;
|
18
|
+
}
|
19
|
+
.default > .table_header > .table_header_column > .sort {
|
20
|
+
position: absolute; top: 1px; right: 2px;
|
21
|
+
}
|
22
|
+
.default > .table_body {
|
23
|
+
position: absolute; top: 24px; left: 0; right: 0; bottom: 0;
|
24
|
+
overflow: auto; overflow-x: hidden;
|
25
|
+
}
|
@@ -1,19 +1,2 @@
|
|
1
|
-
<div id="
|
2
|
-
|
3
|
-
<div class="table_n"></div>
|
4
|
-
<div class="table_ne"></div>
|
5
|
-
<div class="table_w"></div>
|
6
|
-
<div class="table_c"></div>
|
7
|
-
<div class="table_e"></div>
|
8
|
-
<div class="table_sw"></div>
|
9
|
-
<div class="table_s"></div>
|
10
|
-
<div class="table_se"></div>
|
11
|
-
</div>
|
12
|
-
<div id="header#{_ID}" class="table_header">
|
13
|
-
<div class="table_header_left"></div>
|
14
|
-
<div class="table_header_middle"></div>
|
15
|
-
<div class="table_header_right"></div>
|
16
|
-
<div id="header_columns#{_ID}" class="table_columns"></div>
|
17
|
-
</div>
|
18
|
-
<div id="content#{_ID}" class="table_content"></div>
|
19
|
-
</div>
|
1
|
+
<div id="header#{_ID}" class="table_header"></div>
|
2
|
+
<div id="subview#{_ID}" class="table_body"></div>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rsence-pre
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.0.
|
4
|
+
version: 2.3.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-08-
|
13
|
+
date: 2012-08-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsence-deps
|