Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

read only configuration #135

Open
fvisticot opened this issue Jul 19, 2013 · 6 comments
Open

read only configuration #135

fvisticot opened this issue Jul 19, 2013 · 6 comments
Milestone

Comments

@fvisticot
Copy link

I need to display all the tags in a "read only" mode (without the cross) and without the input box to add new tag.
Is it possible ? how ?

@johnnyshields
Copy link
Collaborator

@fvisticot we don't have this currently, but it would not be hard to add by adding a new API parameter "readonly" and preventing the delete action. As for hiding the 'x' characters, you could do this either in the HTML generation, setting the tagCloseIcon to an empty string (''), or via CSS.

@jjwilliams
Copy link

I have done this - I do not have time to do a full pull request, but here is the codez (im sure it can be improved):

option:

readOnly: false,

Function to determine if read only. Note that I did this while using a specific framework which gives me values of 'True' based on my ACL rules.

var isReadOnly = function() {
        return (tagManagerOptions.readOnly == 'True' ||
            tagManagerOptions.readOnly == true ||
            tagManagerOptions.readOnly == 'true' ||
            tagManagerOptions.readOnly == 1);
    };

Check to make the input box disabled if readOnly:

if (isReadOnly()) {
          obj.attr('readonly', true);
          tagManagerOptions.deleteTagsOnBackspace = false;
      } else {
          obj.attr('readonly', false);
      }

Note: I realize in version 3.0 deleteTagsOnBackspace is deprecated, this is for version 2.4.2

Code to handle the remove button:

if (!isReadOnly()) {
            html += '<a href="#" class="tm-tag-remove" id="' + newTagRemoveId + '" TagIdToRemove="' + tagId + '">';
            html += tagManagerOptions.tagCloseIcon + '</a> ';
        }

@johnnyshields
Copy link
Collaborator

@jjwilliams can you please make this into a pull request so we can review, or if no time, make a gist of the file?

@jjwilliams
Copy link

Sure, I will work on it this weekend. One issue I had when trying was getting a working example going. Is it just me or is docs.html lacking? Its missing jquery, bootstrap, and typeahead references.

@johnnyshields
Copy link
Collaborator

@jjwilliams The way docs.html runs it's embedded into another page. It's synced automatically here and updates every 5 mins from Github:
http://welldonethings.com/tags/manager/v3

@jjwilliams
Copy link

Submitted a pull request for this, #167

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants