Git Product home page Git Product logo

ember-autoresize's Introduction

Ember AutoResize Ember Observer Score Code Climate

Greenkeeper badge

Note: if you're using a version of Ember less than 1.12.0, then please use 0.4.1 of this addon.

Ember AutoResize is an Ember-CLI addon for providing autoresize functionality to Ember. This package currently provides the necessary bootstrapping for {{input}} and {{textarea}} components.

To play with the addon, look at our demo. (Note: The demo is a bit out of date, check the documentation below for proper usage.)

Usage

To enable autoresizing on an input, add the following to your handlebars:

{{input autoresize=true}}

Refresh your page, and you should see that when you type in your text field, it automatically resizes to fit the text.

Textareas work exactly the same way:

{{textarea autoresize=true}}

Options

max-width

Set the maximum width of the resizeable element. If no unit is provided, it assumes that it's in pixels.

{{input autoresize=true max-width=200}}

max-height

Set the maximum width of the element. If no unit is provided, it assumes that it's in pixels.

{{input autoresize=true max-height=300}}

rows

Set the minimum number of rows for the element. Recommended for textareas.

{{textarea autoresize=true rows=2}}

max-rows

Set the maximum number of rows for the element. Recommended for textareas.

{{textarea autoresize=true max-rows=10}}

If you are making custom inputs using raw DOM elements, you can still use autoresize by specifying a custom autoresizeElement when you mixin the autoresize to your component.

import Ember from 'ember';

export default Ember.Component.extend({
  autoresizeElementDidChange: on('didInsertElement', function () {
    set(this, 'autoresizeElement', this.$('input')[0]);
  })
});

Installation

ember install ember-autoresize

Roadmap

  • Optimize style lookups
  • Font fitting
  • Clearer ways to enable autoresizing on templates

Contributing

Contributors are welcome! Please provide a reproducible test case. Details will be worked out on a case-per-case basis. Maintainers will get in touch when they can, so delays are possible. For contribution guidelines, see the code of conduct.

Publishing Documentation

To publish documentation (under the tests/dummy directory) run the following command:

npm run-script publish-docs

ember-autoresize's People

Contributors

bnitobzh avatar cibernox avatar danmcclain avatar elwayman02 avatar go1dfish avatar greenkeeper[bot] avatar h1d avatar jheth avatar jordpo avatar ktkate avatar mixonic avatar ncoden avatar rwjblue avatar tim-evans avatar urbany avatar zeppelin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-autoresize's Issues

ability to pass in a maxWidthClass class name binding

I'd like the ability to have the input look different when it reaches max width. Maybe something like:

{{input autoresize=true maxWidthClass="lol cats" max-width=300}}

## initial rendering
<input class="ember-view ember-text-field ember-auto-resize" style="width: 9px; overflow: hidden;">

## when the width hits 300px
<input class="ember-view ember-text-field ember-auto-resize lol cats" style="width: 300px; overflow: hidden;"/>

If this sounds OK to you, I'll make a PR. @tim-evans

also, perhaps an action that can be fired when we reach max width. I feel more iffy about this though.

Add class to identify temporary div

Would be nice to have a class name to identify the temporary div that's created. Just spent a little while trying to figure out where this div was coming from. So, for example:

<div class="ember-autoresize" style="position: absolute; left: -10010px; top: -10px; width: 10000px; height: 0px; overflow: hidden; visibility: hidden;">

Thanks for your work on this.

Add-on seems to fail when running tests on ember-cli-2.8.0

We are trying to use the addon within our app, and it seems to be working, but our tests fail with

Promise rejected after user can switch between editing and preview mode: Cannot get styles on an element that doesn't exist

Initially, we thought the problem is with our own lifecycle, since the editor is placed in a tab that renders or doesn't render depending on a property, but putting it outside of that scope, so it's always rendered doesn't make a difference.

Manually update size

My app contains tabs. If an autoresize textarea exists in a tab not immediately visible, it doesn't initialize to the correct size. I have to type something for it to update.

