webstaff: Select on focus for tag, indicators, and sf codes
authorMike Rylander <mrylander@gmail.com>
Thu, 17 Sep 2015 22:11:11 +0000 (18:11 -0400)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:46 +0000 (14:58 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index ceb0e5b..1a92f13 100644 (file)
@@ -64,7 +64,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
             contextItemContainer: '@',
             contextItemGenerator: '=',
             max: '@',
-            itype: '@'
+            itype: '@',
+            selectOnFocus: '='
         },
         controller : ['$scope',
             function ( $scope ) {
@@ -142,6 +143,11 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
 
             if (scope.onKeydown) element.bind('keydown', {scope : scope}, scope.onKeydown);
 
+            if (Boolean(scope.selectOnFocus)) {
+                element.addClass('noSelection');
+                element.bind('focus', function () { element.select() });
+            }
+
             element.bind('change', function (e) { element.size = scope.max || parseInt(scope.content.length * 1.1) });
 
             element.bind('contextmenu', {scope : scope}, scope.showContext);
@@ -293,6 +299,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                         'for="r{{field.record.subfield(\'901\',\'c\')[1]}}f{{field.position}}s{{subfield[2]}}code" '+
                         '>‡</label><eg-marc-edit-editable '+
                         'itype="sfc" '+
+                        'select-on-focus="true" '+
                         'class="marcedit marcsf marcsfcode" '+
                         'field="field" '+
                         'subfield="subfield" '+
@@ -336,6 +343,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
         template: '<span><eg-marc-edit-editable '+
                       'itype="ind" '+
                       'class="marcedit marcind" '+
+                      'select-on-focus="true" '+
                       'field="field" '+
                       'content="ind" '+
                       'max="1" '+
@@ -363,6 +371,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
         template: '<span><eg-marc-edit-editable '+
                       'itype="tag" '+
                       'class="marcedit marctag" '+
+                      'select-on-focus="true" '+
                       'field="field" '+
                       'content="tag" '+
                       'max="3" '+
@@ -385,8 +394,8 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
 
                         if (!$scope.field.isControlfield()) {
                             options = options.concat([
-                                { label : 'Add Datafield', action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.addDatafield(e) } },
-                                { label : 'Insert Datafield', action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.addDatafield(e,true) } },
+                                { label : 'Insert field after ', action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.addDatafield(e) } },
+                                { label : 'Insert field before', action : function(j1,j2,j3,j4,e) { $scope.contextFunctions.addDatafield(e,true) } },
                             ]);
                         }
 
@@ -577,6 +586,14 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
         },
         link: function (scope, element, attrs) {
 
+            element.bind('mouseup', function(e) {;
+                scope.current_event_target = $(e.target).attr('id');
+                if (scope.current_event_target && $(e.target).hasClass('noSelection')) {
+                    e.preventDefault()
+                    return false;
+                }
+            });
+
             element.bind('click', function(e) {;
                 scope.current_event_target = $(e.target).attr('id');
                 if (scope.current_event_target) {