Category Archives: html5 components

Auto Resizing Textarea HTML5 WebComponent

Just finished my next experiment with HTML5 WebComponents. AcidJs.XTextarea is an advanced replacement of the classic <textarea /> HTML element, supporting custom events and auto resizing as-you-type. Check the extensive documentation in the distribution file (click the download button at the top of the demo page) or scroll this page to see the demos.

thumb

Usage

<acdisj-xtextarea></acdisj-xtextarea>
<acdisj-xtextarea placeholder="Type your message..." id="textarea-1" name="textarea-1" rows="5" cols="40"></acdisj-xtextarea>
<acdisj-xtextarea name="textarea-2" rows="10" cols="30" disabled></acdisj-xtextarea>
<acdisj-xtextarea name="textarea-5" autoresize="off" rows="5" cols="30"></acdisj-xtextarea>
<acdisj-xtextarea autofocus name="textarea-8" cols="60" rows="5"></acdisj-xtextarea>
<acdisj-xtextarea name="textarea-4" hidden></acdisj-xtextarea>

HTML Attributes of the Component

Apart from the form attributes like name, rows, cols, placeholder, spellcheck, autofocus, disabled and readonly etc. and the HTML standard attributes such is id and style AcidJs.XTextarea supports one custom property, allowing to turn the autoresizing off:

  • [autoresize="off"]

JavaScript API – Methods, Accessors and Events

The component supports all standard JavaScript methods querySelector, querySelectorAll, getElementById, etc. plus the following custom methods, accessors and events:

Methods

  • enable() – the method enables back a previously disabled textbox by using the disable() method, the enabled accessor or the disabled and readonly properties.
  • disable() – the method disables the queried textbox, so no user input is possible.
  • getValue() – the method returns the current value of the queried textbox, similar to the enabled accessor.
  • setValue(String|null) – the method sets new value to the queried textbox.

Accessors

  • enabled – gets or sets the enabled state of the textbox. Use Boolean value for the setter.
  • value – gets or sets value of the textbox. The setter requires a string or empty value.

Events

  • type – the event is triggered upon user input and returns an object, containing the current value of the textbox to which the event handler is bound to:
    {
        data: "Lorem ipsum dolor sit amet..."
    }
    /*
     * Bind to the "type" event of the textbox
     **/
     $("#my-textarea").on("type", function(e, data) {
         window.console.log("textbox event:", e.type, data);
     });

If you share the same interest towards HTML5 Web Components as I do these days, make sure you read my relevant blog posts and further endeavors on my HTML5, CSS3 and JavaScript Experiments and Insight website.

Corporate BS Generator HTML5 WebComponent

Nothing serious this time, just a small fun HTML5 WebComponent, inspired by BS Generator, stitching-up (bullshit) sentences out of random buzzwords:

thumb

Usage:

<acidjs-xbsgenerator></acidjs-xbsgenerator>

The component does not have it’s own methods, setters, getters or styles. Just use the tag wherever you want.

If you share the same interest towards HTML5 Web Components as I do these days, make sure you read my relevant blog posts and further endeavors on my HTML5, CSS3 and JavaScript Experiments and Insight website.

5 Years of Ribbon JS!

Ribbon JS is turning 5 this month! If you are planning to purchase a license, now it’s the time. Join the celebration and get any commercial license for the most advanced and feature-complete JavaScript, HTML5 and CSS3 MSOffice-like ribbon control available on the Internet today at a half price only in August 2015!

ribbonjs.promo

EU Cookie Consent HTML5 Web Component

AcidJs.XCookieConsent is a ready-made, fully customizable solution to the EU Cookie Law, wrapped as a custom HTML5 Web Component.

thumb

The component is being used on this blog as well. If you have dismissed the cookie consent bar, click the button below to open show it again:

Using the Tag *

First, go to the demo page and download the sample project, then try one of the following (you need just one instance of the tag on your page).

<acidjs-xcookie-consent>
This website uses cookies to ensure you get the best experience.
</acidjs-xcookie-consent>
<acidjs-xcookie-consent position="top" dismiss-button-text="Understood">
This website uses cookies to ensure you get the best experience.
</acidjs-xcookie-consent>
<acidjs-xcookie-consent dir="rtl"></acidjs-xcookie-consent>

* The message should be set between the <acidjs-xcookie-consent></acidjs-xcookie-consent> tag and HTML is supported. If no content is set, the default text will be “This website uses cookies to ensure you get the best experience“.

HTML Attributes of the Tag

Apart from the standard HTML attributes, the following component-specific ones are supported:

  • position – optional position of the cookie consent bar. By default, position is "bottom", the possible value is "top".
  • dismiss-button-text – optional custom text for the dismiss button. If not set, the default value is "Got it!"

Direction is also supported – you could try dir="rtl" or dir="ltr" (default).

JavaScript Methods of the Tag

Apart from the standard JavaScript methods, getters and setters, the following component specific methods are also supported:

  • show() – to programmatically show the cookie consent bar. Calling this method will, however not delete the _acidjs_xcookie_consent_dismissed cookie.
    // JavaScript
    document.querySelector("acidjs-xcookie-consent").show();
    // jQuery
    $("acidjs-xcookie-consent").get(0).show();
  • hide() –  to programmatically hide the cookie consent bar. This will, however not set the _acidjs_xcookie_consent_dismissed cookie.  Cookie will be set only if user clicks the button to dismiss the message.
    // JavaScript
    document.querySelector("acidjs-xcookie-consent").hide();
    // jQuery
    $("acidjs-xcookie-consent").get(0).hide();
    

If you share the same interest towards HTML5 Web Components as I do these days, make sure you read my relevant blog posts and further endeavors on my HTML5, CSS3 and JavaScript Experiments and Insight website.

Ribbon JS 4.1.0 is Out

I’ve just released a new minor version for Ribbon JS introducing a couple of new features, properties and methods. The new version is fully backwards compatible with the previous versions of the control (4.0.0 and above), so it is safe to upgrade. The HTML5 Web Component for Ribbon JS has also been updated to support the latest additions.

ribbon.js.scr

Release Notes

  • New highlightTabsGroup method, allowing contextual tab grouping. The method supports custom colors and labels.
  • New unhighlightTabsGroup method, which removes a tab group, set via the highlightTabsGroup method.
  • New enableFlatStyles method, allowing to set flat (Metro) look and feel to the ribbon.
  • New disableFlatStyles method, setting back the classic (pre Office 2013) styles to the ribbon.
  • New appIconUrl property, set in the constructor of a ribbon, allowing custom top left application icon. The property is optional, and the default icon is the HTML5 badge.
  • New flat property (optional, Boolean), set in the constructor of a ribbon. If set to true applies flat (Metro) look and feel to the ribbon. Its default value is false.

Screenshots

ribbonjs.4.1.0

Ribbon JS is arguably the best recreation of the MS Officetm ribbon bar, using JavaScript, CSS3, and HTML5. It is a lightweight control, which is ready to use on websites, web-based WYSIWYG editors, sophisticated back-end systems, mail applications, complex file managers, and JavaScript-heavy apps. It has everything you would expect from a ribbon bar – comprehensive and fully documented API, amazing command handling, huge set of inbuilt tools, capability to add custom tools via client-side templates, cool looks and is also available optionally wrapped as a full-blown HTML5 WebComponent. Last but not least, it only takes a few minutes to deploy, configure, and run.