Is there an easy way tell the textarea to run a manual update?

An in-range update of ember-cli-htmlbars is breaking the build 🚨

Version 1.3.1 of ember-cli-htmlbars just got published.

Branch Build failing 🚨
Dependency ember-cli-htmlbars
Current Version 1.3.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As ember-cli-htmlbars is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Commits

The new version differs by 4 commits0.

  • b46eb48 v1.3.1
  • f0c03ec Merge pull request #109 from ember-cli/use-non-deprecated-version-checker-api
  • faf7f25 Add yarn.lock.
  • 1b27f67 Update ember-cli-version-checker use to avoid deprecated APIs.

false

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Sometimes cuts off the end of the input value

Not sure what is causing this but we've tried to fix it a couple of times and it keeps recurring. We are using ember-autoresize for the title input in https://github.com/ember-cli/ember-twiddle. It seems to sporadically cut off the last character in the input. Not always and not reproducible (at least not that we've found). I've attached a screen shot where you can see half of the last e in New Twiddle gets cut off.

Wondered if you guys had seen anything like this before or knew what could be going on here?

twiddle-signin-old

Some of the times we've tried to address it:
ember-cli/ember-twiddle#187
ember-cli/ember-twiddle#190 (diff)
ember-cli/ember-twiddle@c9d57d6

AdobeBlank injection appears to slow page load

The injection of the AdobeBlank font appears to slow my initial page load time down by about 0.5 seconds on average. My understanding from looking at the code and and previous issues is that this font is only used to support the custom-font attribute, which my application doesn't require.

Could there an option be provided in ember-cli-build to disable custom font support and then not inject the AdobeBlank font?

An in-range update of loader.js is breaking the build 🚨

Version 4.5.0 of loader.js just got published.

Branch Build failing 🚨
Dependency loader.js
Current Version 4.4.1
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As loader.js is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details

Commits

The new version differs by 7 commits.

  • 094e20b release v4.5.0 🎉
  • db2f6a6 Merge pull request #126 from ember-cli/moduleId
  • 204838b rename mod.name => mod.id
  • 4fa0fe0 add require.moduleId to allow a module to know its ID
  • f62bc54 Merge pull request #121 from ember-cli/define-exports
  • d963886 Update README.md
  • 928e18f add define.exports

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

document.styleSheets is not reliably updated

document.styleSheets not always synchronously updated with a new element's sheet.

The element added here may not actually cause a sheet to be added and found in document.styleSheets here.

This presents as an error:

Getting "Refused to load the font" Error

I think the error might be from quotation marks in multi-word fonts, like Open Sans and Helvetica Neue

For reference, this is what dom_ruler.getStyles(get(this, 'element')).fontFamily.split(',') responds with before it errors out:

  • ["'Open Sans'", " 'Helvetica Neue'", " Helvetica", " Arial", " sans-serif"]

autoresize.js:174 [Report Only] Refused to load the font 
'data:font/opentype;base64,
T1RUTwAKAIAAAwAgQ0ZGIDTeCDQAACFkAAAZPERTSUcAAAABA…AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAA==' 
because it violates the following Content Security Policy directive: "font-src 'self' fonts.gstatic.com".

Could not find module `ember-copy` imported from `ember-autoresize/system/font-loaded`

Hi, I get this error after upgrading to 1.3.1:

Could not find module `ember-copy` imported from `ember-autoresize/system/font-loaded`

I see ember-copy in the package.json for the add-on, but not in my project's node_modules.

Seems that if I add ember-copy to my project dependencies it fixes the problem?

ember-cli: 3.3.0
node: 10.4.1
os: darwin x64

Eliminate the need for ember g

There should be a way for the addon to automatically execute its own blueprint during install, rather than having to make the user run ember g ember-autoresize afterward. I just don't remember what it is, lol.

Incorrect calculations when size is a float

Hi @tim-evans first of all thanks for the great addon.

I'm using this in a project, and a user detected a bug when using browser zoom, but it might occur in other instances too.

