The plugin has a large set of additional options that allow full customization. You can use custom HTML, CSS, own color palette, set observers and more.
PUP should work in any modern web browser (HTML 5) regardless of the user device (that includes mobile devices). It has been tested and confirmed to work on Windows, Mac, Linux and Android (Chrome).
Basic installation is easy as copy the following code into any HTML section of the target website. You can add custom options right on this code.
Note: You need to edit
data-url to match your website.
PUP works on the DOM so it doesn't have any server-side dependencies and it can be installed on any website.
All plugin customizations are handled via data attributes that you must add to PUP base code. As an example, to use the red color palette the code should look like this:
This applies to all PUP options. The format is data-key where key is the target option key, in this case the palette option is being declared as the
data-palette attribute value.
This is the list of all the plugin key options available.
URL of the target Fotoaly website.
Named color palette of the button or a comma-separated list of colors (HEX, RGB, etc.). When using a comma-separated list of colors, the system will bind each color to a
%n color index (starting at
%1) that you can use with custom CSS. Supported list of palette names:
Embed codes to auto insert in the target editable content. Default
. Codes using
will link to the image viewer page. Use
to disable auto insert. Supported embed codes strings:
Sibling CSS selector to use it as a reference to the DOM node where the button should be inserted. By default, the button will be placed relative to the editable content. When the sibling is defined, the plugin will search for that element and it will use it as the reference for button insertion. Value
Position, relative to the sibling, to place the button. Default
Named vendor string. Default
auto. Supported vendors strings:
Plugin mode. By default, the plugin binds to any matching editor box. Use
manual mode to explicitly insert the button and stop any automatic binding. Default
CSS selector for target editable content. Use it when manually inserting the button. Default
Button language for two-letter and four-letter language codes. Default
auto. Supported language strings:
Custom button container class name. It binds
%cClass to the template stack. By default, the system will use
Custom button class name. It binds
%bClass to the template stack. By default, the system will use
A boolean indicating if the plugin should fit the button to the target editor toolbar. Values
1 (enabled). When disabled, the plugin won't fit the button styling to the target editor (override valid only for supported vendors).
CSS selector for elements that on click event will trigger sibling observation and then button insertion. Useful for dynamic editors that generate editor code on the fly. Value
A boolean indicating if a matched observed element should be cached. Default
1 (enabled). When enabled, it will stop observing the matched observed element click events. Always disable observe cache if the editor is dynamically generated and not stored as a DOM node.
Custom HTML and CSS
PUP support custom templates and it includes template placeholders. A template placeholder is a special string that PUP will convert into usable markup. This is the list of template placeholders available:
For custom CSS, you can also use color palette placeholders in the form of
%n where n is the color palette index so it binds
Custom HTML works by indicating the template string as an option attribute. In this example, this is the custom HTML that we want to use:
<a %x title='%text' class='%bClass'>%iconSvg</a>
To use this template, simply assign
data-html right into the plugin code:
Custom CSS works exactly the same as custom HTML but it uses
data-button-css and color palette placeholders (
%n). In this example, this is the custom CSS that we want to use:
To use this template, simply assign
data-css right into the plugin code:
Important: For both custom HTML and CSS make sure to don't break the syntax when using quotes.
Manual button binding
To manually bind a button, simply create your own button make sure to add
data-target attributes. This is an example of a manually inserted button:
<div id="editor" contenteditable></div>
<button data-fotoaly-pup-trigger data-target="#editor">Custom button</button>
Manually inserted buttons get the same popup dialog functionality and binding. However, manually inserted buttons won't use any of the plugin options or templating.
This plugin has very neat functions and takes advantage of modern standards to provide its core functionality. These are some of the features shape the PUP core.
It works async so it doesn't matter where you place the insertion code and it won't render block the load of the target website at all.
Smart load and dynamic trigger observer
PUP is designed to observe the DOM until the target sibling element is available and soon as that happens, it will initiate its process and it will stop any additional DOM node observation. For dynamically generated editor boxes, PUP has a complimentary load option that observes the click event on a defined selector element. Any click on that element will trigger PUP's sibling observation and it will stop soon as the sibling gets found. This allows PUP to work in static or dynamic editor boxes.
Since some dynamic editor boxes will be generated just once and then stored as DOM nodes (XenForo) and others will be always re-parsed (Discourse, NodeBB), you can indicate if PUP should cache or not the observed triggered bindings. XenForo, Discourse and NodeBB vendors are configured to observe certain selectors just in case you want to learn how this works.
PUP uses postMessage API to keep an active communication with the target Fotoalywebsite. Options and embed codes are safely handled using this API which restricts the origin of the posted messagese and on top of that, PUP validates each message to ensure that there's no tempering on those either. PUP will only listen to messages from the target Fotoaly website.
PUP supports multiple unlimited instances. You can cast multiple buttons at the same time and all instance ids are referenced using the GUID algorithm.
PUP will cache the button template so it won't unnecessarily re-process the template placeholders. This grants super fast performance even in multiple instances.