0.2.2 • Published 8 years ago

jquery-asGalleryPicker v0.2.2

Weekly downloads
3
License
LGPL-3.0
Repository
github
Last release
8 years ago

jQuery asGalleryPicker bower NPM version Dependency Status prs-welcome

A jquery plugin that do amazing things.

Table of contents

Main files

dist/
├── jquery-asGalleryPicker.js
├── jquery-asGalleryPicker.es.js
├── jquery-asGalleryPicker.min.js
└── css/
    ├── asGalleryPicker.css
    └── asGalleryPicker.min.css

Quick start

Several quick start options are available:

Download the latest build

Install From Bower

bower install jquery-asGalleryPicker --save

Install From Npm

npm install jquery-asGalleryPicker --save

Install From Yarn

yarn add jquery-asGalleryPicker

Build From Source

If you want build from source:

git clone git@github.com:amazingSurge/jquery-asGalleryPicker.git
cd jquery-asGalleryPicker
npm install
npm install -g gulp-cli babel-cli
gulp build

Done!

Requirements

jquery-asGalleryPicker requires the latest version of jQuery and asScrollbar.

Usage

Including files:

<link rel="stylesheet" href="/path/to/asGalleryPicker.css">
<script src="/path/to/jquery.js"></script>
<script src="/path/to/jquery-asGalleryPicker.js"></script>

Required HTML structure

<div class="example"></div>

Initialization

All you need to do is call the plugin on the element:

jQuery(function($) {
  $('.example').asGalleryPicker(); 
});

Examples

There are some example usages that you can look at to get started. They can be found in the examples folder.

Options

jquery-asGalleryPicker can accept an options object to alter the way it behaves. You can see the default options by call $.asGalleryPicker.setDefaults(). The structure of an options object is as follows:

{
  namespace: 'asGalleryPicker',
  skin: null,
  lang: 'en',
  viewportSize: '330',
  disabled: false,

  tpl() {
    return '<div class="{{namespace}}">' +
      '<div class="{{namespace}}-initial">' +
      '<i></i>{{strings.placeholder}}' +
      '</div>' +
      '<div class="{{namespace}}-info">' +
      '<img class="{{namespace}}-info-image" src="">' +
      '<span class="{{namespace}}-info-count">{{strings.count}}</span>' +
      '<div class="{{namespace}}-info-add">{{strings.add}}</div>' +
      '<div class="{{namespace}}-info-expand">{{strings.expand}}</div>' +
      '</div>' +
      '<div class="{{namespace}}-expand">' +
      '<a class="{{namespace}}-expand-close" href="#"></a>' +
      '<div class="{{namespace}}-expand-add">' +
      '<i></i>{{strings.add}}' +
      '</div>' +
      '<ul class="{{namespace}}-expand-items">' +
      '</ul>' +
      '</div>' +
      '</div>';
  },

  process(value) {
    if (value) {
      return value.join(',');
    }
    return '';
  },

  parse(value) {
    if (typeof value === 'string' && value.length !== 0) {
      let array = [];
      array = value.split(",");
      return array;
    }
    return null;
  },
  getImage(value) {
    return value;
  },
  change(index) {
    return index;
  },
  add() {},
  onChange() {}
}

Methods

Methods are called on asGalleryPicker instances through the asGalleryPicker method itself. You can also save the instances to variable for further use.

// call directly
$().asGalleryPicker('destroy');

// or
var api = $().data('asGalleryPicker');
api.destroy();

get()

Get the image picked.

var icon = $().asGalleryPicker('get');

set()

Set the value.

$().asGalleryPicker('set', 'image.png');

val()

Get or set the value.

// get the value
var icon = $().asGalleryPicker('val'); 

// set the value
$().asGalleryPicker('set', 'image.png');

clear()

Clear the value.

$().asGalleryPicker('clear');

enable()

Enable the gallery picker functions.

$().asGalleryPicker('enable');

disable()

Disable the gallery picker functions.

$().asGalleryPicker('disable');

destroy()

Destroy the gallery picker instance.

$().asGalleryPicker('destroy');

Events

jquery-asGalleryPicker provides custom events for the plugin’s unique actions.

$('.the-element').on('asGalleryPicker::ready', function (e) {
  // on instance ready
});
EventDescription
initFires when the instance is setup for the first time.
readyFires when the instance is ready for API use.
enableFires when the enable instance method has been called.
disableFired when the disable instance method has been called.
destroyFires when an instance is destroyed.

No conflict

If you have to use other plugin with the same namespace, just call the $.asGalleryPicker.noConflict method to revert to it.

<script src="other-plugin.js"></script>
<script src="jquery-asGalleryPicker.js"></script>
<script>
  $.asGalleryPicker.noConflict();
  // Code that uses other plugin's "$().asGalleryPicker" can follow here.
</script>

Browser support

Tested on all major browsers.

Latest ✓Latest ✓Latest ✓Latest ✓9-11 ✓Latest ✓

As a jQuery plugin, you also need to see the jQuery Browser Support.

Contributing

Anyone and everyone is welcome to contribute. Please take a moment to review the guidelines for contributing. Make sure you're using the latest version of jquery-asGalleryPicker before submitting an issue. There are several ways to help out:

Development

jquery-asGalleryPicker is built modularly and uses Gulp as a build system to build its distributable files. To install the necessary dependencies for the build system, please run:

npm install -g gulp
npm install -g babel-cli
npm install

Then you can generate new distributable files from the sources, using:

gulp build

More gulp tasks can be found here.

Changelog

To see the list of recent changes, see Releases section.

Copyright and license

Copyright (C) 2016 amazingSurge.

Licensed under the LGPL license.

⬆ back to top