Giter Club home page Giter Club logo

widearea's Introduction

Widearea

Lightweight, easy-to-use JavaScript/CSS library to create expandable textarea and write large amount of text easily.

How to use

Really simple. Just include both widearea.js and widearea.css in your page (use minified version for production) and then call this JavaScript function:

wideArea();

See online demo.

API

###wideArea([selector])

Creating a Widearea object.

Available since: v0.1.0

Parameters:

  • selector : String (optional) Should be defined to search for textareas in a specific container

Returns:

  • wideArea object.

Example:

wideArea() //without selector, to search all textarea(s) in the page
wideArea("#writingContainer") //search for textarea(s) only in #writingContainer

###wideArea.setOption(option, value)

Set a single option to wideArea object.

Available since: v0.1.0

Parameters:

  • option : String Option key name.

  • value : String/Number Value of the option.

Returns:

  • wideArea object.

Example:

wideArea().setOption("defaultColorScheme", "dark");

###wideArea.setOptions(options)

Set a group of options to the wideArea object.

Available since: v0.1.0

Parameters:

  • options : Object Object that contains option keys with values.

Returns:

  • wideArea object.

Example:

wideArea().setOptions({ defaultColorScheme: "dark", closeIconLabel: "Exit" });

###wideArea.clearData(value)

Clear the textarea value from localStorage

Available since: v0.3.0

Parameters:

  • value : Object | String | Number This method accept parameter with different types
    1. Object for clearing data using DOM object
    2. String for clearing data using CSS selector
    3. Number for clearing data using the widearea id

Returns:

  • wideArea object.

Example:

wideArea().clearData(1); //clear textarea data with `data-widearea-id` == 1
wideArea().clearData("#first"); //clear textarea data with `#first` selector
wideArea().clearData($("#first")); //get DOM object with jQuery and pass it to clearData()

###Options:

  • wideAreaAttr: Extra attribute name for detecting textareas that uses Widearea, default is data-widearea
  • exitOnEsc: Close Fullscreen mode when pressing Escape, default is true
  • defaultColorScheme: Default color scheme, default is light
  • closeIconLabel: Close icon label, default is Close WideArea.
  • changeThemeIconLabel: Change color scheme icon label, default is Toggle Color Scheme
  • fullScreenIconLabel: Fullscreen mode icon label, default is WideArea Mode
  • autoSaveKeyPrefix: Prefix key for localStorage items

Build

First you should install nodejs and npm, then first run this command: npm install to install all dependencies.

Now you can run this command to minify all static resources:

make build

Roadmap

  • More browser compatibility
  • Provide more examples
  • Add templating option

Release History

  • v0.3.0 - 2013-07-26

    • Add auto-save option for all textareas
    • Bug fixes
  • v0.2.0 - 2013-06-07

    • Basic changes in initiating WideArea
    • Remove WideArea div wrapper
    • Code refactoring
  • v0.1.1 - 2013-05-26

    • Adding tab-key support while typing
    • Fix some bugs in multiple textareas
    • Fix bug when textarea has an existing value
  • v0.1.0 - 2013-05-22

    • First commit.

Author

Afshin Mehrabani

Ehsan Arasteh

License

Copyright (C) 2012 Afshin Mehrabani ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

widearea's People

Contributors

afshinm avatar beastburn avatar ehsandotnet avatar svoboda-jan avatar viliamkopecky 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  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  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

widearea's Issues

Existing textarea class name is duplicated when adding widearea class

Hello,

inside widearea.js:

//add widearea class to textarea
currentTextArea.className += (currentTextArea.className + " widearea").replace(/^\s+|\s+$/g, "");

The '+' should be eliminated to prevent duplicating the existing class name and to prevent destroying the css layout.

Comma missing from line 59, leaking variable

From just looking at the code, there seems to be a missing comma/semi-colon. From the line:

wideAreaIcons    = document.createElement('div')

Which causes the fullscreenIcon variable to leak to global.

