tenon 1.0.30 → 1.0.31
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/tenon/features/focus_first_field.js.coffee +8 -0
- data/app/assets/javascripts/tenon/features/protect_changes.js.coffee +25 -0
- data/app/assets/javascripts/tenon/tenon.js +2 -1
- data/lib/tenon/version.rb +1 -1
- metadata +4 -3
- data/app/assets/javascripts/tenon/features/forms.js.erb +0 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5284723eeed1bf522c2a56e3cf2986c4e56ed3e0
|
4
|
+
data.tar.gz: 39452e80c5f9e020c20f598121ca3460bc8269c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8758fa8e8724e6f3fbdc7f5f1dcd89fafd812c328c12540216387d13e82dab52d04a94f1f4fdff3216e198fbb6ec340d066846adc6fd5f03fb34f9510c883b8
|
7
|
+
data.tar.gz: 6231d7d545676ca6d5ba4302ec397d7f4706e7ad9e10c8b61e679e9146faeca09ee228782c14ca1d8dbc11c19065d7362973fec47bb429cb6fd23927b8d7f3ee
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class Tenon.features.FocusFirstField
|
2
|
+
constructor: ->
|
3
|
+
$firstField = $($(".main-content form input[type!='hidden'], .main-content form select, .main-content form textarea")[0])
|
4
|
+
$firstField.focus()
|
5
|
+
|
6
|
+
if $firstField.is('input[type=text], textarea')
|
7
|
+
length = $firstField.val().length
|
8
|
+
$firstField[0].setSelectionRange(length, length)
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Tenon.features.ProtectChanges
|
2
|
+
constructor: ->
|
3
|
+
@changesMade = false
|
4
|
+
@bindChangeEvents()
|
5
|
+
$(window).on('beforeunload', @confirmNavigation)
|
6
|
+
|
7
|
+
bindChangeEvents: =>
|
8
|
+
@$form = $('.main-content form')
|
9
|
+
@$form.on('cocoon:after-insert cocoon:after-remove', @_markChanged)
|
10
|
+
@$form.on('keyup change', 'input, select, textarea', @_markChanged)
|
11
|
+
@$form.on('input', '.editable-text', @_markChanged)
|
12
|
+
@$form.on('submit', @_clearChanges)
|
13
|
+
|
14
|
+
_markChanged: (e) =>
|
15
|
+
ignore = [37, 38, 39, 40, 20, 16, 17, 18]
|
16
|
+
code = e.keyCode || e.which
|
17
|
+
@changesMade = true if $.inArray(code, ignore) == -1
|
18
|
+
|
19
|
+
_clearChanges: =>
|
20
|
+
@changesMade = false
|
21
|
+
return true
|
22
|
+
|
23
|
+
confirmNavigation: =>
|
24
|
+
if @changesMade
|
25
|
+
'You have unsaved changes, are you sure you want to leave this page?'
|
@@ -30,12 +30,12 @@ var Tenon = {
|
|
30
30
|
// init select2
|
31
31
|
$('select').select2();
|
32
32
|
|
33
|
-
Tenon.features.forms.init();
|
34
33
|
Tenon.features.fileSelectWidget.init();
|
35
34
|
new Tenon.features.I18nFields();
|
36
35
|
new Tenon.features.Flash();
|
37
36
|
new Tenon.features.AssetCropping();
|
38
37
|
new Tenon.features.AssetDetachment();
|
38
|
+
new Tenon.features.FocusFirstField();
|
39
39
|
new Tenon.features.MainMenu();
|
40
40
|
new Tenon.features.Pagination();
|
41
41
|
new Tenon.features.HamburgerNavigation();
|
@@ -46,6 +46,7 @@ var Tenon = {
|
|
46
46
|
new Tenon.features.ItemVersionAutosave();
|
47
47
|
new Tenon.features.ModalWindows();
|
48
48
|
new Tenon.features.ModalForms();
|
49
|
+
new Tenon.features.ProtectChanges();
|
49
50
|
new Tenon.features.RecordApproval();
|
50
51
|
new Tenon.features.RecordBooleanToggle();
|
51
52
|
new Tenon.features.RecordDeletion();
|
data/lib/tenon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tenon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.31
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- factor[e] design initiative
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: better_errors
|
@@ -930,7 +930,7 @@ files:
|
|
930
930
|
- app/assets/javascripts/tenon/features/date_time_picker.js.coffee
|
931
931
|
- app/assets/javascripts/tenon/features/file_select_widget.js.erb
|
932
932
|
- app/assets/javascripts/tenon/features/flash.js.coffee
|
933
|
-
- app/assets/javascripts/tenon/features/
|
933
|
+
- app/assets/javascripts/tenon/features/focus_first_field.js.coffee
|
934
934
|
- app/assets/javascripts/tenon/features/hamburger_navigation.js.coffee
|
935
935
|
- app/assets/javascripts/tenon/features/header_menu.js.coffee
|
936
936
|
- app/assets/javascripts/tenon/features/i18n_fields.js.coffee
|
@@ -947,6 +947,7 @@ files:
|
|
947
947
|
- app/assets/javascripts/tenon/features/nested_set_writer.js.coffee
|
948
948
|
- app/assets/javascripts/tenon/features/new_item_version_handler.js.coffee
|
949
949
|
- app/assets/javascripts/tenon/features/pagination.js.coffee
|
950
|
+
- app/assets/javascripts/tenon/features/protect_changes.js.coffee
|
950
951
|
- app/assets/javascripts/tenon/features/quick_search.js.coffee
|
951
952
|
- app/assets/javascripts/tenon/features/record_approval.js.coffee
|
952
953
|
- app/assets/javascripts/tenon/features/record_boolean_toggle.js.coffee
|
@@ -1,47 +0,0 @@
|
|
1
|
-
Tenon.features.forms = {
|
2
|
-
init: function () {
|
3
|
-
var self = Tenon.features.forms;
|
4
|
-
self.setupRadioSliders();
|
5
|
-
self.protectChanges();
|
6
|
-
self.focusFirstField();
|
7
|
-
},
|
8
|
-
|
9
|
-
protectChanges: function () {
|
10
|
-
var self = Tenon.features.forms;
|
11
|
-
|
12
|
-
self.changesMade = false;
|
13
|
-
$('input, select, textarea').bind('keyup change', function() {
|
14
|
-
if ($(this).attr('id') != "quick-search") { self.changesMade = true; }
|
15
|
-
});
|
16
|
-
|
17
|
-
// don't run the check if the user is submitting a form of course
|
18
|
-
$(document).on('submit', 'form', function() {
|
19
|
-
window.onbeforeunload = null;
|
20
|
-
});
|
21
|
-
|
22
|
-
window.onbeforeunload = self.confirmNavigation;
|
23
|
-
},
|
24
|
-
|
25
|
-
confirmNavigation: function () {
|
26
|
-
var self = Tenon.features.forms;
|
27
|
-
|
28
|
-
if (typeof CKEDITOR != 'undefined') {
|
29
|
-
for ( instance in CKEDITOR.instances )
|
30
|
-
if(CKEDITOR.instances[instance].checkDirty()) { self.changesMade = true}
|
31
|
-
}
|
32
|
-
|
33
|
-
if (self.changesMade) {
|
34
|
-
return "You have unsaved changes, are you sure you want to leave this page?";
|
35
|
-
}
|
36
|
-
},
|
37
|
-
|
38
|
-
setupRadioSliders: function () {
|
39
|
-
$('.radio-slider').radioSlider({sliderImage: '<%= asset_path'tenon/slider-button.png' %>'});
|
40
|
-
},
|
41
|
-
|
42
|
-
focusFirstField: function () {
|
43
|
-
el = $(".main-content form input[type!='hidden'], .main-content form select, .main-content form textarea")[0];
|
44
|
-
$(el).focus();
|
45
|
-
}
|
46
|
-
|
47
|
-
}
|