rsence-pre 2.3.0.14 → 2.3.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/js/datetime/timesheet/timesheet.js +32 -54
- data/js/foundation/geom/rect/rect.js +2 -8
- data/lib/rsence/pluginmanager.rb +2 -0
- data/lib/rsence/plugins/plugin.rb +63 -3
- data/lib/rsence/plugins/plugin_base.rb +36 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.3.0.
|
1
|
+
2.3.0.15.pre
|
@@ -608,31 +608,6 @@ HTimeSheet = HControl.extend({
|
|
608
608
|
}
|
609
609
|
},
|
610
610
|
|
611
|
-
// checks if i overlaps j
|
612
|
-
// todo: refactor, it's a bit messy
|
613
|
-
_doesOverlap: function( i, j, _overlaps, _rectSelf, _items ){
|
614
|
-
if( _rectSelf === undefined ) {
|
615
|
-
_rectSelf = this.timeSheetItems[i].rect;
|
616
|
-
}
|
617
|
-
if( _items === undefined ){
|
618
|
-
_items = this.timeSheetItems;
|
619
|
-
}
|
620
|
-
var
|
621
|
-
_isntSame = (i !== j),
|
622
|
-
_isntListedSelf = (!~_overlaps.indexOf(i)),
|
623
|
-
_isntListedOther = (!~_overlaps.indexOf(j)),
|
624
|
-
_rectOther = _items[j].rect;
|
625
|
-
if( !_isntSame ){ return false; }
|
626
|
-
if( !_isntListedSelf ){ return false; }
|
627
|
-
if( _isntListedOther ){
|
628
|
-
if( _rectOther.intersects( _rectSelf, 1, 1 ) || _rectSelf.intersects( _rectOther, 1, 1 ) ){
|
629
|
-
return true;
|
630
|
-
}
|
631
|
-
}
|
632
|
-
return false;
|
633
|
-
},
|
634
|
-
|
635
|
-
|
636
611
|
// finds the index in the array which contains most sequential items
|
637
612
|
_findLargestSequence: function( _arr ){
|
638
613
|
var
|
@@ -660,30 +635,34 @@ HTimeSheet = HControl.extend({
|
|
660
635
|
},
|
661
636
|
|
662
637
|
// find the amount of overlapping time sheet items
|
663
|
-
_findOverlapCount: function(){
|
638
|
+
_findOverlapCount: function( _items ){
|
664
639
|
var
|
665
|
-
_overlapCount,
|
666
|
-
_items = this._sortedTimeSheetItems(),
|
667
640
|
_overlaps = [],
|
668
|
-
|
669
|
-
i
|
670
|
-
|
671
|
-
for( ; i < _items.length; i++
|
672
|
-
|
673
|
-
|
674
|
-
|
675
|
-
|
676
|
-
|
677
|
-
|
678
|
-
|
679
|
-
|
680
|
-
_overlaps.push( i );
|
681
|
-
if( _overlapCount > _maxOverlapCount ){
|
682
|
-
_maxOverlapCount = _overlapCount;
|
641
|
+
_testRects = this._getTestRects( _items ),
|
642
|
+
i,j;
|
643
|
+
|
644
|
+
for( i = 0; i < _items.length; i++){
|
645
|
+
_overlaps[i] = 0;
|
646
|
+
}
|
647
|
+
|
648
|
+
for( i = 0; i < _items.length - 1; i++ ){
|
649
|
+
for( j = i + 1; j < _items.length; j++ ){
|
650
|
+
if( _items[i].rect.intersects( _testRects[j] ) ){
|
651
|
+
_overlaps[i] += 1;
|
652
|
+
_overlaps[j] += 1;
|
683
653
|
}
|
684
654
|
}
|
685
655
|
}
|
686
|
-
return
|
656
|
+
return Math.max.apply( Math, _overlaps );
|
657
|
+
},
|
658
|
+
|
659
|
+
_getTestRects: function( _items ){
|
660
|
+
var _rects = [];
|
661
|
+
for( var i = 0; i < _items.length; i++){
|
662
|
+
_rects[i] = HRect.nu( _items[i].rect );
|
663
|
+
_rects[i].insetBy( 1, 1 );
|
664
|
+
}
|
665
|
+
return _rects;
|
687
666
|
},
|
688
667
|
|
689
668
|
// returns a sorted copy of the timeSheetItems array
|
@@ -710,16 +689,16 @@ HTimeSheet = HControl.extend({
|
|
710
689
|
var
|
711
690
|
// loop indexes:
|
712
691
|
i, j, k, l,
|
713
|
-
// amount of items ovelapping (max, actual number might be smaller after optimization)
|
714
692
|
_options = this.options,
|
715
693
|
_rect = this.rect,
|
716
|
-
_overlapCount = this._findOverlapCount(),
|
717
694
|
_availWidth = ( _rect.width - _options.itemOffsetRight - _options.itemOffsetLeft ),
|
718
695
|
_left = _options.itemOffsetLeft,
|
719
|
-
_width = Math.floor( _availWidth / (_overlapCount+1) ),
|
720
696
|
// get a list of timesheet items sorted by height (larger to smaller order)
|
721
697
|
_items = this._sortedTimeSheetItems(),
|
722
698
|
_itemCount = _items.length,
|
699
|
+
// amount of items ovelapping (max, actual number might be smaller after optimization)
|
700
|
+
_overlapCount = this._findOverlapCount( _items ),
|
701
|
+
_width = Math.floor( _availWidth / (_overlapCount+1) ),
|
723
702
|
_itemRect,
|
724
703
|
_testRect,
|
725
704
|
_leftPos,
|
@@ -732,10 +711,11 @@ HTimeSheet = HControl.extend({
|
|
732
711
|
_optimalColAndLength,
|
733
712
|
_col,
|
734
713
|
_colWidth,
|
735
|
-
_overlaps
|
714
|
+
_overlaps,
|
715
|
+
_testRects;
|
736
716
|
|
737
717
|
// No overlapping; nothing to do
|
738
|
-
if(_overlapCount === 0 ){
|
718
|
+
if( _overlapCount === 0 ){
|
739
719
|
return false;
|
740
720
|
}
|
741
721
|
|
@@ -763,19 +743,17 @@ HTimeSheet = HControl.extend({
|
|
763
743
|
_itemRect.setRight( _leftPos + _width );
|
764
744
|
continue;
|
765
745
|
}
|
766
|
-
_testRect = HRect.nu( _itemRect );
|
767
|
-
|
768
746
|
_overlapCols = [];
|
769
747
|
_vacantCols = [];
|
770
|
-
|
748
|
+
_testRects = this._getTestRects( _items );
|
749
|
+
_testRect = HRect.nu( _itemRect );
|
771
750
|
// test each column position (modes 0 and 2)
|
772
751
|
for( k = 0; k < _overlapCount+1; k++ ){
|
773
752
|
_leftPos = _left + (k*_width);
|
774
753
|
_testRect.setLeft( _leftPos );
|
775
754
|
_testRect.setRight( _leftPos + _width );
|
776
|
-
_overlaps = [];
|
777
755
|
for( j = 0; j < _itemCount; j++){
|
778
|
-
if(
|
756
|
+
if( i !==j && _testRect.intersects( _testRects[j] ) ){
|
779
757
|
if( !~_overlapCols.indexOf( k ) ){
|
780
758
|
_overlapCols.push( k );
|
781
759
|
}
|
@@ -447,14 +447,8 @@ HRect = HClass.extend({
|
|
447
447
|
}
|
448
448
|
_rect.insetBy( _insetByX, _insetByY );
|
449
449
|
}
|
450
|
-
return (
|
451
|
-
|
452
|
-
( _rect.right >= this.left && _rect.right <= this.right )
|
453
|
-
) &&
|
454
|
-
( ( _rect.top >= this.top && _rect.top <= this.bottom) ||
|
455
|
-
( _rect.bottom >= this.top && _rect.bottom <= this.bottom)
|
456
|
-
)
|
457
|
-
);
|
450
|
+
return ! ( this.left > _rect.right || this.right < _rect.left ||
|
451
|
+
this.top > _rect.bottom || this.bottom < _rect.top );
|
458
452
|
},
|
459
453
|
|
460
454
|
overlaps: function( _rect, _insetbyX, _insetByY ){
|
data/lib/rsence/pluginmanager.rb
CHANGED
@@ -212,6 +212,57 @@ module RSence
|
|
212
212
|
return ses[key] if key
|
213
213
|
return ses
|
214
214
|
end
|
215
|
+
|
216
|
+
# Returns an array of type (:js/:coffee/:none), path (string)
|
217
|
+
def guess_js_path( js_name )
|
218
|
+
has_slash = js_name.include?('/')
|
219
|
+
is_coffee = false
|
220
|
+
is_js = false
|
221
|
+
if has_slash
|
222
|
+
js_fn = js_name.split('/')[-1]
|
223
|
+
else
|
224
|
+
js_fn = js_name
|
225
|
+
end
|
226
|
+
if js_fn.include?('.')
|
227
|
+
js_ext = js_fn.split('.')[-1]
|
228
|
+
if js_ext == 'coffee'
|
229
|
+
is_coffee = true
|
230
|
+
elsif js_ext == 'js'
|
231
|
+
is_js = true
|
232
|
+
end
|
233
|
+
end
|
234
|
+
if has_slash
|
235
|
+
sub_ptah = false
|
236
|
+
else
|
237
|
+
sub_path = 'js'
|
238
|
+
end
|
239
|
+
if is_coffee or is_js
|
240
|
+
path = bundle_path( js_name, sub_path, '.'+js_ext )
|
241
|
+
found = file_exist?( path )
|
242
|
+
else
|
243
|
+
path = bundle_path( js_name, sub_path, '.coffee' )
|
244
|
+
found = file_exist?( path )
|
245
|
+
if found
|
246
|
+
is_coffee = true
|
247
|
+
else
|
248
|
+
is_js = true
|
249
|
+
path = bundle_path( js_name, sub_path, '.js' )
|
250
|
+
found = file_exist?( path )
|
251
|
+
end
|
252
|
+
end
|
253
|
+
foundtype = found ? ( is_coffee ? :coffee : ( is_js ? :js : :none ) ) : :none
|
254
|
+
path = false if foundtype == :none
|
255
|
+
[ foundtype, path ]
|
256
|
+
end
|
257
|
+
|
258
|
+
# Returns coffee compiled to js
|
259
|
+
def brew_coffee( path )
|
260
|
+
client_pkg.coffee( file_read( path ) )
|
261
|
+
end
|
262
|
+
|
263
|
+
def squeezed_js( path )
|
264
|
+
client_pkg.squeeze( file_read( path ) )
|
265
|
+
end
|
215
266
|
|
216
267
|
# Returns the source code of the javascript file +js_name+ in the 'js' subdirectory of the plugin bundle. Use it to send raw javascript command code to the client. Use {#read_js_once} for libraries.
|
217
268
|
#
|
@@ -220,7 +271,15 @@ module RSence
|
|
220
271
|
# @return [String] The source of the file.
|
221
272
|
# @return [false] Returns false, when file was not found.
|
222
273
|
def read_js( js_name )
|
223
|
-
|
274
|
+
( type, path ) = guess_js_path( js_name )
|
275
|
+
if type == :none
|
276
|
+
warn "File not found: #{js_name}"
|
277
|
+
return ''
|
278
|
+
end
|
279
|
+
return brew_coffee( path ) if type == :coffee
|
280
|
+
# return squeezed_js( path ) if type == :js
|
281
|
+
return file_read( path ) if type == :js
|
282
|
+
warn "read_js: unknown type #{type.inspect}"
|
224
283
|
end
|
225
284
|
|
226
285
|
# Like {#read_js}, but reads the file only once per session. Use for inclusion of custom library code.
|
@@ -235,10 +294,11 @@ module RSence
|
|
235
294
|
if not ses.has_key?(:deps)
|
236
295
|
ses[:deps] = []
|
237
296
|
end
|
238
|
-
path =
|
297
|
+
( found, path ) = guess_js_path( js_name )
|
298
|
+
return false unless found == :none
|
239
299
|
unless ses[:deps].include?( path )
|
240
300
|
ses[:deps].push( path )
|
241
|
-
return
|
301
|
+
return read_js( path )
|
242
302
|
else
|
243
303
|
return ''
|
244
304
|
end
|
@@ -76,6 +76,17 @@ module RSence
|
|
76
76
|
# @return [nil]
|
77
77
|
def close
|
78
78
|
end
|
79
|
+
|
80
|
+
# File existence checker
|
81
|
+
#
|
82
|
+
# Just a wrapper for File.exist, except it handles the +path+ via #bundle_path
|
83
|
+
#
|
84
|
+
# @return [false] if the file does not exist.
|
85
|
+
# @return [true] if the file exists.
|
86
|
+
def file_exist?( path )
|
87
|
+
path = bundle_path( path )
|
88
|
+
File.exist?( path )
|
89
|
+
end
|
79
90
|
|
80
91
|
# File reader utility
|
81
92
|
#
|
@@ -118,7 +129,31 @@ module RSence
|
|
118
129
|
end
|
119
130
|
end
|
120
131
|
|
121
|
-
#
|
132
|
+
# JSON reader utility
|
133
|
+
#
|
134
|
+
# Reads the contents of the JSON file given in the +path+ and returns as a parsed structure of the contents of the file.
|
135
|
+
#
|
136
|
+
# @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before reading the file.
|
137
|
+
#
|
138
|
+
# @return [false] If the is no file, returns +false+
|
139
|
+
# @return [Object] Any valid structure defined by the YAML file, parsed to a Ruby object.
|
140
|
+
def json_read( path )
|
141
|
+
file_data = file_read( path )
|
142
|
+
if not file_data
|
143
|
+
return false
|
144
|
+
else
|
145
|
+
begin
|
146
|
+
return JSON.parse( file_data )
|
147
|
+
rescue => e
|
148
|
+
warn "An exception occurred while parsing JSON file: #{path}"
|
149
|
+
warn e.message
|
150
|
+
warn " #{e.backtrace.join("\n ")}"
|
151
|
+
return false
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
# File writer utility.
|
122
157
|
#
|
123
158
|
# Writes the contents of the +data+ into the file given in the +path+.
|
124
159
|
# @param [String] path The +path+ is relative to the bundle path by default, unless it starts with '/' or '..'; it's simply processed by {#bundle_path} before writing the file.
|
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.15
|
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:
|
13
|
+
date: 2013-01-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rsence-deps
|