The problem is in https://github.com/tim-evans/ember-autoresize/blob/0.5.17/addon/mixins/autoresize.js#L21

If by some reason the number is a float this unitlessNumber === number + '' won't be true and a number without units will be returned. You can see here my example:
screen shot 2016-11-22 at 11 57 29

There might be multiple ways of fixing this and I'm not sure what's the best for all the available use cases and I can't seem to run the package tests to make sure I'm not breakign something, so I'm going to submit a PR with a "safe" fix.

ember install fails, but npm install works fine

When I try to install the addon using ember install I get the following error:

bryan$ ember install ember-autoresize
version: 1.13.8
Installed packages for tooling via npm.
installing ember-autoresize
undefined is not a function
TypeError: undefined is not a function
    at new RegistryClient (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/node_modules/bower-registry-client/Client.js:8:27)
    at new PackageRepository (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/lib/core/PackageRepository.js:17:28)
    at new Manager (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/lib/core/Manager.js:17:24)
    at new Project (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/lib/core/Project.js:25:21)
    at install (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/lib/commands/install.js:16:15)
    at /Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/lib/commands/index.js:21:32
    at Promise.apply (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/node_modules/q/q.js:1165:26)
    at Promise.promise.promiseDispatch (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/node_modules/q/q.js:788:41)
    at /Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/node_modules/q/q.js:1391:14
    at runSingle (/Users/bryan/src/betterup-app/frontend/node_modules/ember-cli/node_modules/bower/node_modules/q/q.js:137:13)

I was able to get the addon working using npm and then adding dom-ruler to my bower.json. I'm not sure what kind of environment info you need, but here's my bower.json:

{
  "name": "frontend",
  "dependencies": {
    "bootstrap-filestyle": "~1.2.1",
    "bootstrap-sass": "~3.3.5",
    "ember": "2.2.0",
    "ember-cli-shims": "0.0.6",
    "ember-cli-test-loader": "0.2.1",
    "ember-data": "2.2.1",
    "ember-load-initializers": "~0.1.7",
    "ember-qunit": "0.4.13",
    "ember-qunit-notifications": "0.1.0",
    "font-awesome": "~4.4.0",
    "fullcalendar": "~2.4.0",
    "hint.css": "~1.3.5",
    "jquery": "2.1.4",
    "jquery-knob": "~1.2.11",
    "jquery-mockjax": "~2.0.1",
    "loader.js": "3.4.0",
    "moment": ">= 2.8.0",
    "moment-timezone": "0.4.1",
    "qunit": "~1.18.0",
    "ember-uploader": "0.3.9",
    "fullcalendar": "~2.4.0",
    "js-cookie": "2.0.4",
    "dom-ruler": "~0.1.13"
  },
  "devDependencies": {
    "blanket": "~1.1.5"
  }
}

Wrong dependancy

Hi! According to README package.json should declare ember dependency like this:

'ember': '>1.12.0'

should I do sent a PR?

Ember 2.10: ember serve fails for 0.5.19

After upgrading to Ember 2.10 and upgrading ember-autoresize from working 0.5.16 → 0.5.19, ember s fails with the error:

The Broccoli Plugin: [SourceMapConcat: Concat: Vendor /assets/vendor.js] failed with:
Error: ENOENT: no such file or directory, stat '/mypath/tmp/source_map_concat-input_base_path-pRZd4RXb.tmp/bower_components/dom-ruler/dist/amd/dom-ruler.js'
    at Error (native)
    at Object.fs.statSync (fs.js:987:18)
    at FSMonitor._measure (/mypath/node_modules/heimdalljs-fs-monitor/index.js:66:21)
    at Object.statSync (/mypath/node_modules/heimdalljs-fs-monitor/index.js:82:30)
    at Concat.keyForFile (/mypath/node_modules/broccoli-caching-writer/index.js:87:20)
    at Array.map (native)
    at Concat.CachingWriter._conditionalBuild (/mypath/node_modules/broccoli-caching-writer/index.js:109:65)
    at /mypath/node_modules/broccoli-plugin/read_compat.js:93:34
    at tryCatch (/mypath/node_modules/rsvp/dist/rsvp.js:538:12)
    at invokeCallback (/mypath/node_modules/rsvp/dist/rsvp.js:553:13)

