switch_access-rails 1.1.6 → 1.1.7
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.
@@ -3,7 +3,7 @@ Switch Access for webpages
|
|
3
3
|
(c) 2012 Leif Ringstad
|
4
4
|
Dual-licensed under GPL or commercial license (LICENSE and LICENSE.GPL)
|
5
5
|
Source: http://github.com/leifcr/switch_access
|
6
|
-
v 1.1.
|
6
|
+
v 1.1.7
|
7
7
|
###
|
8
8
|
|
9
9
|
SwitchAccessCommon =
|
@@ -305,8 +305,10 @@ class SwitchAccess
|
|
305
305
|
parent_idx: 0 # the last idx on the parent before moving into the group
|
306
306
|
action_triggered: false # set to true if an action is triggered
|
307
307
|
keypress_allowed: true # keypress allowed or not
|
308
|
-
|
309
|
-
|
308
|
+
single_switch:
|
309
|
+
timer_id: null # The id of the single switch timer
|
310
|
+
running: false # if the timer is running or not
|
311
|
+
activate_triggered: false # if the activate action has been triggered
|
310
312
|
|
311
313
|
highlighter_holder: null # The highlighter holder as a jquery object
|
312
314
|
|
@@ -532,6 +534,7 @@ class SwitchAccess
|
|
532
534
|
moveToNext: ->
|
533
535
|
@log "moveToNext Current: I: #{@runtime.element.next_idx} L: #{@runtime.element.level} Next: I: #{@runtime.element.next_idx} L: #{@runtime.element.next_level}" if (@options.debug)
|
534
536
|
@runtime.action_triggered = true
|
537
|
+
@runtime.single_switch.activate_triggered = false
|
535
538
|
|
536
539
|
# return if current level and idxs are equal
|
537
540
|
return false if (@runtime.element.next_level == @runtime.element.level) and (@runtime.element.idx == @runtime.element.next_idx)
|
@@ -562,6 +565,11 @@ class SwitchAccess
|
|
562
565
|
@runtime.current_list = list_n
|
563
566
|
@runtime.element.current = list_n[@runtime.element.idx]
|
564
567
|
|
568
|
+
# check if this is a "stay-element" and it's single switch
|
569
|
+
if (@options.switches.number_of_switches == 1)
|
570
|
+
if @runtime.element.current.jq_element().data("sw-single-stay") == true
|
571
|
+
@stopSingleSwitchTimer()
|
572
|
+
|
565
573
|
@makeElementVisible()
|
566
574
|
return true
|
567
575
|
|
@@ -636,21 +644,28 @@ class SwitchAccess
|
|
636
644
|
activateElementCallBack: ->
|
637
645
|
@log "activateElementCallBack" if (@options.debug)
|
638
646
|
|
639
|
-
# see if the element has
|
640
|
-
if @runtime.element.current.children().length >
|
647
|
+
# see if the element has more than 1 child, if so go into level
|
648
|
+
if @runtime.element.current.children().length > 1
|
641
649
|
@startSingleSwitchTimer()
|
642
650
|
return @moveToNextLevel()
|
643
651
|
# else the element should "activate"
|
644
652
|
|
645
|
-
|
646
|
-
|
653
|
+
# choose correct element to "activate"
|
654
|
+
# first child if there is one
|
655
|
+
if @runtime.element.current.children().length == 1
|
656
|
+
el = @runtime.element.current.jq_element()[0]
|
657
|
+
else # activate the current element
|
658
|
+
el = @runtime.element.current.jq_element()
|
659
|
+
|
660
|
+
if ((el.is("a")) || (@activate_first_link == false))
|
661
|
+
element_to_click = el
|
647
662
|
else
|
648
663
|
# if element isn't a link, find first link within element and go to the url/trigger it
|
649
|
-
element_to_click =
|
664
|
+
element_to_click = el.find("a")
|
650
665
|
|
651
666
|
# safety catch
|
652
667
|
if (element_to_click.length <= 0)
|
653
|
-
element_to_click =
|
668
|
+
element_to_click = el
|
654
669
|
|
655
670
|
@log "Triggering Element: IDX: #{@runtime.element.current_idx} Element Tag: #{$(element_to_click).get(0).tagName.toLowerCase()} Text: #{$(element_to_click).text()}" if (@options.debug)
|
656
671
|
|
@@ -662,7 +677,7 @@ class SwitchAccess
|
|
662
677
|
if (@options.switches.number_of_switches == 1)
|
663
678
|
@runtime.next_element_idx = -1 if (@options.single_switch_restart_on_activate)
|
664
679
|
@runtime.next_level = 0
|
665
|
-
@startSingleSwitchTimer()
|
680
|
+
# @startSingleSwitchTimer()
|
666
681
|
else
|
667
682
|
msg = "Nothing to do. Verify options passed to SwitchAccess"
|
668
683
|
@log msg, "warn" if (@options.debug)
|
@@ -699,7 +714,17 @@ class SwitchAccess
|
|
699
714
|
if !@runtime.keypress_allowed
|
700
715
|
event.stopPropagation()
|
701
716
|
return false
|
702
|
-
|
717
|
+
# check if stayed at element and if element has "trigger" action
|
718
|
+
if @runtime.element.current.jq_element().data("sw-single-stay") == true
|
719
|
+
if @runtime.element.current.jq_element().data("sw-single-noaction") == true or @runtime.single_switch.activate_triggered == true
|
720
|
+
action = @moveToNextElementAtLevel()
|
721
|
+
if @runtime.element.current.jq_element().data("sw-single-stay") != true
|
722
|
+
@startSingleSwitchTimer()
|
723
|
+
else
|
724
|
+
@runtime.single_switch.activate_triggered = true
|
725
|
+
|
726
|
+
if action == 0
|
727
|
+
action = @activateElement()
|
703
728
|
|
704
729
|
else if @options.switches.number_of_switches == 2
|
705
730
|
if (event.which in @options.switches.keys_2[0]) || (event.which in @options.switches.keys_2[1])
|
@@ -736,12 +761,14 @@ class SwitchAccess
|
|
736
761
|
startSingleSwitchTimer: ->
|
737
762
|
return unless @options.switches.number_of_switches == 1
|
738
763
|
@log "startSingleSwitchTimer", "trace" if (@options.debug)
|
739
|
-
@runtime.
|
764
|
+
@runtime.single_switch.timer_id = window.setInterval(( => @singleSwitchTimerCallback();return), @options.switches.single_switch_move_time)
|
765
|
+
@runtime.single_switch.running = true
|
740
766
|
|
741
767
|
stopSingleSwitchTimer: ->
|
742
768
|
return unless @options.switches.number_of_switches == 1
|
743
769
|
@log "stopSingleSwitchTimer", "trace" if (@options.debug)
|
744
|
-
window.clearInterval(@runtime.
|
770
|
+
window.clearInterval(@runtime.single_switch.timer_id)
|
771
|
+
@runtime.single_switch.running = false
|
745
772
|
|
746
773
|
removeCallbacks: ->
|
747
774
|
@log "removeCallbacks", "trace" if (@options.debug)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: switch_access-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: actionpack
|
@@ -113,7 +113,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
113
113
|
version: '0'
|
114
114
|
segments:
|
115
115
|
- 0
|
116
|
-
hash: -
|
116
|
+
hash: -219704317675928756
|
117
117
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
118
|
none: false
|
119
119
|
requirements:
|
@@ -122,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
122
|
version: '0'
|
123
123
|
segments:
|
124
124
|
- 0
|
125
|
-
hash: -
|
125
|
+
hash: -219704317675928756
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
128
|
rubygems_version: 1.8.24
|