npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

fohn-ui

v1.8.1

Published

Javascript library for Fohn-Ui php framework.

Downloads

63

Readme

Fohn-ui js package

Javascript package for Fohn-Ui PHP framework.

Install via cdn:

This the default installation when using Fohn-Ui PHP framework.

<script type="application/javascript" src="https://unpkg.com/fohn-ui@{VERSION}/dist/fohn-ui.min.js"></script>

Install locally:

You may want to create your own custom javascript integration to Fohn-Ui. Therefore, you would need a local copy in order to build your own release. Then have Fohn-Ui to load your local copy instead of the cdn version.

Clone the git repository and install.

git clone https://github.com/Fohn-Group/fohn-js.git
cd fohn-js
npm install

Adjust the webpack.config.js outputDir value to where you want build file to be placed.

module.exports = (env) => {
  
  const isProduction = env.production || env.distribution;
  const srcDir = path.resolve(__dirname, './src');
  const outputDir = PATH_TO_PUBLIC_FOLDER;
    // rest of configuraiton
}

Run development mode npm run dev or production mode npm run build

Install within your own package.

If you need to include this package within your own, you can simply install via npm.

npm install fohn-ui

In order to be able to use existing Fohn-ui js component, jquery plugin or service, the package will need to export the fohn library for Fohn-Ui php framework.

import fohn from 'fohn-ui';

const myLib = {
    fohn: fohn,
}

export default myLib;

Then in Fohn-Ui php framework simply set up the Ui service jsLibrary property:

Ui::service()->jsLibrary = 'myLib.fohn';

Note:

Fohn uses jQuery as an external library. In order to work correctly, you will need to add the external property to your package build in webpack.config.js.

module.exports = {
    // Webpack config.
    externals: { jQuery: 'jQuery'},
}

Getting package version

Calling this function in your custom js script or in console will output the package version number.

    fohn.version();

Services

All services are export via the fohn global object. You can access them via fohn.serviceName. Certain functionalities are offered from these services.

For example, if one of your script need to send an ajax request directly, you could use the apiService.processRequestResponse to run and evaluate the server response from Fohn-Ui.

    $.getJSON( "myajax.php", function( resp ) {
      fohn.apiService.processRequestResponse(resp);
     });

Another example would be the upload service for file uploading using one of your script.

    fohn.uploadService.uploadFiles(
      filesArraytoUpload,
      theElement,
      {data: 'value'},
      url,             
      onComplete(){}, // the callback function when upload is complete.
      onXhr(){}       // the callback function when uploading files is in progress.
    );

jQuery plugin

The fohn global object may be used as a quick way of registering a jQuery plugin under the fohn namespace.

Let's create a new jQuery plugin that will change every selected dom element text color to green.

    fohn.registerPlugin('Greenify', function(el) {
        $(el).css("color", "green");
    }, false, myNameSpace)

The plugin can now by invoke using:

    // Change all div color text to green.
    $('div').myNameSpaceGreenify();