The broccoli plugin was instantiated at:
    at Concat.Plugin (/mypath/node_modules/broccoli-plugin/index.js:7:31)
    at Concat.CachingWriter [as constructor] (/mypath/node_modules/broccoli-caching-writer/index.js:18:10)
    at new Concat (/mypath/node_modules/broccoli-concat/concat.js:33:17)
    at module.exports (/mypath/node_modules/broccoli-concat/index.js:26:10)
    at EmberApp.concatFiles (/mypath/node_modules/ember-cli/lib/broccoli/ember-app.js:369:10)
    at EmberApp._concatFiles (/mypath/node_modules/ember-cli/lib/broccoli/ember-app.js:382:15)
    at EmberApp.javascript (/mypath/node_modules/ember-cli/lib/broccoli/ember-app.js:1270:12)
    at EmberApp.toArray (/mypath/node_modules/ember-cli/lib/broccoli/ember-app.js:1646:10)
    at EmberApp.toTree (/mypath/node_modules/ember-cli/lib/broccoli/ember-app.js:1668:30)
    at module.exports (/mypath/ember-cli-build.js:67:16)

Please release new version with Babel 6

I notice that you have ember-cli-babel listed as version 6.x in master but not in the latest release. Could you please release a version with babel 6?

Thanks!

Please provide a Changelog

Hi, 👋

It would be useful to get the list of changes and bugfixes between versions, with migrations notes or recommendations if any. For now we have to check in the code or git history if any change in the API was made, and it can take some time when you have a lot of dependencies to update.

Please publish a GitHub release for the last version v1.3.2 with what changed and reasons behind the major version update, and provide a CHANGELOG.md file or GitHub releases.

See for example https://gist.github.com/ungoldman/476a87abd16cd970bb9f

Thank you. ❤️

If this had a fallback for IE, that'd be amazing.

IE doesn't support CSS resize and the jQuery plugins that exist are not CSS-intelligent and they really want you to download a bunch of jquery-ui stuff (including stylesheets).

If this was intelligent that would be amazing.

I'd even send over an internet hug.

No way to set a default value unless autoResizeText configurable?

I would like to have it use the placeholder, or be able to give it a string to use in case the placeholder is not being used. Is there a way to do that? I tried a few things but nothing seems to work. I apologize if I'm missing something obvious, as is often the case with me!

I'm doing something like this on focusOut to ensure the field always has a value but it seems the textfield resizes to only fit . from autoResizeText and doesn't resize to accommodate the text being inserted:

if(this.$('input').val()===''){
        this.$('input').val('default value');
    }

If I could set the autoResizeText property directly or the value it uses then it would be perfect.

Update demo page

The demo page hasn't been updated in 7 months, and it doesn't reflect the current API. For example, the code it shows uses maxHeight instead of max-height.

HierarchyRequestError in iOs 8.3 Safari

HierarchyRequestError: DOM Exception 3: A Node was inserted somewhere it doesn't belong.

It's taken me about 6 hours to finally pin this down. I can walk you through the details if you're interested but I'll assume you want to be spared.

The gist: I get the above error when:

  1. Using an old iphone, (I can replicated it using the simulator with iOS 8.3 and safari AND
  2. Transitioning to a page that has an autoresizing textarea (not directly loading the page) AND
  3. The site's built using the production env (doesn't happen in dev)

I've tracked it down to your injectAdobeBlank() function in system/font-loaded.js. If I comment out the contents of that function I do not receive the error and everything works

I feel a little crazy because of how ridiculously specific this is. I'm not sure it's of any use. How necessary is adobe blank?

Ember                     : 1.13.10
Ember Data                : 1.13.11
ember-autoresize                 : 0.5.10

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml
  • The new Node.js version is in-range for the engines in 1 of your package.json files, so that was left alone

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.