[Git][noosfero/noosfero][master] 2 commits: tokeninput: don't focus on init to avoid page scroll down

Bráulio Bhavamitra gitlab at gitlab.com
Wed Jun 17 20:01:42 BRT 2015


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
e37b3e2f by Braulio Bhavamitra at 2015-06-09T10:29:42Z
tokeninput: don't focus on init to avoid page scroll down

This happens for example on /admin/features with feature members_whitelist_enabled
with one member added, the page will load and scroll to token input

- - - - -
c055f168 by Bráulio Bhavamitra at 2015-06-17T23:01:26Z
Merge branch 'tokeninput-dont-focus-on-init' into 'master'

tokeninput: don't focus on init to avoid page scroll down

This happens for example on /admin/features with feature members_whitelist_enabled
with one member added, the page will load and scroll to token input

See merge request !594

- - - - -


1 changed file:

- public/javascripts/jquery.tokeninput.js


Changes:

=====================================
public/javascripts/jquery.tokeninput.js
=====================================
--- a/public/javascripts/jquery.tokeninput.js
+++ b/public/javascripts/jquery.tokeninput.js
@@ -345,7 +345,7 @@ $.TokenList = function (input, url_or_data, options) {
     dropdown.appendTo("body");
     if (!settings.permanentDropdown)
         dropdown.appendTo("body");
-    else 
+    else
         $(input).after(dropdown.show());
 
     if (settings.permanentDropdown || settings.showAllResults) {
@@ -382,7 +382,7 @@ $.TokenList = function (input, url_or_data, options) {
     if(li_data && li_data.length) {
         $.each(li_data, function (index, value) {
             insert_token(value);
-            checkTokenLimit();
+            checkTokenLimit({init: true});
         });
     }
 
@@ -425,12 +425,12 @@ $.TokenList = function (input, url_or_data, options) {
     // Private functions
     //
 
-    function checkTokenLimit() {
+    function checkTokenLimit(options) {
         if(settings.tokenLimit !== null && token_count >= settings.tokenLimit) {
             input_box.hide();
             hide_dropdown();
             return;
-        } else {
+        } else if (options && !options.init) {
             input_box.focus();
         }
     }
@@ -618,7 +618,7 @@ $.TokenList = function (input, url_or_data, options) {
             if (!settings.showAllResults)
               dropdown.empty();
             selected_dropdown_item = null;
-        } 
+        }
         if (settings.showAllResults)
             show_dropdown_hint();
     }
@@ -728,7 +728,7 @@ $.TokenList = function (input, url_or_data, options) {
             item.addClass(settings.classes.selectedDropdownItem);
             selected_dropdown_item = item.get(0);
 
-            isBefore = item[0].offsetTop <= (dropdown[0].scrollTop + dropdown[0].scrollWidth); 
+            isBefore = item[0].offsetTop <= (dropdown[0].scrollTop + dropdown[0].scrollWidth);
             isAfter = item[0].offsetTop >= dropdown[0].scrollTop;
             visible = isBefore && isAfter;
             if (!visible) {



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/39215aac24eb73b824eb0928ff999008ff2a7953...c055f168bc1ef1c15fa00906a3d546526a70ed97
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150617/a04241e5/attachment.html>


More information about the Noosfero-dev mailing list