(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var ui           = require( './../libs/ui.js' );
var formHandler  = require( './../libs/form.js' );
var fademenu     = require( './../libs/fademenu.js' );
var collapse     = require( './../libs/collapse.js' );
var onoff        = require( './../libs/onoff.js' );
var uploader     = require( './../libs/uploader.js' );
var tab          = require( './../libs/tab.js' );
var imgOption    = require( './../libs/image-option.js' );
var manage       = require( './../libs/manage.js' );
var option       = require( './../libs/fancy-option.js' );
var stat         = require( './../libs/stat.js' );
var buttonActive = require( './../libs/button-active.js' );
var selectPreview = require( './../libs/select-preview.js' );

(function($)
{
  "use strict";

  /*
   * Input name
   */
  $( '#ipjck-manage-page #ipjck-section-general #input-title' ).focusout( function()
  {
    var title  = $(this).val();
    var pageid = $( '#ipjck-value-pageid' ).val(); 

    $.ajax({
      url: ajaxurl+'?doajax=1&ipjck=1&action=getslug',
      type: "POST",
      dataType: "json",
      data: 'title='+title+'&pageid='+pageid,
      success: function (result)
      {
        if ( result.status == '1' ) {
          $( '#ipjck-section-general #input-slug' ).val( result.slug );
        }
      }
    });
  });

  /**
   * Tab menu
   */
  if ( $( '.ipjck-tab' ).length > 0 )
  {
    tab( $( '.ipjck-tab' ), {
      after_click: function( idtab, root ){
        var content = $( '#'+idtab );
        var title   = $( '.ipjck-title-content', content ).clone().removeClass( 'ipjck-hide' );
        $( '.ipjck-tab-title', root ).html( title );
        //
        //Save hide
        if ( content.hasClass( 'ipjck-save-hide' )){
          $( '.ipjck-top-submit, .ipjck-bottom-submit, .ipjck-bottom-action', root ).hide();
        } else {
          $( '.ipjck-top-submit, .ipjck-bottom-submit, .ipjck-bottom-action', root ).show();
        }
      },
      tab_init: function( idtab, root ) {
        var content = $( '#'+idtab );
        var title   = $( '.ipjck-title-content', content ).clone().removeClass( 'ipjck-hide' );
        $( '.ipjck-tab-title', root ).html( title );
        //
        //Save hide
        if ( content.hasClass( 'ipjck-save-hide' )){
          $( '.ipjck-top-submit, .ipjck-bottom-submit, .ipjck-bottom-action', root ).hide();
        } else {
          $( '.ipjck-top-submit, .ipjck-bottom-submit, .ipjck-bottom-action', root ).show();
        }
      }
    });
  }

  /**
   * fademenu
   */
  if ( $( '.ipjck-fademenu' ).length > 0 )
  {
    fademenu( $('.ipjck-fademenu' ) );
  }

  /**
   * collapse
   */
  if ( $( '.collapse' ).length > 0 )
  {
    collapse( $('.collapse' ) );
  }

  /**
   * on/off button
   */
  if ( $( '.ipjck-onoff' ).length > 0 ) {
    onoff( $( '.ipjck-onoff' ), {
      func_select: function( button, cont )
      {
        var root = cont.parents( '.ipjck-content-onoff' );
        if ( cont.hasClass( 'ipjck-onoff-action' ) && root.length > 0 )
        {
          var value = button.data( 'value' );
          if ( value == true ) {
            $( '.ipjck-content-onoff-main', root ).show();
          } else {
            $( '.ipjck-content-onoff-main', root ).hide();
          }
        }
      }
    });
  }

  /**
   * Image option
   */
  if ( $( '.ipjck-image-option' ).length > 0 ) {
    imgOption( $( '.ipjck-image-option' ), {
      after: function( value, input )
      {
        var root = $(input).parents( '.ipjck-wrap' );
        var row  = $(input).parents( '.ipjck-field-row' );
        if ( ! row.hasClass( 'ipjck-input-template' )) {
          return true;
        }
        var valnum = new Number( value );
        //
        //Modal change template
        if ( root.hasClass( 'ipjck-admin-modal' ) )
        {
          if ( valnum > 3 ) {
            $( '#ipjck-field-padding' ).hide();
            $( '#ipjck-field-padding2' ).show();
            $( '#ipjck-field-background' ).hide();
            $( '#ipjck-field-background2' ).show();
          } else {
            $( '#ipjck-field-padding' ).show();
            $( '#ipjck-field-padding2' ).hide();
            $( '#ipjck-field-background' ).show();
            $( '#ipjck-field-background2' ).hide();
          } 
          //Set label
          if ( valnum == 6 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp6_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp6_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp6_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp6_lbl );
          }
          else if ( valnum == 7 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp7_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp7_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp7_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp7_lbl );
          }
          else {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp3_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp3_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp3_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp3_lbl );
          }
        }
        //
        //Bar change template
        if ( root.hasClass( 'ipjck-admin-bar' ) )
        {
          if ( valnum == 2 || valnum == 3 ) {
            $( '#ipjck-field-media' ).show();
          } else {
            $( '#ipjck-field-media' ).hide();
          } 

          if ( valnum > 4 ) {
            $( '#ipjck-field-padding' ).hide();
            $( '#ipjck-field-padding2' ).show();
            $( '#ipjck-field-background' ).hide();
            $( '#ipjck-field-background2' ).show();
          } else {
            $( '#ipjck-field-padding' ).show();
            $( '#ipjck-field-padding2' ).hide();
            $( '#ipjck-field-background' ).show();
            $( '#ipjck-field-background2' ).hide();
          }


          //Set label
          if ( valnum == 5 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp6_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp6_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp6_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp6_lbl );
          }
          else if ( valnum == 6 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp7_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp7_lbl );
              
            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp7_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp7_lbl );
          }
          else {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp3_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp3_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp3_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp3_lbl );
          }
        }
        //
        //Slide change template
        if ( root.hasClass( 'ipjck-admin-slide' ) )
        {
          if ( valnum > 2 ) {
            $( '#ipjck-field-padding' ).hide();
            $( '#ipjck-field-padding2' ).show();
            $( '#ipjck-field-background' ).hide();
            $( '#ipjck-field-background2' ).show();
          } else {
            $( '#ipjck-field-padding' ).show();
            $( '#ipjck-field-padding2' ).hide();
            $( '#ipjck-field-background' ).show();
            $( '#ipjck-field-background2' ).hide();
          }

          //Set label
          if ( valnum == 3 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padd_main_sld3_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padd_sec_sld3_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_sld3_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_sld3_lbl );
          }
          else if ( valnum == 4 || valnum == 6 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padd_main_sld4_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padd_sec_sld4_lbl );
              
            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_sld4_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_sld4_lbl );
          }
          else if ( valnum == 5 ) {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padd_main_sld5_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padd_sec_sld5_lbl );
              
            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_sld5_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_sld5_lbl );
          }
          else {
            $( '#ipjck-field-padding2 label[for="input-box-main-padding"]' )
              .text( ipjck_padding_main_temp3_lbl );
            $( '#ipjck-field-padding2 label[for="input-box-sec-padding"]' )
              .text( ipjck_padding_sec_temp3_lbl );

            $( '#ipjck-field-background2 .ipjck-field-title-bg' )
              .text( ipjck_bg_main_temp3_lbl );
            $( '#ipjck-field-background2 .ipjck-field-title-bg2' )
              .text( ipjck_bg_sec_temp3_lbl );
          }
        }
      }
    });
  }

  /**
   * Fancy option
   */
  if ( $( '.ipjck-fancy-option' ).length > 0 ) {
    option( $( '.ipjck-fancy-option' ));
  }

  /**
   * Input uploader
   */
  if ( $( '.ipjck-upload-image' ).length > 0 ) {
    uploader( $( '.ipjck-upload-image' ));
  }

  //
  //Color picker
  //
  if ( $('.ipjck-color-picker').length > 0 )
  {
    $('.ipjck-color-picker').each( function() {
      var picker = $(this);
      picker.wpColorPicker({
        change: function(event, ui){
          picker.val( ui.color.toString() );
        }
      });
    });
  }
  /*
   * Date time picker
   */
  if ( $( '.ipjck-date-picker' ).length > 0 )
  {
    $('.ipjck-date-picker').datepicker({
      format: 'yyyy/mm/dd'
    });
  }
  if ( $( '.ipjck-time-picker' ).length > 0 )
  {
    $('.ipjck-time-picker').timepicker({
      minuteStep: 10,
      showInputs: false,
      disableFocus: true,
      showMeridian: false,
      defaultTime: false
    });
  }

  /*
   * Select button action
   */
  $( '.input-button-action' ).change( function()
  {
    var root  = $(this).parents( '.ipjck-button-action-fields' );
    var value = $(this).val();
    $( '.ipjck-button-action-fields', root ).hide();
    $( '.ipjck-button-action-' + value, root ).show();
  });

  /*
   * Date time picker
   */
  //$( '.ipjck-end-date' ).datetimepicker();

  //
  //Input Share button
  if ( $( '#input-social-button-style' ).length > 0 )
  {
    //Style preview
    selectPreview( $( '#input-social-button-style' ), {
      cont_preview_selector:  '.ipjck-icon-preview',
      item_preview_class:     'ipjck-icon',
      root_image:             ipjck_img_url + 'icon/',
      preview_data:
      [
        'facebook',
        'twitter',
        'googleplus',
        'linkedin',
        'tumblr',
        'pinterest',
        'stumbleupon',
        'digg'
      ]
    });
  }

  /*
   * Autoresponder
   */
  $( '.ipjck-input-optin' ).each( function()
  {
    var input = $(this);
    var cont  = input.parents( '#ipjck-section-form' );

    input.focusout( function()
    {
      var html   = encodeURIComponent( input.val() );
      var parent = $( '.ipjck-optin-settings', cont );
      var action = ajaxurl+'?doajax=1&ipjck=1&action=getoptin';
      $.ajax({
        url: action,
        type: "POST",
        data: 'html='+html,
        dataType: "json",
        success: function ( result ) {
          if ( result.status == 1 )
          {
            var fields = [];
            if ( result.data.fields ) {
              fields = result.data.fields;
            }
            $( '.ipjck-input-autoresponder-action', parent ).val( result.data.action );
            $( 'select', parent ).html( '' );
            for ( var i=0; i<fields.length; i++ )
            {
              var option = '<option value="'+fields[i]+'">'+fields[i]+'</option>';
              $( 'select', parent ).append( option );
            }
            parent.show();
          }
        },
      });
    });
  });

  /**
   * Form modal handler
   */
  var formModalCreate = new formHandler( '#ipjck-form-modal-add' );
  formModalCreate.is_add = true;
  //Additional data
  formModalCreate.additional_data = function( data )
  {
    if ( this.is_add ) {
      data += '&isadd=1';
    }
    return data;
  };
  formModalCreate.init();

  var formModalEdit = new formHandler( '#ipjck-form-modal-update' );
  formModalEdit.init(); 

  //
  //Delete modal
  if ( $('.ipjck-item-modal-delete').length > 0 ) {
    var delete_url = ajaxurl+'?doajax=1&ipjck=1&action=delete_modal';
    manage.delete( $( '.ipjck-item-modal-delete' ), delete_url );
  } 

  /**
   * Form bar handler
   */
  var formBarCreate = new formHandler( '#ipjck-form-bar-add' );
  formBarCreate.is_add = true;
  //Additional data
  formBarCreate.additional_data = function( data )
  {
    if ( this.is_add ) {
      data += '&isadd=1';
    }
    return data;
  };
  formBarCreate.init();

  var formBarEdit = new formHandler( '#ipjck-form-bar-update' );
  formBarEdit.init(); 

  //
  //Delete bar
  if ( $('.ipjck-item-bar-delete').length > 0 ) {
    var delete_url = ajaxurl+'?doajax=1&ipjck=1&action=delete_bar';
    manage.delete( $( '.ipjck-item-bar-delete' ), delete_url );
  } 

  /**
   * Form slide handler
   */
  var formSlideCreate = new formHandler( '#ipjck-form-slide-add' );
  formSlideCreate.is_add = true;
  //Additional data
  formSlideCreate.additional_data = function( data )
  {
    if ( this.is_add ) {
      data += '&isadd=1';
    }
    return data;
  };
  formSlideCreate.init();

  var formSlideEdit = new formHandler( '#ipjck-form-slide-update' );
  formSlideEdit.init(); 

  //
  //Delete slide
  if ( $('.ipjck-item-slide-delete').length > 0 ) {
    var delete_url = ajaxurl+'?doajax=1&ipjck=1&action=delete_slide';
    manage.delete( $( '.ipjck-item-slide-delete' ), delete_url );
  } 
  

  /**
   * Form page handler
   */
   var formPageCreate = new formHandler( '#ipjck-form-page-add' );
   formPageCreate.is_add = true;
   //Additional data
   formPageCreate.additional_data = function( data )
   {
       if ( this.is_add ) {
           data += '&isadd=1';
       }
       return data;
   };
   formPageCreate.init();

   var formPageEdit = new formHandler( '#ipjck-form-page-update' );
   formPageEdit.init();

   //
   //Delete page
   if ( $('.ipjck-item-page-delete').length > 0 ) {
       var delete_url = ajaxurl+'?doajax=1&ipjck=1&action=delete_page';
       manage.delete( $( '.ipjck-item-page-delete' ), delete_url );
   }

	//
	//Change media type
  $( '#ipjck-input-media-type' ).change( function()
  {
    var value = $(this).val();
    $( '.ipjck-fields-media-image, .ipjck-fields-media-video' ).hide();
    if ( value == 'image' ) {
      $( '.ipjck-fields-media-image' ).show();
    }
    else if ( value == 'video' ) {
      $( '.ipjck-fields-media-video' ).show();
    }
  });

  //Change group options
	$( '.ipjck-section-select-options' ).change( function()
	{
		var value   = $(this).val();
    var wrapper = $(this).parents( '.ipjck-section-select' )[0];
    var content = $( '#ipjck-section-' + value, wrapper );
    
    $( '.ipjck-section-select-content', wrapper ).hide();
    if ( content.length > 0 )
    {
      content.show(); 
    }
	});

  //
  //Settings form handler
  var formSetting = new formHandler( '#ipjck-form-setting' );
  formSetting.init();

  //Change widget type
  $( '#ipjck-sett-general-type' ).change( function()
  {
    var type = $(this).val();
    $( '.ipjck-sett-general-widget' ).hide();
    $( '#ipjck-sett-general-' + type ).show();
  });

  //Change widget type
  $( '#ipjck-sett-home-type' ).change( function()
  {
    var type = $(this).val();
    $( '.ipjck-sett-home-widget' ).hide();
    $( '#ipjck-sett-home-' + type ).show();
  });

  //
  //Preview
  //
  $( '.ipjck-page-menu-preview' ).click( function()
  {
    var widget = $( '.ipjck-preview-widget .ipjck-widget' );
    showWidget( widget );

    return false;
  });

  function showWidget( widget )
  {
    var content = $( '.ipjck-widget-content', widget );
    var overlay = $( '.ipjck-widget-overlay', widget );
    var setting = $( '.ipjck-setting-effect', widget );
    var effect  = setting.data( 'show_effect' );
    var speed   = setting.data( 'show_speed' );

    if ( effect == 'none' || typeof effect == 'undefined' ) {
      effect = 'transition.bounceIn';
    }

    overlay.css( 'opacity', 0 );
    widget.show();

    content.velocity( effect, {
      duration: speed
    });

    if ( widget.hasClass( 'ipjck-modal' ))
    {
      overlay.velocity({
        opacity: overlay.attr( 'data-opacity' ),
        duration: 500
      });
    }

    //
    //play audio
    playAudio( 'show', widget );
  };

  //
  //Close widget
  //
  $( '.ipjck-preview-widget .ipjck-widget .ipjck-close-button' ).click( function()
  {
    var widget = $(this).parents( '.ipjck-widget' );
    hideWidget( widget );

    return false;
  });


  function hideWidget( widget )
  {
    var content = $( '.ipjck-widget-content', widget );
    var overlay = $( '.ipjck-widget-overlay', widget );
    var setting = $( '.ipjck-setting-effect', widget );
    var effect  = setting.data( 'hide_effect' );
    var speed   = setting.data( 'hide_speed' );

    if ( effect == 'none' || typeof effect == 'undefined' ) {
      effect = 'transition.bounceOut';
    }

    content.velocity( effect, {
      duration: speed,
      complete: function()
      {
        setTimeout( function()
        {
          widget.hide();
        },1000 );
      }
    });

    if ( widget.hasClass( 'ipjck-modal' ))
    {
      overlay.velocity({
        opacity: 0,
        duration: 500
      });
    }

    //
    //play audio
    playAudio( 'hide', widget );
  };

  function playAudio( type, root )
  {
    if ( type == 'hide' ) {
      var audio = $( '.ipjck-audio-hide', root );
      if ( audio.length > 0 ) {
          audio[0].play();
      } 
    } else
    {
      var audio = $( '.ipjck-audio-show', root );
      if ( audio.length > 0 ) {
          audio[0].play();
      }
    }
  };

  //
  //Edited message
  //
  if ( $( '.ipjck-message-edited' ).length > 0 )
  {
    $( '.ipjck-message-edited' ).animate({top: "0"}, 800, function()
    {
      var object = $( this );
      setTimeout( function(){
        object.animate({top: '-100px'}, 800, function(){
            object.remove();
        });
      }, 4000);
    });
  }

  //
  //Statistic
  //
  if ( $( '.ipjck-statistic-page' ).length > 0 ) {
      stat( $( '.ipjck-statistic-page' ), {
          chart_id: 'ipjck-chart-div',
          ajax_url: ajaxurl+'?doajax=1&ipjck=1&action=getchartpage'
      });
  }
  if ( $( '.ipjck-statistic' ).length > 0 ) {
      stat( $( '.ipjck-statistic' ), {
          chart_id: 'ipjck-chart-div',
          ajax_url: ajaxurl+'?doajax=1&ipjck=1&action=getchart'
      });
  }

})(jQuery);

},{"./../libs/button-active.js":3,"./../libs/collapse.js":4,"./../libs/fademenu.js":5,"./../libs/fancy-option.js":6,"./../libs/form.js":7,"./../libs/image-option.js":8,"./../libs/manage.js":9,"./../libs/onoff.js":10,"./../libs/select-preview.js":11,"./../libs/stat.js":12,"./../libs/tab.js":13,"./../libs/ui.js":14,"./../libs/uploader.js":15}],2:[function(require,module,exports){
var ui = require( './../libs/ui.js' );

(function($)
{
  "use strict";

  $(document).ready(function()
  {
    //
    //Init ui
    ui.base.modal.prototype.top_margin = '20px';
    var modal  = new ui.base.modal();

    ui.base.loader.prototype.image_base  = ipjck_img_url;
    ui.base.loader.prototype.loader_file = 'loading.gif';
    var loader  = new ui.base.loader();
    var message = new ui.base.message();

    var winWidth = $(window).width();

    //
    //Form horizontal setup
    function formHorizontalSetup()
    {
      $( '.ipjck-form-horizontal' ).each( function()
      {
        var form   = $(this);
        var widget = form.parents( '.ipjck-widget' );
        widget.show();

        var formWidth  = form.width();
        var btnWidth   = $( '.ipjck-form-submit', form ).width();
        var fieldWidth = formWidth - btnWidth - 15;
        $( '.ipjck-fields', form ).width( fieldWidth );
        $( '.ipjck-form-input', form ).width( fieldWidth - 20 );

        widget.hide();
      });
    };
    formHorizontalSetup();

    //
    //Fixed widget height
    if ( $( '.ipjck-bar.ipjck-template-5' ).length > 0 )
    {
      var widget = $( '.ipjck-bar.ipjck-template-5' );
      widget.show();
      var contentHeight = $( '.ipjck-widget-content', widget ).height();

      $( '.ipjck-widget-main', widget ).height( contentHeight );
      $( '.ipjck-widget-main-inner', widget ).innerHeight( contentHeight );
      $( '.ipjck-widget-secondary', widget ).height( contentHeight );

      widget.hide();
    }
    if ( $( '.ipjck-bar.ipjck-template-6' ).length > 0 )
    {
      var widget = $( '.ipjck-bar.ipjck-template-6' );
      widget.show();
      var contentHeight = $( '.ipjck-widget-secondary', widget ).height();

      $( '.ipjck-widget-main', widget ).height( contentHeight+20 );
      $( '.ipjck-widget-main-inner', widget ).innerHeight( contentHeight+20 );

      widget.hide();
    }

    //
    //Fixed modal full
    if ( $( '.ipjck-modal-full' ).length > 0 )
    {
      $( '.ipjck-modal-full' ).each( function()
      {
        var modal = $(this);
        modal.show();

        var modalHeight   = $( '.ipjck-widget-inner', modal ).height();
        var contentHeight = $( '.ipjck-widget-main', modal ).height();
        var contentTop    = (modalHeight - contentHeight - 100)/2;
        $( '.ipjck-widget-content', modal ).css( 'paddingTop', contentTop + 'px' );

        modal.hide();
      });
    }

    //
    //Widget library
    //
    var IPScri_Widget =
    {
      //
      //Submit form subscribe
      //
      subscribeSubmit: function( widget )
      {
        var $this = this;

        //
        //Submit form subscribe
        //
        $( '.ipjck-form-submit button', widget ).click( function()
        {
          var button   = $(this);
          var form     = button.parents( '.ipjck-form' );
          var root     = button.parents( '.ipjck-widget' );
          var sett     = $( '.ipjck-setting-submission', root );
          var widgetId = sett.data( 'id' );

          //
          //Check email
          var email = $( '#ipjck-input-email', form ).val();
          if ( email == '' || email == ' ' ) {
            $( '.ipjck-form-message' ).removeClass( 'show' );
            $( '#ipjck-message-email-empty' ).addClass( 'show' );
            return false;
          }
          if ( ! $this.validateEmail( email ) ) {
            $( '.ipjck-form-message' ).removeClass( 'show' );
            $( '#ipjck-message-email-wrong' ).addClass( 'show' );
            return false;
          }

          var name  = '';
          if ( $( '#ipjck-input-name', form ).length > 0 )
          {
            var name = $( '#ipjck-input-name', form ).val();
            if ( name == '' || name == ' ' ) {
              $( '.ipjck-form-message' ).removeClass( 'show' );
              $( '#ipjck-message-name-empty' ).addClass( 'show' );
              return false;
            }
          }

          //Show loader
          $( '.ipjck-form-message' ).removeClass( 'show' );
          loader.show();

          //
          //Save stat
          $.ajax({
            url: ipjck_ajaxurl+'?doajax=1&ipjck=1&action=save_subscribe',
            type: "POST",
            data: 'widget_id='+widgetId+'&email='+email+'&name='+name,
            dataType: "json",
            success: function ( result )
            {
              //Hide loader
              loader.hide();

              if ( result.status == 0 )
              {
                $( '.ipjck-form-message' ).removeClass( 'show' );
                $( '#ipjck-message-error .ipjck-alert span' ).text( result.message );
                $( '#ipjck-message-error' ).addClass( 'show' );
                return false;
              }
              else
              {

                $( '.ipjck-form-message' ).removeClass( 'show' );
                $( '#ipjck-message-success .ipjck-alert span' ).text( result.message );
                $( '#ipjck-message-success' ).addClass( 'show' );

                //
                //Form submit
                $( 'form', root )[0].submit();
                //
                //Save cookie
                $this.saveSubmitCookie( root );
              }

            }
          });
          return false;
        });
      },

      //
      //Validating email
      //
      validateEmail: function(email)
      {
        var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
        return re.test(email);
      },

      //
      //Button adn link click handler
      //
      buttonSubmit: function( widget )
      {
        var $this = this;

        $( '.ipjck-action-button .ipjck-button, .ipjck-action-link .ipjck-link, .ipjck-action-social .ipjck-social-button', widget  )
          .click( function()
          {
            loader.show();

            var href       = $(this).attr( 'href' );
            var widget     = $(this).parents( '.ipjck-widget' );
            var submission = $( '.ipjck-setting-submission', widget );
            var widgetId   = submission.attr( 'data-id' );

            //
            //Save stat
            $.ajax({
              url: ipjck_ajaxurl+'?doajax=1&ipjck=1&action=savestat',
              type: "POST",
              data: 'widget_id='+widgetId+'&type=click',
              dataType: "json",
              success: function ( result )
              {
                window.location.href = href;
              }
            });

            return false;
          });
      },

      //
      //Close message
      //
      closeMessage: function( widget )
      {
        $( '.ipjck-form-message a', widget ).click( function()
        {
          var msg = $(this).parents( '.ipjck-form-message' );
          msg.removeClass( 'show' );
          return false;
        });
      },

      //
      //Behaviour
      //
      behaviour: function( widget )
      {
        var $this = this;
        //
        //First Show widget
        //
        if ( widget.hasClass( 'ipjck-widget-first-visible' ) )
        {
          $this.showWidget( widget );
        }
        //
        //After show widget
        //
        if ( widget.hasClass( 'ipjck-widget-first-after' ) )
        {
          var behaviour = $( '.ipjck-setting-behaviour', widget );
          var delay = behaviour.attr( 'data-show-delay' );
          delay *= 1000;

          setTimeout( function()
          {
            $this.showWidget( widget );
          }
          ,delay);
        }
        //
        //Behaviour widget
        //
        var effect    = $( '.ipjck-setting-effect', widget );
        var behaviour = $( '.ipjck-setting-behaviour', widget );

        //
        //Exit intent
        var exit = behaviour.attr( 'data-exit-intent' );
        if ( exit == 1 )
        {
          $('body').on('mouseleave', function () {
            setTimeout( function(){ $this.showWidget( widget ); }, 400 );
          });
        }

        //
        //Scroll
        var scroll = behaviour.attr( 'data-user-scroll' );
        var pageId = behaviour.attr( 'data-scroll-id' );
        var height = behaviour.attr( 'data-scroll-height' );

        var scrollIsShow = false;
        if ( scroll == 1 )
        {
          $(window).scroll( function()
          {
            if ( scrollIsShow ) {
              return true;
            }
            var scrollTop = $(window).scrollTop();
            if ( pageId != '' && $( '#'+pageId ).length > 0 )
            {
              var scrollContent = $( '#'+pageId ).offset().top;
              if ( scrollTop > scrollContent ) {
                $this.showWidget( widget );
                scrollIsShow = true;
              }
            }
            else if ( height != '' )
            {
              var heightNum = new Number( height );
              if ( scrollTop > heightNum ) {
                $this.showWidget( widget );
                scrollIsShow = true;
              }
            }
          });
        }

        //
        //Inactive
        //
        var inactive = behaviour.attr( 'data-user-inactive' );
        var time     = behaviour.attr( 'data-inactive-time' );

        if ( inactive == 1 )
        {
          var idleTimer = null;
          var idleState = false;
          var idleWait  = time*1000;

          $('*').bind('mousemove keydown scroll', function ()
          {
            clearTimeout(idleTimer);

            idleState = false;
            idleTimer = setTimeout(function()
            {
              idleState = true;
            }, idleWait);
          });

          var idleInterval = setInterval( function()
          {
            if ( idleState == true )
            {
              clearInterval( idleInterval );
              $this.showWidget( widget );
            }
          },100);
        };
      },

      //
      //Close widget
      //
      closeWidget: function( widget )
      {
        var $this = this;

        $( '.ipjck-close-button', widget ).click( function()
        {
          $this.hideWidget( widget );
          return false;
        });
      },

      //
      //Miniming widget
      //
      minimizeWidget: function( widget )
      {
        //
        //Setup Minimize widget
        //
        var content = $( '.ipjck-widget-content', widget );
        content.attr( 'data-height', content.height() );
        content.css( 'overflow', 'hidden' );

        $( '.ipjck-widget .ipjck-minimize-button', widget ).click( function()
        {
          var content = $( '.ipjck-widget-content', widget );
          var height  = content.attr( 'data-height' );
          var headHeight = $( '.ipjck-header', widget ).outerHeight();

          if ( widget.hasClass( 'minimized' ) )
          {
            content.velocity({
              height: height+'px',
              duration: 500
            });
            widget.removeClass( 'minimized' );
          }
          else
          {
            content.velocity({
              height: headHeight+4+'px',
              duration: 500
            });
            widget.addClass( 'minimized' )
          }
          return false;
        });
      },

      //
      //Show widget
      //
      showWidget: function( widget )
      {
        //
        //Check cookie
        //
        var behaviour  = $( '.ipjck-setting-behaviour', widget );
        var submission = $( '.ipjck-setting-submission', widget );
        var widgetId   = submission.attr( 'data-id' );

        var useCookie = behaviour.attr( 'data-cookies' );
        if ( useCookie == 1 )
        {
          var cookieClosing = this.getCookie( '__ipjck_repeat_closing' );
          var cookieConvers = this.getCookie( '__ipjck_repeat_conversion' );
          if ( ( cookieClosing && cookieClosing == 1 ) ||
               ( cookieConvers && cookieConvers == 1 )
          ) {
            return false;
          }
        }

        var content = $( '.ipjck-widget-content', widget );
        var overlay = $( '.ipjck-widget-overlay', widget );
        var setting = $( '.ipjck-setting-effect', widget );
        var effect  = setting.data( 'show_effect' );
        var speed   = setting.data( 'show_speed' );

        if ( effect == 'none' || typeof effect == 'undefined' ) {
          effect = 'transition.bounceIn';
        }

        overlay.css( 'opacity', 0 );
        widget.show();

        var winWidth     = $(window).width();
        var hideInMobile = setting.attr( 'data-disable-mobile' );

        if ( hideInMobile != 1 && winWidth < 480 )
        {
          content.show();
          overlay.css( 'opacity', 1 );
        }
        else
        {

          content.velocity( effect, {
            duration: speed
          });

          if ( widget.hasClass( 'ipjck-modal' ))
          {
            overlay.velocity({
              opacity: overlay.attr( 'data-opacity' ),
              duration: 500
            });
          }

          //
          //play audio
          this.playAudio( 'show', widget );
        }

        //
        //Save stat
        $.ajax({
          url: ipjck_ajaxurl+'?doajax=1&ipjck=1&action=savestat',
          type: "POST",
          data: 'widget_id='+widgetId+'&type=view',
          dataType: "json",
          success: function ( result ) {}
        });

      },

      //
      //Hide widget
      //
      hideWidget: function( widget )
      {
        var content = $( '.ipjck-widget-content', widget );
        var overlay = $( '.ipjck-widget-overlay', widget );
        var setting = $( '.ipjck-setting-effect', widget );
        var effect  = setting.data( 'hide_effect' );
        var speed   = setting.data( 'hide_speed' );

        if ( effect == 'none' || typeof effect == 'undefined' ) {
          effect = 'transition.bounceOut';
        }

        var winWidth     = $(window).width();
        var hideInMobile = setting.attr( 'data-disable-mobile' );

        if ( hideInMobile != 1 && winWidth < 480 )
        {
          content.hide();
          overlay.css( 'opacity', 0 );
          widget.hide();
        }
        else
        {
          content.velocity( effect, {
            duration: speed,
            complete: function()
            {
              setTimeout( function()
              {
                widget.hide();
              },1000 );
            }
          });

          if ( widget.hasClass( 'ipjck-modal' ))
          {
            overlay.velocity({
              opacity: 0,
              duration: 500
            });
          }

          //
          //play audio
          this.playAudio( 'hide', widget );
        }

        //
        //Save cookie
        this.saveCloseCookie( modal );
      },

      //
      //Playing audio
      playAudio: function( type, root )
      {
        if ( type == 'hide' ) {
          var audio = $( '.ipjck-audio-hide', root );
          if ( audio.length > 0 ) {
              audio[0].play();
          }
        } else
        {
          var audio = $( '.ipjck-audio-show', root );
          if ( audio.length > 0 ) {
              audio[0].play();
          }
        }
      },

      //
      //Save cookie when closing widget
      //
      saveCloseCookie: function( widget )
      {
        var behaviour = $( '.ipjck-setting-behaviour', widget );
        var useCookie = behaviour.attr( 'data-cookies' );

        if ( useCookie == 1 )
        {
          var day = behaviour.attr( 'data-closing' );
          this.createCookie( '__ipjck_repeat_closing', 1, day );
        }
      },

      //
      //Save cookie when submiting
      //
      saveSubmitCookie: function( widget )
      {
        var behaviour = $( '.ipjck-setting-behaviour', widget );
        var useCookie = behaviour.attr( 'data-cookies' );

        if ( useCookie == 1 )
        {
          var day = behaviour.attr( 'data-conversion' );
          this.createCookie( '__ipjck_repeat_conversion', 1, day );
        }
      },

      //
      //Creating cookie
      //
      createCookie: function(name, value, expires, path, domain)
      {
        var cookie = name + "=" + escape(value) + ";";

        if (expires) {
          // If it's a date
          if(expires instanceof Date) {
            // If it isn't a valid date
            if (isNaN(expires.getTime()))
             expires = new Date();
          }
          else
            expires = new Date(new Date().getTime() + parseInt(expires) * 1000 * 60 * 60 * 24);

          cookie += "expires=" + expires.toGMTString() + ";";
        }

        if (path)
          cookie += "path=" + path + ";";
        if (domain)
          cookie += "domain=" + domain + ";";

        document.cookie = cookie;
      },

      //
      //Get cookie value
      //
      getCookie: function(name)
      {
        var regexp = new RegExp("(?:^" + name + "|;\s*"+ name + ")=(.*?)(?:;|$)", "g");
        var result = regexp.exec(document.cookie);
        return (result === null) ? null : result[1];
      }

    };

    //
    //Main widget
    if ( $( '.ipjck-widget' ).length > 0 )
    {
      $( '.ipjck-widget' ).each( function()
      {
        var widget    = $(this);
        var behaviour = $( '.ipjck-setting-behaviour', widget );
        var effect    = $( '.ipjck-setting-effect', widget );
        var isPreview = widget.hasClass( 'ipjck-widget-preview' );

        //
        //Hide in mobile
        var winWidth     = $(window).width();
        var hideInMobile = behaviour.attr( 'data-disable-mobile' );
        if ( hideInMobile == 1 && winWidth < 768 ) {
          widget.remove();
        }

        if ( ! isPreview && ! ( hideInMobile == 1 && winWidth < 768 ) )
        {
          IPScri_Widget.subscribeSubmit( widget );
          IPScri_Widget.buttonSubmit( widget );
          IPScri_Widget.closeMessage( widget );
          IPScri_Widget.behaviour( widget );
          IPScri_Widget.closeWidget( widget );
          IPScri_Widget.minimizeWidget( widget );
        }
      });
    };

    //
    //Page click link
    //
    if ( $( '.ipjck-content' ).length > 0 )
    {
      var opt    = $( '.ipjck-content' ).attr( 'data-replace-link' );
      var pageId = $( '.ipjck-content' ).attr( 'data-page-id' );

      $( '.ipjck-content a' ).click( function()
      {
        if ( opt == '1' && pageId )
        {
          //Show loader
          loader.show();

          var href = $(this).attr( 'href' );

          $.ajax({
            url: ipjck_ajaxurl+'?doajax=1&ipjck=1&action=savestatpage',
            type: "POST",
            data: 'page_id='+pageId+'&type=click',
            dataType: "json",
            success: function ( result ) {
              window.location.href = href;
            }
          });
          return false;
        }
      });
    }

  });
})(jQuery);

},{"./../libs/ui.js":14}],3:[function(require,module,exports){
/*
 *===========================================================
 * Button active
 *===========================================================*/

var buttonActive;
(function($)
{
    "use strict";

    buttonActive = function( button, options )
    {
        var defaults  = {
            func_select: function( button ){}
        };
        var opt = $.extend( defaults, options );

        button.click( function()
        {
            if ( $(this).hasClass( 'active' )) {
                $(this).removeClass( 'active' );
                $( 'input', $(this) ).val( 'off' );
            } else {
                $(this).addClass( 'active' );
                $( 'input', $(this) ).val( 'on' );
            }

            //Select callback
            opt.func_select( $(this) );
            return false;
        });
    };

})(jQuery);

module.exports = buttonActive;

},{}],4:[function(require,module,exports){
/*
 *===========================================================
 * Toggle/Collapse
 *===========================================================*/
var collapse;

(function($)
{
    "use strict";

    collapse = function( root )
    {
        //
        //init
        //
        $( '.intm-options-section' ).each( function()
        {
            if ( $(this).is( ":hidden" ) ) {
                $(this).addClass( '_tempshow' ).show();
            }
        });
        $( '.intm-option-fields' ).each( function()
        {
            if ( $(this).is( ":hidden" ) ) {
                $(this).addClass( '_tempshow' ).show();
            }
        });

        root.each( function()
        {
            var cont   = $(this);
            var height = $( '.collapse-content', cont ).height();
            $( '.collapse-trigger', cont ).click( function()
            {
                if ( cont.hasClass( 'open' ))
                {
                    cont.removeClass( 'open' );
                    cont.addClass( 'close' );
                    $( '.intm-panel-actions i', $(this) ).removeClass( 'intm-fa-chevron-down' );
                    $( '.intm-panel-actions i', $(this) ).addClass( 'intm-fa-chevron-right' );
                    $( '.collapse-content', cont )
                        .height( height )
                        .animate(
                            { height: 0 }, 500
                        );
                }
                else
                {
                    cont.removeClass( 'close' );
                    cont.addClass( 'open' );
                    $( '.intm-panel-actions i', $(this) ).removeClass( 'intm-fa-chevron-right' );
                    $( '.intm-panel-actions i', $(this) ).addClass( 'intm-fa-chevron-down' );
                    $( '.collapse-content', cont )
                        .height( 0 )
                        .show()
                        .animate(
                            { height: height }, 500
                        );

                }
                return false;
            });
        });

        $( '._tempshow' ).hide();
    };

})(jQuery);

module.exports = collapse;

},{}],5:[function(require,module,exports){
/*
 *===========================================================
 * Fade Menu
 *===========================================================*/
var fademenu;

(function($)
{
  "use strict";

  fademenu = function( root )
  {
    $(root).each( function()
    {
      var button = $(this);
      var mouse_in_menu = false;
      $( '.ipjck-fademenu-button', button ).click( function()
      {
        $( '.ipjck-fademenu-content' ).fadeOut( "fast" );
        $( '.ipjck-fademenu-button' ).removeClass( 'active' );

        var link    = $(this);
        var content = $( '.ipjck-fademenu-content', button );

        if ( content.is(":visible") ) {
          content.fadeOut( "fast" );
          link.removeClass( 'active' );
        } else {
          content.fadeIn( "fast" );
          link.addClass( 'active' );
        }
        return false;
      });

      $( '.ipjck-fademenu-content', button ).hover( function(){
        mouse_in_menu = true;
      }, function(){
        mouse_in_menu = false;
      });
      $( "body" ).click(function(){
        if ( ! mouse_in_menu ) {
          $( '.ipjck-fademenu-content', button ).fadeOut( "fast" );
          $( '.ipjck-fademenu-button', button ).removeClass( 'active' );
        }
      });
      $( '.ipjck-fademenu-content a', button ).click(function(){
        return true;
      });
    });
  };
})(jQuery);

module.exports = fademenu;

},{}],6:[function(require,module,exports){
/*
 *===========================================================
 * Fancy Option
 *===========================================================*/
var option;

(function($)
{
    "use strict";

    //Fancy option
    option = function( items, options ){

        var defaults  = {
            func_select: function( option ){},
        };
        var options = $.extend( defaults, options );

        //Setup
        $( '.ipjck-select li:first-child' ).addClass( 'ipjck-item-selected' );

        $(items).each( function(){

            var option  = $(this);
            var in_menu = false;

            $( '.ipjck-selected', option ).click( function(){

                var menu   = $(this);
                var select = $( '.ipjck-select', option );

                if ( select.is(":visible") ) {
                    select.fadeOut( "fast" );
                    menu.removeClass( 'active' );
                } else {

                    $( '.ipjck-select' ).each( function(){
                        $(this).fadeOut( "fast" );
                        $(this).parents( '.ipjck-selected' ).removeClass( 'active' );
                    });
                    select.fadeIn( "fast" );
                    menu.addClass( 'active' );
                }
                return false;
            });
            $( '.ipjck-select', option ).hover( function(){
                    in_menu = true;
                }, function(){
                    in_menu = false;
            });
            $( "body" ).click(function(){
                if ( ! in_menu ) {
                    $( '.ipjck-select', option ).fadeOut( "fast" );
                    $( '.ipjck-selected', option ).removeClass( 'active' );
                }
            });

            $( 'li', option ).click( function(){

                var item  = $(this);
                var label = $( '.ipjck-select-label', item ).clone().html();
                var data  = item.data( 'select' );
                $( '.ipjck-selected .ipjck-selected-box', option ).html( label );
                $( '.ipjck-select li', option ).removeClass( 'ipjck-item-selected' );
                item.parents( 'li' ).addClass( 'ipjck-item-selected' );
                $( '.ipjck-input-select', option ).val( data );

                //Hide Select box
                $( '.ipjck-select', option ).fadeOut( "fast" );
                $( '.ipjck-selected', option ).removeClass( 'active' );

                options.func_select( option );
            });

        });

    };

})(jQuery);

module.exports = option;

},{}],7:[function(require,module,exports){
/*
 *===========================================================
 * Form Handler
 *===========================================================
 */
 var formHandler;
 var uifunc = require( './../libs/ui.js' );

(function($)
{
    "use strict";

    //Prepare ui
    if (typeof ipjck_img_url != 'undefined') {
        uifunc.base.construct.prototype.image_base = ipjck_img_url;
    }
    uifunc.base.confirm.prototype.set_ajax = function( ajax_url )
    {
        this.ajax_url = ajax_url;
    };
    uifunc.init();

    /**
     * Form handler
     */
    function ip_form( id ){
        this.form   = $( id );
        this.action = this.form.attr( 'action' );
    }
    //Set vars
    ip_form.prototype =
    {
        //Variables
        button_id:          '.ipjck-form-submit',
        cont_id:            '.ipjck-form-container',
        error_process:      'Error',
        success_process:    'Success',
        ajax_type:          'POST',
        ajax_dataType:      'json',

        afterSuccess:        function(){},

        //Init
        init: function()
        {
            var $this = this;
            //Prepare
            this.prepare();
            //Form submit
            $( this.button_id, $this.form ).click( function()
            {
                if ( $this.validator() ) {
                    if ( $this.before() ) {
                        uifunc.loader.show();
                        var data   = $this.get_data();
                        var result = $this.process();
                        $this.after( result );
                    }
                }
                $this.error();
                return false;
            });
        },
        //Prepare form
        prepare: function(){},
        //Main process
        process: function()
        {
            var $this = this;
            var data  = $this.get_data();
            $.ajax({
                url: $this.action,
                type: $this.ajax_type,
                dataType: $this.ajax_dataType,
                data: data,
                success: function( result ) {
                    $this.ajax_success( result, $this );
                },
                error: function() {
                    $this.ajax_error( $this );
                }
            });
        },
        //Before process
        before: function()
        {
            return true;
        },
        //After process
        after: function( result ){},
        //Process if error
        error: function(){},
        //Process if ajax success
        ajax_success: function( result, $this )
        {
            $( '.ui-message', $this.form ).remove();
            uifunc.loader.hide();
            if ( result.status == 1 ) {
                if ( typeof result.redirect != 'undefined' ) {
                    window.location.href = result.redirect;
                } else {
                    if ( typeof result.reset != 'undefined' ) {
                        $this.form[0].reset();
                    }
                    uifunc.message.modal( result.message, 'alert-success' );
                    this.afterSuccess( result, $this );
                }
            } else {
                uifunc.message.modal( result.message, 'alert-danger' );
            }
        },
        //Process if ajax error
        ajax_error: function( $this )
        {
            uifunc.loader.hide();
            uifunc.message.modal( $this.error_process, 'alert-danger' );
        },

        //Validating form data
        validator: function()
        {
            return true;
        },
        check_empty: function( id, message )
        {
            var input = $( id );
            if ( input.val() == '' ) {
                uifunc.message.block( message, 'ip-ui-danger', input );
                return true;
            }
            return false;
        },

        //Get data form
        get_data: function()
        {
            var root = this.form;
            var selector  = 'input[type=text]';
            selector += ', input[type=hidden]';
            selector += ', input[type=password]';
            selector += ', input[type=radio]:checked';
            selector += ', input[type=checkbox]:checked';
            selector += ', textarea';
            selector += ', select';

            var data = '';
            $( selector, root ).each( function(){
                var name  = $(this).attr( 'name' );
                var value = encodeURIComponent( $(this).val() );

                if ( data != '' ) {
                    data += '&';
                }
                data += name+'='+value;
            });
            if (typeof tinyMCE !== 'undefined') {
                for ( var edId in tinyMCE.editors ) {

                    if ( edId.length > 1 ) {
                        var value = tinyMCE.editors[edId].getContent();
                        if ( data != '' ) {
                            data += '&';
                        }
                        data += edId+'='+value;
                    }
                }
            }
            data = this.additional_data( data );
            return data;
        },
        additional_data: function( data )
        {
            return data;
        },

        //Get tiny mce object
        get_tinymce: function( contentId )
        {
            var content = '';
            if (typeof tinyMCE !== 'undefined') {
                content = tinyMCE.get( contentId ).getContent();
            }
            return content;
        },
        //Set tiny mce object with a content
        set_tinymce: function( contentId, content )
        {
            if (typeof tinyMCE !== 'undefined') {
                tinyMCE.get( contentId ).setContent( content );
            }
        }
    };
    formHandler = ip_form;

})(jQuery);

module.exports = formHandler;

},{"./../libs/ui.js":14}],8:[function(require,module,exports){
/*
 *===========================================================
 *  Input image option
 *===========================================================*/
var option;

(function($)
{
    "use strict";

    option = function( root, options )
    {
        var defaults  = {
            after: function( value, input ){},
        };
        var options = $.extend( defaults, options );

        root.each( function()
        {
            var input = $(this);

            $( '._item', input ).click( function()
            {
                $( '._item', input ).removeClass( '_selected' );
                var value = $(this).data( 'value' );
                $(this).addClass( '_selected' );
                $( '._value-selected', input ).val( value );
                //
                //Callback
                options.after( value, input );
                return false;
            })
        });
    };

})(jQuery);

module.exports = option;

},{}],9:[function(require,module,exports){
/*
 *===========================================================
 * Manage script
 *===========================================================*/
var uifunc = require( './../libs/ui.js' );
var manage;

(function($)
{
    "use strict";

    var delete_confirm_title = '';
    var delete_confirm_info  = '';

    if (typeof ui_message != 'undefined') {
        if (typeof ui_message.delete_confirm_title != 'undefined') {
            delete_confirm_title = ui_message.delete_confirm_title;
        }
        if (typeof ui_message.delete_confirm_info != 'undefined') {
            delete_confirm_info = ui_message.delete_confirm_info;
        }
    }

    //Prepare ui
    if (typeof ui_base_image != 'undefined') {
        uifunc.base.construct.prototype.image_base = ui_base_image;
    }
    uifunc.base.confirm.prototype.set_ajax = function( ajax_url )
    {
        this.ajax_url = ajax_url;
    };

    uifunc.init();
    uifunc.delete_confirm = new uifunc.base.confirm();

    uifunc.delete_confirm.set_vars({
        title: delete_confirm_title,
        info: delete_confirm_info,
        yes_class:  'ipjck-btn ipjck-btn-md ipjck-btn-danger',
        no_class:   'ipjck-btn ipjck-btn-md ipjck-btn-default',
        action:     function( object, ui )
        {
            var id = object.data( 'id' );
            uifunc.loader.show();
            ui.hide( object );

            $.ajax({
                url: ui.ajax_url + '&id='+id,
                type: "POST",
                dataType: "json",
                success: function (result)
                {
                    if ( object.hasClass( 'ipjck-delete-edit' ) )
                    {
                        window.location.href = result.redirect;
                    } else
                    {
                        if ( result.status == '-1' ) {
                            uifunc.message.modal( result.message, 'alert-danger' );
                        } else {
                            uifunc.message.modal( result.message, 'alert-success' );
                            ui.vars.remove_element( object, ui );
                        }
                        uifunc.loader.hide();
                    }
                },
                error: function () {
                    alert( "Error in deleting item." );
                },
            });
        },
        remove_element: function( object, ui )
        {
            var tr = object.parents( 'tr' );
            console.log( object.parents( 'tr' ) );
            console.log( tr );
            tr.hide( 'blind' );
            setTimeout( function(){
                tr.remove();
            }, 600);
        }
    });

    manage = {
        delete: function( items, url )
        {
            $(items).each( function()
            {
                var button = $(this);
                button.click( function()
                {
                    uifunc.delete_confirm.set_ajax( url );
                    uifunc.delete_confirm.set_vars({
                        remove_element: function( object, ui ){
                            var cont   = object.parents( '.ipjck-manage-list' );
                            var item   = object.parents( '.ipjck-list-item' );
                            var length = $( '.ipjck-list-item', cont ).length;

                            item.hide( 'blind' );
                            if ( length == 1 ) {
                                $( '.ipjck-list-empty', cont ).show();
                            }
                            setTimeout( function(){
                                item.remove();
                            }, 600);
                        }
                    });
                    uifunc.delete_confirm.show( button );
                    return false;
                });
            });
        }
    }
})(jQuery);

module.exports = manage;

},{"./../libs/ui.js":14}],10:[function(require,module,exports){
/*
 *===========================================================
 * On Off Button
 *===========================================================*/
var onoff;

(function($)
{
    "use strict";

    /**
     * On Off button
     */
    onoff = function( root, options )
    {
        var defaults  = {
            func_select: function( button ){},
        };
        var options = $.extend( defaults, options );

        $(root).each( function(){

            var cont = $(this);
            $( '.ipjck-btn-onoff', cont ).click( function()
            {
                var value = $(this).data( 'value' );
                if ( ! $(this).hasClass( 'active' ) ) {
                    $( 'button', cont ).removeClass( 'active' );
                    $( 'button', cont ).removeClass( 'ipjck-btn-on' );
                    $( 'button', cont ).removeClass( 'ipjck-btn-off' );
                    if ( value == true ) {
                        $(this).addClass( 'ipjck-btn-on' );
                    } else {
                        $(this).addClass( 'ipjck-btn-off' );
                    }
                    $(this).addClass( 'active' );
                }
                $( '.ipjck-onoff-value', cont ).val(value);

                var field = $(this).parents( '.ipjck-field-row' );
                if ( field.hasClass( 'ipjck-toggle' )) {

                    if ( value == 'false' || value == false ) {
                        $( '.ipjck-toggle-option', field ).hide();
                    } else {
                        $( '.ipjck-toggle-option', field ).show();
                    }
                }
                options.func_select( $(this), cont );
                return false;
            });
        });
    };

})(jQuery);

module.exports = onoff;

},{}],11:[function(require,module,exports){
/*
 *===========================================================
 * Select preview
 *===========================================================*/

var selectPreview;

(function($)
{
    "use strict";

    selectPreview = function( input, options )
    {
        var defaults  = {
            cont_selector:          '.ipjck-field-row',
            cont_preview_selector:  '.ipjck-select-preview',
            item_preview_class:     'ipjck-preview',
            root_image:             '',
            preview_data:           [],
            func_select:            function( input ){}
        };
        var opt  = $.extend( defaults, options );
        var cont = input.parents( opt.cont_selector );

        input.change( function()
        {
            var select  = $(this).val();
            var preview = $( opt.cont_preview_selector, cont );
            var opts    = opt.preview_data;
            preview.html( '' );
            for (var i = 0; i < opts.length; i++)
            {
                var key = opts[i];
                var src = opt.root_image+select+'/'+key+'.png';
                preview.append(
                    '<span class="'+opt.item_preview_class+'"><img src="'+src+'" alt="'+key+'"></span>'
                );
            }
            opt.func_select( $(this) );
        });
    };

})(jQuery);

module.exports = selectPreview;

},{}],12:[function(require,module,exports){
/*
 *===========================================================
 * Tab menu
 *===========================================================*/
var stat;

(function($)
{
    "use strict";

    stat = function( object, options )
    {
        var defaults  = {
            ajax_url: '',
            chart_id:  'ipjck-chart-div'
        };
        var ipjck_opt = $.extend( defaults, options );

        var root = $(object);

        //Date picker
        $( '#date-start',root )
            .datepicker()
            .bind('changeDate', function(ev){
                $( '#date-start',root ).datepicker('hide');
            });

        $( '#date-end', root )
            .datepicker()
            .bind('changeDate', function(ev){
                $( '#date-end',root ).datepicker('hide');
            });

        //Do filter date
        $( '#do-filter-date', root ).click( function()
        {
            var dateStart = $( '#date-start' ).val();
            var dateEnd   = $( '#date-end' ).val();
            var pageId    = $( '#value-pageid' ).val();
            var type      = $( '#value-stat-type' ).val();

            //Show loader
            $( '.ipjck-chart-main', root ).html('').hide();
            $( '.ipjck-chart-load', root ).show();

            $.ajax({
                url: ipjck_opt.ajax_url,
                type: "POST",
                data: 'start='+dateStart+'&end='+dateEnd+'&pageid='+pageId+'&type='+type,
                dataType: "json",
                success: function (result ) {

                    $( '.ipjck-chart-main' ).show();
                    $( '.ipjck-chart-load' ).hide();
                    if ( result.status == 1 && result.data.length > 0 )
                    {
                        var dataTable = new google.visualization.DataTable();
                        dataTable.addColumn( 'date', result.labelDate );
                        dataTable.addColumn( 'number', result.labelValue );

                        var rows = [];
                        for (var i=0; i<result.data.length; i++)
                        {
                            var cur   = result.data[i];
                            var value = new Number( cur.value );
                            var data  = [ new Date( cur.year, cur.mon, cur.day ), value ];
                            rows.push( data );
                        }
                        dataTable.addRows( rows );
                        var options = {
                            series: [{pointSize:6}]
                        };
                        var chart = new google.visualization.LineChart(document.getElementById(ipjck_opt.chart_id));
                        chart.draw(dataTable, options);
                    }
                },
                error: function () {
                    alert( "Error in get statistic data" );
                },
            });

            return false;
        });

        //Stat Nav
        $( '.ipjck-stat-nav a' ).click( function()
        {
            if ( $(this).hasClass( 'ipjck-no-chart' )) {
                return false;
            }
            var link   = $(this);
            var root   = link.parents( 'li' );
            var type   = link.attr( 'href' ).replace( '#stat-', '' );
            var pageId = $( '#value-pageid' ).val();

            if ( root.hasClass( 'active' )) {
                return true;
            }
            $( '.ipjck-stat-nav li' ).removeClass( 'active' );
            root.addClass( 'active' );
            $( '#value-stat-type' ).val( type );

            //Show loader
            $( '.ipjck-chart-main' ).html('').hide();
            $( '.ipjck-chart-load' ).show();

            //Load cart
            $.ajax({
                url: ipjck_opt.ajax_url,
                type: "POST",
                data: 'pageid='+pageId+'&type='+type,
                dataType: "json",
                success: function (result ) {

                    $( '.ipjck-chart-main' ).show();
                    $( '.ipjck-chart-load' ).hide();
                    if ( result.status == 1 && result.data.length > 0 )
                    {
                        var dataTable = new google.visualization.DataTable();
                        dataTable.addColumn( 'date', result.labelDate );
                        dataTable.addColumn( 'number', result.labelValue );

                        var rows = [];
                        for (var i=0; i<result.data.length; i++)
                        {
                            var cur   = result.data[i];
                            var data  = [ new Date( cur.year, cur.mon, cur.day ), cur.value ];
                            rows.push( data );
                        }
                        dataTable.addRows( rows );
                        var options = {
                            series: [{pointSize:6}]
                        };
                        var chart = new google.visualization.LineChart(document.getElementById(ipjck_opt.chart_id));
                        chart.draw(dataTable, options);
                    }
                },
                error: function () {
                alert( "Error in get statistic data" );
                },
            });

            return false;
        });
    };

})(jQuery);

module.exports = stat;

},{}],13:[function(require,module,exports){
/*
 *===========================================================
 * Tab menu
 *===========================================================*/
var tab;

(function($)
{
    "use strict";

    tab = function( object, options )
    {
        var defaults  = {
            after_click:     function(){},
            tab_init:        function(){}
        };
        var opt  = $.extend( defaults, options );

        $(object).each( function()
        {
            var root = $(this);

            tab_init();

            $( '.ipjck-tab-menu a', root ).click( function()
            {
                clear_tab();
                $( this ).addClass( 'active' );

                var idtab = $(this).attr( 'href' ).replace( '#', '' );
                $( '#'+idtab ).show();
                $( '#ipjck-tab-selected' ).val( idtab );

                opt.after_click( idtab, root );

                return false;
            });

            function clear_tab()
            {
                $( '.ipjck-tab-menu a', root ).each( function(){
                    $(this).removeClass( 'active' );
                });
                $( '.ipjck-tab-content', root ).hide();
            };

            function tab_init()
            {
                clear_tab();
                $( '#ipjck-tab-selected', root ).hide();
                var current = $( '#ipjck-tab-selected' ).val();
                $( '#'+current ).show();
                $( 'a[href="#'+current+'"]' ).addClass( 'active' );
                $( '#ipjck-tab-selected' ).val( current );

                opt.tab_init( current, root );
            };
        });
    };

})(jQuery);

module.exports = tab;

},{}],14:[function(require,module,exports){
/*
 *===========================================================
 * UI
 *===========================================================
 */
var ui;

(function($)
{
    "use strict";

    //Inherit function
    function inherit( proto )
    {
        function F() {}
        F.prototype = proto
        return new F
    }

    /*
     *===========================================================
     * Ui prototype
     *===========================================================*/
    function ui_construct( options ){};

    ui_construct.prototype =
    {

        vars:               {},
        class_prefix:       'ipjck-',
        class_main:         '-main',
        class_title:        '-title',
        class_content:      '-content',
        class_disabled:     'disabled',
        class_close:        'ui-close',
        label_close:        'x',
        image_base:         '',

        top_margin:         '80px',
        overlay_speed:      600,
        main_speed:         400,
        show_speed:         4000,

        show_after:         function(){},
        hide_after:         function(){},

        popup_body: function( class_root, content, title, close )
        {
            var body = $( '<div class="'+class_root+'"></div>' );
            var main = $( '<div class="'+class_root + this.class_main+'"></div>' );
            if ( title )
            {
                var _title = $( '<div class="'+class_root + this.class_title+'"></div>' )
                                .append( '<h3>'+title+'</h3>' );
                if ( close )
                {
                    var _close = $( '<a href="#">'+this.label_close+'</a>' );
                    this.popup_close( _close, class_root );

                    _title.append(
                        $( '<div class="'+this.class_prefix+this.class_close+'"></div>' ).append( _close )
                    );
                }
                main.append( _title );
            }
            if ( content ) {
                main.append(
                    $( '<div class="'+class_root + this.class_content+'"></div>' ).append( content )
                );
            }
            body.append( main );
            return body;
        },
        popup_show: function( popup )
        {
            var c_root = popup.attr( 'class' );
            var main   = $( '.'+c_root+this.class_main, popup );
            popup.show();
            main.css( 'margin-top', '-40%' )
                .animate({marginTop: this.top_margin}, this.main_speed, this.show_after);
        },
        popup_hide: function( popup )
        {
            var c_root = popup.attr( 'class' );
            var main   = $( '.'+c_root+this.class_main, popup );

            popup.animate( {opacity: 0}, this.overlay_speed, function(){
                $(this).css( 'opacity', 1 )
                       .hide();
            });
            main.animate( {marginTop: '-60%'}, this.main_speed, this.hide_after);
        },
        popup_close: function( button, class_popup )
        {
            var ui = this;
            button.click( function(){
                var popup = $( '.'+class_popup );
                ui.popup_hide( popup );
                return false;
            });
        },
        is_load: function( selector )
        {
            if ( $( selector ).length > 0 ) {
                return true;
            }
            return false;
        },
        set_vars: function( options )
        {
            this.vars = $.extend(this.vars, options);
        },
        set_base_vars: function( options )
        {
            this.vars = $.extend(this, options);
        },
        go_to: function( selector )
        {
            var pos = $( selector ).position();
            $('html, body').animate({scrollTop: ( pos.top )}, 600);
            return false;
        }
    };

    /*
     * Modal Class
     **/
    function modal(){};
    modal.prototype = inherit( ui_construct.prototype );
    //Modal message
    modal.prototype.ajax = function( id, url )
    {
        var ui      = this;
        var c_root  = this.class_prefix + this.class_modal;
        var modal   = this.popup_body( c_root, '', false, false ).appendTo( $( 'body' ) );
        modal.addClass( class_type )
             .attr( 'id', id );

        this.popup_show( modal );
    };

    /*
     * Loader Class
     **/
    function loader(){};
    loader.prototype = inherit( ui_construct.prototype );
    //Properties
    loader.prototype.class_root     = 'ui-loader';
    loader.prototype.loader_file    = 'loading.gif';
    //Show loader
    loader.prototype.show = function()
    {
        var loader = this.create();
        this.popup_show( loader );
    };
    //Hide loader
    loader.prototype.hide = function()
    {
        var loader = this.create();
        this.popup_hide( loader );
    };
    //Create loader
    loader.prototype.create = function()
    {
        var c_root = this.class_prefix + this.class_root;
        if ( this.is_load( '.'+c_root )) {
            return $( '.'+c_root );
        } else
        {
            var image  = '<img src="'+this.image_base+this.loader_file+'" alt="Loading...">';
            var loader = this.popup_body( c_root, image, false, false ).appendTo( $( 'body' ) );
            loader.hide();

            return loader;
        }
    };


    /*
     * Inline loader Class
     **/
    function iloader(){};
    iloader.prototype = inherit( ui_construct.prototype );
    //Properties
    iloader.prototype.class_root   = 'ui-inline-loader';
    iloader.prototype.loader_file  = 'spin.gif';
    //Loader show
    iloader.prototype.show = function( button )
    {
        button.attr( 'disabled', 'disabled' );
        this.create( button ).show();
    };
    //Loader hide
    iloader.prototype.hide = function( button )
    {
        button.removeAttr( 'disabled' );
        this.create( button ).hide();
    };
    //Creating loader
    iloader.prototype.create = function( button )
    {
        var root   = button.parent();
        var lclass = this.class_prefix + this.class_root;
        if ( $( '.'+lclass, root ).length > 0 ) {
            var loader = $( '.'+lclass, root );
        } else {
            var image  = '<img src="'+this.image_base+this.loader_file+'" alt="Loading...">';
            var loader = $( '<span class="'+lclass+'"></span>' )
                            .append( image )
                            .css( 'margin-left', '8px' );
        }
        button.after( loader );
        return loader;
    };


    /*
     * Confirm popup
     **/
    function confirm( options )
    {
        var defaults = {
            title:      'Confirmation',
            info:       '',
            yes_label:  'Yes',
            no_label:   'Cancel',
            yes_class:  'btn btn-danger',
            no_class:   'btn btn-success',
            action:     function( object ){}
        };
        this.vars = $.extend(defaults, options);
    };
    confirm.prototype = inherit( ui_construct.prototype );
    //Properties
    confirm.prototype.class_root = 'ui-confirm';
    //Confirm show
    confirm.prototype.show = function( object )
    {
        var confirm = this.create( object );
        this.popup_show( confirm );
    };
    //Confirm hide
    confirm.prototype.hide = function( object )
    {
        var confirm = this.create( object );
        this.popup_hide( confirm );
    };
    //Creating confirm
    confirm.prototype.create = function( object )
    {
        var ui     = this;
        var c_root = this.class_prefix + this.class_root;
        if ( this.is_load( '.'+c_root )) {
            $( '.'+c_root ).remove();
        }
        //Create confirm
        var yesbtn = $( '<a href="#" class="ip-confirm-yes '+this.vars.yes_class+'">'+this.vars.yes_label+'</a>' );
        var nobtn  = $( '<a href="#" class="ip-confirm-no '+this.vars.no_class+'">'+this.vars.no_label+'</a>' );

        yesbtn.click( function(){
            ui.vars.action( object, ui );
            return false;
        });
        this.popup_close( nobtn, c_root );

        var content = $( '<div class="'+c_root+'-inner"></div>' )
            .append( '<p>'+this.vars.info+'</p>' )
            .append(
                $( '<div class="'+c_root+'-actions"></div>' )
                    .append( yesbtn )
                    .append( nobtn )
            );

        var confirm = this.popup_body( c_root, content, this.vars.title, false ).appendTo( $( 'body' ) );
        confirm.hide();

        return confirm;
    };


    /*
     * Alert popup
     **/
    function alert( options )
    {
        var defaults = {
            message:        '',
            label_button:   'Ok',
            class_root:     '',
            class_button:   'ipjck-btn ipjck-btn-sm ipjck-btn-danger',
            after:          function(){}
        };
        this.vars = $.extend(defaults, options);
    };
    alert.prototype = inherit( ui_construct.prototype );
    //Properties
    alert.prototype.class_root = 'ui-alert';
    //Alert show
    alert.prototype.show = function( message )
    {
        this.vars.message = message;
        var alert = this.create();
        this.popup_show( alert );
    };
    //Alert hide
    alert.prototype.hide = function()
    {
        var alert = this.create();
        this.hide_after = this.vars.after;
        this.popup_hide( alert );
    };
    //Creating alert
    alert.prototype.create = function()
    {
        var ui     = this;
        var c_root = this.class_prefix + this.class_root;
        if ( this.is_load( '.'+c_root )) {
            return $( '.'+c_root );
        } else
        {
            var button = $( '<a href="#" class="'+this.vars.class_button+'">'+this.vars.label_button+'</a>' );
            this.popup_close( button, c_root );

            var c_info  = c_root + '-inner';
            if ( this.vars.class_root != '' ) {
                c_info += ' ' + this.vars.class_root;
            }
            var content = $( '<div class="'+c_info+'"></div>' )
                .append( '<p>'+this.vars.message+'</p>' )
                .append(
                    $( '<div class="'+c_root+'-actions"></div>' )
                        .append( button )
                );

            var popup  = this.popup_body( c_root, content, false, false ).appendTo( $( 'body' ) );
            popup.hide();

            return popup;
        }
    };


    /*
     * Message
     **/
    function message(){};
    message.prototype = inherit( ui_construct.prototype );
    //Properties
    message.prototype.class_modal = 'ui-modal-message';
    message.prototype.class_block = 'ui-message';
    //Modal message
    message.prototype.modal = function( message, class_type )
    {
        var ui      = this;
        var c_root  = this.class_prefix + this.class_modal;
        var content = '<p>'+message+'</p>';
        var msg     = this.popup_body( c_root, content, false, false ).appendTo( $( 'body' ) );
        msg.addClass( class_type )
           .show()
           .animate({top: "0"}, ui.overlay_speed, function(){
                var object = $( this );
                setTimeout( function(){
                    object.animate({top: '-100px'}, ui.overlay_speed, function(){
                        object.remove();
                    });
                }, ui.show_speed);
            });
    };
    //Bloack message
    message.prototype.block = function( message, class_type, block, close )
    {
        var ui      = this;
        var c_root  = this.class_prefix + this.class_block;
        var parent  = block.parent();

        $( '.'+c_root, parent ).remove();

        var msg = $( '<div></div>' );
        msg.addClass( c_root )
           .addClass( class_type )
           .append( '<p>'+message+'</p>' );

        if ( close )
        {
            var _close = $( '<a href="#">'+this.close_label+'</a>' );
            _close.click( function()
            {
                var _msg = $(this).parents( '.'+c_root );
                _msg.animate({opacity: "0"}, ui.overlay_speed, function(){
                    _msg.remove();
                });
                return false;
            });
            msg.append(
                $( '<div class="'+this.class_prefix+this.class_close+'"></div>' ).append( _close )
            );
        }
        msg.css( 'opacity', '0' );
        parent.prepend( msg );
        msg.animate({opacity: "1"}, ui.overlay_speed);
    };

    ui =
    {
        base: {
            construct:  ui_construct,
            loader:     loader,
            iloader:    iloader,
            confirm:    confirm,
            message:    message,
            alert:      alert,
            modal:      modal

        },
        init: function()
        {
            this.loader  = new this.base.loader(),
            this.iloader = new this.base.iloader(),
            this.confirm = new this.base.confirm(),
            this.message = new this.base.message(),
            this.alert   = new this.base.alert(),
            this.modal   = new this.base.modal()
        }
    };

})(jQuery);

module.exports = ui;

},{}],15:[function(require,module,exports){
/*
 *===========================================================
 * Image uploader handle
 *===========================================================*/
var uploader;

(function($)
{
    "use strict";

    uploader = function( element, options )
    {
        var defaults  = {
            func_select: function( input ){},
        };
        var options = $.extend( defaults, options );

        $(element).each( function()
        {
            var root = $(this);
            var frame;
            $( '.ipjck-btn-media', root ).click( function(e)
            {
                var $el = $(this);
                e.preventDefault();

                // If the media frame already exists, reopen it.
                if ( frame ) {
                    frame.open();
                    return;
                }
                // Create the media frame.
                frame = wp.media.frames.customHeader = wp.media({
                    // Set the title of the modal.
                    title: $el.data('choose'),

                    // Tell the modal to show only images.
                    library: {
                        type: 'image'
                    },

                    // Customize the submit button.
                    button: {
                        // Set the text of the button.
                        text: $el.data('update'),
                        // Tell the button not to close the modal, since we're
                        // going to refresh the page when the image is selected.
                        close: false
                    }
                });

                // When an image is selected, run a callback.
                frame.on( 'select', function() {
                    // Grab the selected attachment.
                    var attachment = frame.state().get('selection').first();
                    var id         = attachment.id;

                    var url = '';
                    if (typeof attachment.attributes.sizes.thumbnail != 'undefined') {
                        url = attachment.attributes.sizes.thumbnail.url;
                    }
                    else if (typeof attachment.attributes.sizes.medium != 'undefined') {
                        url = attachment.attributes.sizes.medium.url;
                    }
                    else if (typeof attachment.attributes.sizes.full != 'undefined') {
                        url = attachment.attributes.sizes.full.url;
                    }

                    $( '.ipjck-upload-preview .none', root ).hide();
                    $( '.ipjck-upload-preview .image', root )
                        .html( '<img src="'+url+'" alt="" />' )
                        .show();
                    $( '.ipjck-image-id', root ).val( id );
                    $( '.ipjck-btn-reset', root ).show();

                    //Select callback
                    options.func_select( element );

                    frame.close();
                });
                frame.open();

                return false;
            });
            $( '.ipjck-btn-reset', root ).click( function(e)
            {
                $( '.ipjck-upload-preview .none', root ).show();
                $( '.ipjck-upload-preview .image', root ).html( '' ).hide();
                $( '.ipjck-image-id', root ).val( 0 );
                $( '.ipjck-btn-reset', root ).hide();
                return false;
            });
        });
    };

})(jQuery);

module.exports = uploader;

},{}]},{},[1,2]);