That said, if you haven't already, I would advice Linting/Hinting your code. There are some patterns you shouldn't do. Like all those defines inside loops.

Chrome BUG: value not being filled for textarea

Using this in a Ruby on Rails form_for when trying to set the value of a textarea with some text, Chrome does not add the text to the textarea box. Firefox has no problem with this.

This is with Chrome 27.0.1453.93 on OSX 10.7.5

After removing the data-widarea=enable, the form correctly loads the value of the text again.

WideareaMode icon

When there is more content that can't fit in textarea widow and the scrollbar appears the icon overflows the scrollbar. But that also happens with zenmode here on github forms.

Errors after ajax page load

When using this with Rails with turbolinks (standard in Rails 4) you get an endless loop of:

Uncaught TypeError: Cannot read property 'offsetWidth' of null

WideArea icon expanded beyond screen

I have several widescreen textareas on my screen. It seems that if I put my mouse in the center of the screen, the wideare becomes clickable, yet I'm no where near the actual button.

Any ideas on how to fix?

Screenshot 2022-12-02 4 52 29 AM

Focus change on Tab

When expanded, TAB will change focus, but the expanded view means you can't tell what control does have focus. Not sure the best answer, but I would say one of two options:

1). Hitting tab actually inserts a tab character (most likely what the user wanted in the first place), which would also work the same when the view is normal (not expanded).

  1. Hitting TAB functions the same was as hitting ESC, if the view is expanded, it returns to normal. Hitting TAB while not expanded continues to tab to the next element as usual.

Prefilling with Localstorage-Values is messing with "real" content in forms

I have an php-based Application, where a user can create and edit posts.
When I edit any post and submit the form, the Localstorage does not get flushed automatically, which prefills the textarea marked with data-widearea= true" whenever I edit another post. Of course, the Text coming from the localstorage is not the correct content when I edit another post/record, since it is the textareas content coming from the "last-edited" post.

Would it be possible to automatically call wideArea().clearData() whenever a form is submitted?

I know this is kind of an individual problem, but I can Imagine a lot of people are using wideare.js in contexts, where editing Records via the same form-templates is a normal workflow…

I'm sticking to v0.2 for now… just wanted to let you know!

Best regards and thanks for your great js-libraries!

Original <textarea>'s scrollbar persists when entering fullscreen

On OS X if you enter fullscreen while the scrollbar is visible it will persist on the screen (see attached). I don't have time to investigate right now, but I'd imagine blurring/focusing will solve the problem.

STEPS TO REPRODUCE:

  1. Enter enough text to cause the <textarea> to scroll
  2. Move the mouse over the expand icon
  3. Scroll and click

EXPECTED RESULTS:
The scrollbar disappears before entering fullscreen

ACTUAL RESULTS:
The scrollbar remains on the screen

NOTES:
The above repro steps are deceivingly convoluted – I was able to make it happen easily, but those steps help ensure it occurs.

ENVIRONMENT:
Mac OS X 10.8.3, Chrome 26.0.1410.65

ATTACHMENTS:
screen shot 2013-05-28 at 9 07 54 am

Fullscreen icon duplicated

I didn't see this until I resized my window for another purpose, and then I noticed that the fullscreen icon is duplicated and when we resize the screen, one of them stick to the same position and it is not a cache issue

bug

bug report

on line 144 of widearea.js 0.3.0

currentTextArea.className += (currentTextArea.className + " widearea").replace(/^\s+|\s+$/g, "");

This will produce:

<textarea class="form-controlform-control wideared"></textarea>

It should be written like this:

currentTextArea.className = (currentTextArea.className + " widearea").replace(/^\s+|\s+$/g, "");

Remove created widearea

How would I disable what had been created by a widearea() call? I am using it in a backbone.js application and when I change views I would like to disable and remove the result of calling widearea(). Do I only need to remove the generated html? Or is there more cleanup to do? Thanks for the help.

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.