wp/wp-content/plugins/option-tree/assets/js/ot-admin.js
author ymh <ymh.work@gmail.com>
Mon, 14 Oct 2019 17:39:30 +0200
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 11 bf1778c34b9a
permissions -rwxr-xr-x
resynchronize code repo with production
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
/**
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
 * Option Tree UI
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
 * 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
 * Dependencies: jQuery, jQuery UI, ColorPicker
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
 *
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
 * @author Derek Herman (derek@valendesigns.com)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
 */
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
;(function($) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
  OT_UI = {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
    processing: false,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
    init: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
      this.init_hide_body();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
      this.init_sortable();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
      this.init_add();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
      this.init_edit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
      this.init_remove();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    17
      this.init_edit_title();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
      this.init_edit_id();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
      this.init_activate_layout();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    20
      this.init_conditions();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
      this.init_upload();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
      this.init_upload_remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
      this.init_numeric_slider();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
      this.init_tabs();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
      this.init_radio_image_select();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
      this.init_select_wrapper();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    27
      this.bind_select_wrapper();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    28
      this.init_google_fonts();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    29
      this.fix_upload_parent();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    30
      this.fix_textarea();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    31
      this.replicate_ajax();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    32
      this.reset_settings();
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    33
      this.css_editor_mode();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    34
      this.javascript_editor_mode();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    35
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    36
    init_hide_body: function(elm,type) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    37
      var css = '.option-tree-setting-body';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    38
      if ( type == 'parent' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    39
        $(css).not( elm.parent().parent().children(css) ).hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    40
      } else if ( type == 'child' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    41
        elm.closest('ul').find(css).not( elm.parent().parent().children(css) ).hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    42
      } else if ( type == 'child-add' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    43
        elm.children().find(css).hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    44
      } else if ( type == 'toggle' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    45
        elm.parent().parent().children(css).toggle();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    46
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    47
        $(css).hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    48
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
    init_remove_active: function(elm,type) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    51
      var css = '.option-tree-setting-edit';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    52
      if ( type == 'parent' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    53
        $(css).not(elm).removeClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    54
      } else if ( type == 'child' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    55
        elm.closest('ul').find(css).not(elm).removeClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
      } else if ( type == 'child-add' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
        elm.children().find(css).removeClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    59
        $(css).removeClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    60
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    61
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    62
    init_sortable: function(scope) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    63
      scope = scope || document;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    64
      $('.option-tree-sortable', scope).each( function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    65
        if ( $(this).children('li').length ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    66
          var elm = $(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    67
          elm.show();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    68
          elm.sortable({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    69
            items: 'li:not(.ui-state-disabled)',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    70
            handle: 'div.open',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    71
            placeholder: 'ui-state-highlight',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    72
            start: function (event, ui) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    73
              ui.placeholder.height(ui.item.height()-2);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    74
            },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    75
            stop: function(evt, ui) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    76
              setTimeout(
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    77
                function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    78
                  OT_UI.update_ids(elm);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    79
                },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    80
                200
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    81
              )
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    82
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    83
          });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    84
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    85
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    86
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    87
    init_add: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    88
      $(document).on('click', '.option-tree-section-add', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    89
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    90
        OT_UI.add(this,'section');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    91
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    92
      $(document).on('click', '.option-tree-setting-add', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    93
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    94
        OT_UI.add(this,'setting');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    95
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
    96
      $(document).on('click', '.option-tree-help-add', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    97
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    98
        OT_UI.add(this,'the_contextual_help');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
    99
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   100
      $(document).on('click', '.option-tree-choice-add', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   101
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   102
        OT_UI.add(this,'choice');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   103
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   104
      $(document).on('click', '.option-tree-list-item-add', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   105
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   106
        OT_UI.add(this,'list_item');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   107
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   108
      $(document).on('click', '.option-tree-social-links-add', function(e) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   109
        e.preventDefault();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   110
        OT_UI.add(this,'social_links');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   111
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   112
      $(document).on('click', '.option-tree-list-item-setting-add', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   113
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   114
        if ( $(this).parents('ul').parents('ul').hasClass('ui-sortable') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   115
          alert(option_tree.setting_limit);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   116
          return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   117
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   118
        OT_UI.add(this,'list_item_setting');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   119
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   120
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   121
    init_edit: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   122
      $(document).on('click', '.option-tree-setting-edit', function(e) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   123
        e.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   124
        if ( $(this).parents().hasClass('option-tree-setting-body') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   125
          OT_UI.init_remove_active($(this),'child');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   126
          OT_UI.init_hide_body($(this),'child');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   127
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   128
          OT_UI.init_remove_active($(this),'parent');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   129
          OT_UI.init_hide_body($(this), 'parent');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   130
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   131
        $(this).toggleClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   132
        OT_UI.init_hide_body($(this), 'toggle');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   133
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   134
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   135
    init_remove: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   136
      $(document).on('click', '.option-tree-setting-remove', function(event) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   137
        event.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   138
        if ( $(this).parents('li').hasClass('ui-state-disabled') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   139
          alert(option_tree.remove_no);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   140
          return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   141
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   142
        var agree = confirm(option_tree.remove_agree);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   143
        if (agree) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   144
          var list = $(this).parents('ul');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   145
          OT_UI.remove(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   146
          setTimeout( function() { 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   147
            OT_UI.update_ids(list); 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   148
          }, 200 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   149
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   150
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   151
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   152
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   153
    init_edit_title: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   154
      $(document).on('keyup', '.option-tree-setting-title', function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   155
        OT_UI.edit_title(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   156
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   157
      // Automatically fill option IDs with clean versions of their respective option labels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   158
      $(document).on('blur', '.option-tree-setting-title', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   159
        var optionId = $(this).parents('.option-tree-setting-body').find('[type="text"][name$="id]"]')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   160
        if ( optionId.val() === '' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   161
          optionId.val($(this).val().replace(/[^a-z0-9]/gi,'_').toLowerCase());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   162
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   163
      });
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   164
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   165
    init_edit_id: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   166
      $(document).on('keyup', '.section-id', function(){
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   167
        OT_UI.update_id(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   168
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   169
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   170
    init_activate_layout: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   171
      $(document).on('click', '.option-tree-layout-activate', function() { 
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   172
        var active = $(this).parents('.option-tree-setting').find('.open').text();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   173
        $('.option-tree-layout-activate').removeClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   174
        $(this).toggleClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   175
        $('.active-layout-input').attr({'value':active});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   176
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   177
      $(document).on('change', '#option-tree-options-layouts-form select', function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   178
        var agree = confirm(option_tree.activate_layout_agree);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   179
        if (agree) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   180
          $('#option-tree-options-layouts-form').submit();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   181
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   182
          var active = $('#the_current_layout').attr('value');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   183
          $('#option-tree-options-layouts-form select option[value="' + active + '"]').attr({'selected':'selected'});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   184
          $('#option-tree-options-layouts-form select').prev('span').replaceWith('<span>' + active + '</span>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   185
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   186
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   187
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   188
    add: function(elm,type) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   189
      var self = this, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   190
          list = '', 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   191
          list_class = '',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   192
          name = '', 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   193
          post_id = 0, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   194
          get_option = '', 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   195
          settings = '';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   196
      if ( type == 'the_contextual_help' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   197
        list = $(elm).parent().find('ul:last');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   198
        list_class = 'list-contextual-help';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   199
      } else if ( type == 'choice' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   200
        list = $(elm).parent().children('ul');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   201
        list_class = 'list-choice';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   202
      } else if ( type == 'list_item' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   203
        list = $(elm).parent().children('ul');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   204
        list_class = 'list-sub-setting';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   205
      } else if ( type == 'list_item_setting' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   206
        list = $(elm).parent().children('ul');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   207
        list_class = 'list-sub-setting';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   208
      } else if ( type == 'social_links' ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   209
        list = $(elm).parent().children('ul');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   210
        list_class = 'list-sub-setting';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   211
      } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   212
        list = $(elm).parent().find('ul:first');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   213
        list_class = ( type == 'section' ) ? 'list-section' : 'list-setting';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   214
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   215
      name = list.data('name');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   216
      post_id = list.data('id');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   217
      get_option = list.data('getOption');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   218
      settings = $('#'+name+'_settings_array').val();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   219
      if ( this.processing === false ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   220
        this.processing = true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   221
        var count = parseInt(list.children('li').length);
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   222
        if ( type == 'list_item' || type == 'social_links' ) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   223
          list.find('li input.option-tree-setting-title', self).each(function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   224
            var setting = $(this).attr('name'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   225
                regex = /\[([0-9]+)\]/,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   226
                matches = setting.match(regex),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   227
                id = null != matches ? parseInt(matches[1]) : 0;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   228
            id++;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   229
            if ( id > count) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   230
              count = id;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   231
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   232
          });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   233
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   234
        $.ajax({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   235
          url: option_tree.ajax,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   236
          type: 'post',
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   237
          data: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   238
            action: 'add_' + type,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   239
            count: count,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   240
            name: name,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   241
            post_id: post_id,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   242
            get_option: get_option,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   243
            settings: settings,
7
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   244
            type: type,
cf61fcea0001 resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents: 5
diff changeset
   245
            nonce: option_tree.nonce
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
          },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
          complete: function( data ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
            if ( type == 'choice' || type == 'list_item_setting' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
              OT_UI.init_remove_active(list,'child-add');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
              OT_UI.init_hide_body(list,'child-add');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
              OT_UI.init_remove_active();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
              OT_UI.init_hide_body();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   254
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   255
            var listItem = $('<li class="ui-state-default ' + list_class + '">' + data.responseText + '</li>');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   256
            list.append(listItem);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
            list.children().last().find('.option-tree-setting-edit').toggleClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
            list.children().last().find('.option-tree-setting-body').toggle();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
            list.children().last().find('.option-tree-setting-title').focus();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
            if ( type != 'the_contextual_help' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
              OT_UI.update_ids(list);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   262
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   263
            OT_UI.init_sortable(listItem);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   264
            OT_UI.init_select_wrapper(listItem);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   265
            OT_UI.init_numeric_slider(listItem);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   266
            OT_UI.parse_condition();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
            self.processing = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   268
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   269
        });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   270
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   271
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
    remove: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
      $(e).parent().parent().parent('li').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
    edit_title: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
      if ( this.timer ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
        clearTimeout(e.timer);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
      this.timer = setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
        $(e).parent().parent().parent().parent().parent().children('.open').text(e.value);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
      }, 100);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
    update_id: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
      if ( this.timer ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
        clearTimeout(e.timer);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
      this.timer = setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
        OT_UI.update_ids($(e).parents('ul'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
      }, 100);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
    update_ids: function(list) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
      var last_section, section, list_items = list.children('li');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
      list_items.each(function(index) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
        if ( $(this).hasClass('list-section') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
          section = $(this).find('.section-id').val().trim().toLowerCase().replace(/[^a-z0-9]/gi,'_');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
          if (!section) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
            section = $(this).find('.section-title').val().trim().toLowerCase().replace(/[^a-z0-9]/gi,'_');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
          if (!section) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
            section = last_section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
        if ($(this).hasClass('list-setting') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
          $(this).find('.hidden-section').attr({'value':section});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
        last_section = section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   310
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
    condition_objects: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   312
      return 'select, input[type="radio"]:checked, input[type="text"], input[type="hidden"], input.ot-numeric-slider-hidden-input';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
    match_conditions: function(condition) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
      var match;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   316
      var regex = /(.+?):(is|not|contains|less_than|less_than_or_equal_to|greater_than|greater_than_or_equal_to)\((.*?)\),?/g;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
      var conditions = [];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   318
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
      while( match = regex.exec( condition ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
        conditions.push({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
          'check': match[1], 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
          'rule':  match[2], 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   323
          'value': match[3] || ''
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   324
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   325
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   326
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   327
      return conditions;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   328
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   329
    parse_condition: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   330
      $( '.format-settings[id^="setting_"][data-condition]' ).each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   331
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   332
        var passed;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   333
        var conditions = OT_UI.match_conditions( $( this ).data( 'condition' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   334
        var operator = ( $( this ).data( 'operator' ) || 'and' ).toLowerCase();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   335
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   336
        $.each( conditions, function( index, condition ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   337
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   338
          var target   = $( '#setting_' + condition.check );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
          var targetEl = !! target.length && target.find( OT_UI.condition_objects() ).first();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   340
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   341
          if ( ! target.length || ( ! targetEl.length && condition.value.toString() != '' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   342
            return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   343
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   344
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
          var v1 = targetEl.length ? targetEl.val().toString() : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
          var v2 = condition.value.toString();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
          var result;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
          switch ( condition.rule ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
            case 'less_than':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
              result = ( parseInt( v1 ) < parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   353
            case 'less_than_or_equal_to':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
              result = ( parseInt( v1 ) <= parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   355
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   356
            case 'greater_than':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
              result = ( parseInt( v1 ) > parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   358
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   359
            case 'greater_than_or_equal_to':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   360
              result = ( parseInt( v1 ) >= parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   361
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   362
            case 'contains':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   363
              result = ( v1.indexOf(v2) !== -1 ? true : false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
              break; 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
            case 'is':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   366
              result = ( v1 == v2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   367
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   368
            case 'not':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   369
              result = ( v1 != v2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   370
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   371
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   372
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
          if ( 'undefined' == typeof passed ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
            passed = result;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   375
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   376
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   377
          switch ( operator ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
            case 'or':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   379
              passed = ( passed || result );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   380
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   381
            case 'and':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   382
            default:
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   383
              passed = ( passed && result );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   384
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   385
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   386
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   387
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   388
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
        if ( passed ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   390
          $(this).animate({opacity: 'show' , height: 'show'}, 200);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   391
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
          $(this).animate({opacity: 'hide' , height: 'hide'}, 200);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   393
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   394
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   395
        delete passed;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   396
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   397
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   398
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   399
    init_conditions: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
      var delay = (function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
        var timer = 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   402
        return function(callback, ms) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   403
          clearTimeout(timer);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   404
          timer = setTimeout(callback, ms);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   405
        };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   406
      })();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   407
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   408
      $('.format-settings[id^="setting_"]').on( 'change.conditionals, keyup.conditionals', OT_UI.condition_objects(), function(e) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   409
        if (e.type === 'keyup') {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
          // handle keyup event only once every 500ms
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   411
          delay(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
            OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
          }, 500);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   414
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
          OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   417
        OT_UI.load_editors();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   418
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   419
      OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   420
    },
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
    init_upload: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   422
      $(document).on('click', '.ot_upload_media', function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   423
        var field_id            = $(this).parent('.option-tree-ui-upload-parent').find('input').attr('id'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
            post_id             = $(this).attr('rel'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
            save_attachment_id  = $('#'+field_id).hasClass('ot-upload-attachment-id'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   426
            btnContent          = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
        if ( window.wp && wp.media ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   428
          window.ot_media_frame = window.ot_media_frame || new wp.media.view.MediaFrame.Select({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
            title: $(this).attr('title'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
            button: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
              text: option_tree.upload_text
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
            }, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
            multiple: false
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
          });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
          window.ot_media_frame.on('select', function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   436
            var attachment = window.ot_media_frame.state().get('selection').first(), 
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   437
                href = attachment.attributes.url,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   438
                attachment_id = attachment.attributes.id,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
                mime = attachment.attributes.mime,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
                regex = /^image\/(?:jpe?g|png|gif|x-icon)$/i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
            if ( mime.match(regex) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
              btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+href+'" alt="" /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   443
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   444
            btnContent += '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="'+option_tree.remove_media_text+'"><span class="icon ot-icon-minus-circle"></span>'+option_tree.remove_media_text+'</a>';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   445
            $('#'+field_id).val( ( save_attachment_id ? attachment_id : href ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
            $('#'+field_id+'_media').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   447
            $('#'+field_id).parent().parent('div').append('<div class="option-tree-ui-media-wrap" id="'+field_id+'_media" />');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
            $('#'+field_id+'_media').append(btnContent).slideDown();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
            window.ot_media_frame.off('select');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
          }).open();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
          var backup = window.send_to_editor,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
              intval = window.setInterval( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
                function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
                  if ( $('#TB_iframeContent').length > 0 && $('#TB_iframeContent').attr('src').indexOf( "&field_id=" ) !== -1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
                    $('#TB_iframeContent').contents().find('#tab-type_url').hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
                  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
                  $('#TB_iframeContent').contents().find('.savesend .button').val(option_tree.upload_text); 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
                }, 50);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   460
          tb_show('', 'media-upload.php?post_id='+post_id+'&field_id='+field_id+'&type=image&TB_iframe=1');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
          window.send_to_editor = function(html) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
            var href = $(html).find('img').attr('src');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
            if ( typeof href == 'undefined') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
              href = $(html).attr('src');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
            } 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
            if ( typeof href == 'undefined') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
              href = $(html).attr('href');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
            var image = /\.(?:jpe?g|png|gif|ico)$/i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
            if (href.match(image) && OT_UI.url_exists(href)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
              btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+href+'" alt="" /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   472
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   473
            btnContent += '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="'+option_tree.remove_media_text+'"><span class="icon ot-icon-minus-circle"></span>'+option_tree.remove_media_text+'</a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
            $('#'+field_id).val(href);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
            $('#'+field_id+'_media').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   476
            $('#'+field_id).parent().parent('div').append('<div class="option-tree-ui-media-wrap" id="'+field_id+'_media" />');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
            $('#'+field_id+'_media').append(btnContent).slideDown();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
            OT_UI.fix_upload_parent();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
            tb_remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
            window.clearInterval(intval);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
            window.send_to_editor = backup;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
          };
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   487
    init_upload_remove: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   488
      $(document).on('click', '.option-tree-ui-remove-media', function(event) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
        event.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
        var agree = confirm(option_tree.remove_agree);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
        if (agree) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
          OT_UI.remove_image(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
          return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
    init_upload_fix: function(elm) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
      var id  = $(elm).attr('id'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   500
          val = $(elm).val(),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   501
          img = $(elm).parent().next('.option-tree-ui-media-wrap').find('img'),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
          src = img.attr('src'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   503
          btnContent = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   504
      if ( val == src ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   505
        return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   506
      }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
      if ( val != src ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
        img.attr('src', val);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
      if ( val !== '' && ( typeof src == 'undefined' || src == false ) && OT_UI.url_exists(val) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
        var image = /\.(?:jpe?g|png|gif|ico)$/i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
        if (val.match(image)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
          btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+val+'" alt="" /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   514
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   515
        btnContent += '<a href="javascript:(void);" class="option-tree-ui-remove-media option-tree-ui-button button button-secondary light" title="'+option_tree.remove_media_text+'"><span class="icon ot-icon-minus-circle">'+option_tree.remove_media_text+'</span></a>';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
        $('#'+id).val(val);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
        $('#'+id+'_media').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   518
        $('#'+id).parent().parent('div').append('<div class="option-tree-ui-media-wrap" id="'+id+'_media" />');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
        $('#'+id+'_media').append(btnContent).slideDown();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
      } else if ( val == '' || ! OT_UI.url_exists(val) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
        $(elm).parent().next('.option-tree-ui-media-wrap').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   523
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   524
    init_numeric_slider: function(scope) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   525
      scope = scope || document;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   526
      $(".ot-numeric-slider-wrap", scope).each(function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
        var hidden = $(".ot-numeric-slider-hidden-input", this),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
            value  = hidden.val(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
            helper = $(".ot-numeric-slider-helper-input", this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
        if ( ! value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
          value = hidden.data("min");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
          helper.val(value)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
        $(".ot-numeric-slider", this).slider({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
          min: hidden.data("min"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
          max: hidden.data("max"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
          step: hidden.data("step"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
          value: value, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   539
          slide: function(event, ui) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
            hidden.add(helper).val(ui.value).trigger('change');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
          create: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
            hidden.val($(this).slider('value'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
          change: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   546
            OT_UI.parse_condition();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   547
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   548
        });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   549
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   550
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
    init_tabs: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
      $(".wrap.settings-wrap .ui-tabs").tabs({ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
        fx: { 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
          opacity: "toggle", 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
          duration: "fast"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   558
      $(".wrap.settings-wrap .ui-tabs a.ui-tabs-anchor").on("click", function(event, ui) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
        var obj = "input[name='_wp_http_referer']";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
        if ( $(obj).length > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
          var url = $(obj).val(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
              hash = $(this).attr('href');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
          if ( url.indexOf("#") != -1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
            var o = url.split("#")[1],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
                n = hash.split("#")[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
            url = url.replace(o, n);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
            url = url + hash;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
          $(obj).val(url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   571
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   572
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   573
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   574
    init_radio_image_select: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   575
      $(document).on('click', '.option-tree-ui-radio-image', function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   576
        $(this).closest('.type-radio-image').find('.option-tree-ui-radio-image').removeClass('option-tree-ui-radio-image-selected');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   577
        $(this).toggleClass('option-tree-ui-radio-image-selected');
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   578
        $(this).parent().find('.option-tree-ui-radio').prop('checked', true).trigger('change');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   580
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   581
    init_select_wrapper: function(scope) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   582
      scope = scope || document;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   583
      $('.option-tree-ui-select', scope).each(function () {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
        if ( ! $(this).parent().hasClass('select-wrapper') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
          $(this).wrap('<div class="select-wrapper" />');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
          $(this).parent('.select-wrapper').prepend('<span>' + $(this).find('option:selected').text() + '</span>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   588
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
    bind_select_wrapper: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   591
      $(document).on('change', '.option-tree-ui-select', function () {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
        $(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   593
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
    init_google_fonts: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
      var update_items = function(input, items, element) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
        var itemsUI = input.closest('.type-google-font-group').find(element);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
        if ( itemsUI.length ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
          itemsUI.empty();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
          itemsUI.append($.map(items, function(item) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
            var input = document.createElement('input'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
                label = document.createElement('label');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
            input.type = 'checkbox';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
            input.id = ( itemsUI.data('field-id-prefix') || '' ) + item;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   605
            input.name =  ( itemsUI.data('field-name') || '' ) + '[]';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
            input.value =  item;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
            label.innerHTML = item;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
            $( label ).attr( 'for', input.id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   609
            return $( document.createElement('p') ).addClass('checkbox-wrap').append([input, label]);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   610
          }));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   611
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   612
      };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
      $(document).on('change', '.option-tree-google-font-family select', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   614
        var input = $(this);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   615
        $.ajax({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
          url: option_tree.ajax,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   617
          type: 'POST',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   618
          dataType: 'json',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   619
          data: {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   620
            action: 'ot_google_font',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   621
            family: input.val(), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   622
            field_id: input.attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   623
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   624
        }).done(function(response) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   625
          if ( response.hasOwnProperty('variants') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   626
            update_items( input, response.variants, '.option-tree-google-font-variants' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   627
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   628
          if ( response.hasOwnProperty('subsets') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   629
            update_items( input, response.subsets, '.option-tree-google-font-subsets' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   630
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   631
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   632
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
      $('.js-add-google-font').on('click', function (event) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   634
        var $group = $(this).parent('.format-setting-inner').find('.type-google-font-group'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
            $el_clone = $(this).prev('.type-google-font-group-clone'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
            $clone = $el_clone.clone(true),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
            $count = $group.length ? $group.length : 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
        $clone.attr('class', 'type-google-font-group');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   639
        var replacer = function(index, elm) { 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
          return elm.replace('%key%', $count);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   641
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   642
        $('select', $clone).each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   643
          $(this).attr('id', replacer ).attr('name', replacer );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   644
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   645
        $('.option-tree-google-font-variants', $clone).each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   646
          $(this).attr('data-field-id-prefix', replacer ).attr('data-field-name', replacer );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   647
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   648
        $('.option-tree-google-font-subsets', $clone).each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   649
          $(this).attr('data-field-id-prefix', replacer ).attr('data-field-name', replacer );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   650
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   651
        $el_clone.before($clone)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
        event.preventDefault()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   653
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
      $('.js-remove-google-font').on('click', function (event) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   655
        $(this).parents('.type-google-font-group').remove();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   656
        event.preventDefault();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   659
    bind_colorpicker: function(field_id) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   660
      $('#'+field_id).wpColorPicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   661
        change: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   662
          OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   663
        }, 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   664
        clear: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   665
          OT_UI.parse_condition();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   666
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   667
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   668
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   669
    bind_date_picker: function(field_id, date_format) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   670
      $('#'+field_id).datepicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   671
        showOtherMonths: true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   672
        showButtonPanel: true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   673
        currentText: option_tree.date_current,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   674
        closeText: option_tree.date_close,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   675
        dateFormat: date_format
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   676
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   677
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   678
    bind_date_time_picker: function(field_id, date_format) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   679
      $('#'+field_id).datetimepicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   680
        showOtherMonths: true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   681
        closeText: option_tree.date_close,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   682
        dateFormat: date_format
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   685
    fix_upload_parent: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   686
      $('.option-tree-ui-upload-input').not('.ot-upload-attachment-id').on('focus blur', function(){
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
        $(this).parent('.option-tree-ui-upload-parent').toggleClass('focus');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
        OT_UI.init_upload_fix(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
    remove_image: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
      $(e).parent().parent().find('.option-tree-ui-upload-input').attr('value','');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
      $(e).parent('.option-tree-ui-media-wrap').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
    fix_textarea: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
      $('.wp-editor-area').focus( function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
        $(this).parent('div').css({borderColor:'#bbb'});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
      }).blur( function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
        $(this).parent('div').css({borderColor:'#ccc'});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
    replicate_ajax: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
      if (location.href.indexOf("#") != -1) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
        var url = $("input[name=\'_wp_http_referer\']").val(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
            hash = location.href.substr(location.href.indexOf("#"));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
        $("input[name=\'_wp_http_referer\']").val( url + hash );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
        this.scroll_to_top();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
      setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
        $(".wrap.settings-wrap .fade").fadeOut("fast");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
      }, 3000 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   713
    reset_settings: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   714
      $(document).on("click", ".reset-settings", function(event){
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
        var agree = confirm(option_tree.reset_agree);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
        if (agree) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
          return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
          return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
        event.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   723
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   724
    css_editor_mode: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   725
      $('.ot-css-editor').each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   726
        var editor = ace.edit($(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   727
        var this_textarea = $('#textarea_' + $(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   728
        editor.setTheme("ace/theme/chrome");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   729
        editor.getSession().setMode("ace/mode/css");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   730
        editor.setShowPrintMargin( false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
        editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
        editor.getSession().on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   734
          this_textarea.val(editor.getSession().getValue());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   736
        this_textarea.on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
          editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   738
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   739
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   740
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   741
    javascript_editor_mode: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   742
      $('.ot-javascript-editor').each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   743
        var editor = ace.edit($(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   744
        var this_textarea = $('#textarea_' + $(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   745
        editor.setTheme("ace/theme/chrome");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   746
        editor.getSession().setMode("ace/mode/javascript");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   747
        editor.setShowPrintMargin( false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   748
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   749
        editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   750
        editor.getSession().on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   751
          this_textarea.val(editor.getSession().getValue());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   752
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   753
        this_textarea.on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   754
          editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   755
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   756
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   757
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   758
    load_editors: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   759
      OT_UI.css_editor_mode();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   760
      OT_UI.javascript_editor_mode();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   761
    },
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   762
    url_exists: function(url) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   763
      var link = document.createElement('a')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   764
      link.href = url
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   765
      if ( link.hostname != window.location.hostname ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   766
        return true; // Stop the code from checking across domains.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   767
      }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
      var http = new XMLHttpRequest();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
      http.open('HEAD', url, false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
      http.send();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
      return http.status!=404;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
    scroll_to_top: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
      setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
        $(this).scrollTop(0);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
      }, 50 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
  };
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
  $(document).ready( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
    OT_UI.init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   781
  });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   782
})(jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   783
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   784
/* Gallery */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   785
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   786
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   787
  ot_gallery = {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   788
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   789
    frame: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   790
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   791
      var selection = this.select(elm)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   792
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   793
      this._frame = wp.media({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   794
        id:         'ot-gallery-frame'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   795
      , frame:      'post'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   796
      , state:      'gallery-edit'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   797
      , title:      wp.media.view.l10n.editGalleryTitle
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   798
      , editing:    true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   799
      , multiple:   true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   800
      , selection:  selection
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   801
      })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   802
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   803
      this._frame.on('update', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   804
        var controller = ot_gallery._frame.states.get('gallery-edit')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   805
          , library = controller.get('library')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   806
          , ids = library.pluck('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   807
          , parent = $(elm).parents('.format-setting-inner')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   808
          , input = parent.children('.ot-gallery-value')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   809
          , shortcode = wp.media.gallery.shortcode( selection ).string().replace(/\"/g,"'")
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   810
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   811
        input.attr('value', ids)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   812
                        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   813
        if ( parent.children('.ot-gallery-list').length <= 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   814
          input.after('<ul class="ot-gallery-list" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   815
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   816
        $.ajax({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   817
          type: 'POST',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   818
          url: ajaxurl,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   819
          dataType: 'html',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   820
          data: {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   821
            action: 'gallery_update'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   822
          , ids: ids
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   823
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   824
          success: function(res) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   825
            parent.children('.ot-gallery-list').html(res);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   826
            if ( input.hasClass('ot-gallery-shortcode') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   827
              input.val(shortcode);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   828
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   829
            if ( $(elm).parent().children('.ot-gallery-delete').length <= 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   830
              $(elm).parent().append('<a href="#" class="option-tree-ui-button button button-secondary hug-left ot-gallery-delete">' + option_tree.delete + '</a>');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   831
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   832
            $(elm).text(option_tree.edit);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   833
            OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   834
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   835
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   836
      })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   837
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   838
      return this._frame
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   839
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   840
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   841
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   842
  , select: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   843
      var input = $(elm).parents('.format-setting-inner').children('.ot-gallery-value')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   844
        , ids = input.attr('value')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   845
        , _shortcode = input.hasClass('ot-gallery-shortcode') ? ids : '[gallery ids=\'' + ids + '\]'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   846
        , shortcode = wp.shortcode.next('gallery', ( ids ? _shortcode : wp.media.view.settings.ot_gallery.shortcode ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   847
        , defaultPostId = wp.media.gallery.defaults.id
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   848
        , attachments
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   849
        , selection
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   850
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   851
      // Bail if we didn't match the shortcode or all of the content.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   852
      if ( ! shortcode )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   853
        return
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   854
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   855
      // Ignore the rest of the match object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   856
      shortcode = shortcode.shortcode
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   857
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   858
      if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   859
        shortcode.set( 'id', defaultPostId )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   861
      if ( _.isUndefined( shortcode.get('ids') ) && ! input.hasClass('ot-gallery-shortcode') && ids )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   862
        shortcode.set( 'ids', ids )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   863
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   864
      if ( _.isUndefined( shortcode.get('ids') ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   865
        shortcode.set( 'ids', '0' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   866
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   867
      attachments = wp.media.gallery.attachments( shortcode )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   868
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   869
      selection = new wp.media.model.Selection( attachments.models, {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   870
        props:    attachments.props.toJSON()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   871
      , multiple: true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   872
      })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   873
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   874
      selection.gallery = attachments.gallery
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   876
      // Fetch the query's attachments, and then break ties from the query to allow for sorting.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   877
      selection.more().done( function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   878
        selection.props.set({ query: false })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   879
        selection.unmirror()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   880
        selection.props.unset('orderby')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   881
      })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   882
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   883
      return selection
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   884
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   885
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   886
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   887
  , open: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   889
      ot_gallery.frame(elm).open()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   890
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   891
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   892
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
  , remove: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
      if ( confirm( option_tree.confirm ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   897
        $(elm).parents('.format-setting-inner').children('.ot-gallery-value').attr('value', '');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   898
        $(elm).parents('.format-setting-inner').children('.ot-gallery-list').remove();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   899
        $(elm).next('.ot-gallery-edit').text( option_tree.create );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   900
        $(elm).remove();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   901
        OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   902
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   903
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   904
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   905
    }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   906
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   907
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   908
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   909
  // Gallery delete
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   910
  $(document).on('click.ot_gallery.data-api', '.ot-gallery-delete', function (e) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   911
    e.preventDefault()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   912
    ot_gallery.remove($(this))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   913
  })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   914
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   915
  // Gallery edit
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   916
  $(document).on('click.ot_gallery.data-api', '.ot-gallery-edit', function (e) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   917
    e.preventDefault()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   918
    ot_gallery.open($(this))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   919
  })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   920
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   921
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   922
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   923
/*!
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   924
 * Adds metabox tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   925
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   926
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   927
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   928
  $(document).on('ready', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   929
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   930
    // Loop over the metaboxes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   931
    $('.ot-metabox-wrapper').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   932
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   933
      // Only if there is a tab option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   934
      if ( $(this).find('.type-tab').length ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   935
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   936
        // Add .ot-metabox-panels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   937
        $(this).find('.type-tab').parents('.ot-metabox-wrapper').wrapInner('<div class="ot-metabox-panels" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   938
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   939
        // Wrapp with .ot-metabox-tabs & add .ot-metabox-nav before .ot-metabox-panels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   940
        $(this).find('.ot-metabox-panels').wrap('<div class="ot-metabox-tabs" />').before('<ul class="ot-metabox-nav" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   941
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   942
        // Loop over settings and build the tabs nav
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   943
        $(this).find('.format-settings').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   944
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   945
          if ( $(this).find('.type-tab').length > 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   946
            var title = $(this).find('.type-tab').prev().find('label').text()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   947
              , id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   948
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   949
            // Add a class, hide & append nav item 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   950
            $(this).addClass('is-panel').hide()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   951
            $(this).parents('.ot-metabox-panels').prev('.ot-metabox-nav').append('<li><a href="#' + id + '">' + title + '</a></li>')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   952
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   953
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   954
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   955
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   956
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   957
        // Loop over the panels and wrap and ID them.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   958
        $(this).find('.is-panel').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   959
          var id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   960
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   961
          $(this).add( $(this).nextUntil('.is-panel') ).wrapAll('<div id="' + id + '" class="tab-content" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   962
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   963
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   964
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   965
        // Create the tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   966
        $(this).find('.ot-metabox-tabs').tabs({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   967
          activate: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   968
            var parent = $(this).outerHeight(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   969
                child = $(this).find('.ot-metabox-panels').outerHeight() + 8,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   970
                minHeight = parent - 34
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   971
            if ( $(this).find('.ot-metabox-panels').css('padding') == '12px' && child < parent ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   972
              $(this).find('.ot-metabox-panels').css({ minHeight: minHeight })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   973
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   974
            OT_UI.load_editors();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   975
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   976
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   977
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
        // Move the orphaned settings to the top
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   979
        $(this).find('.ot-metabox-panels > .format-settings').prependTo($(this))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   980
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   981
        // Remove a bunch of classes to stop style conflicts.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   982
        $(this).find('.ot-metabox-tabs').removeClass('ui-widget ui-widget-content ui-corner-all')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   983
        $(this).find('.ot-metabox-nav').removeClass('ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   984
        $(this).find('.ot-metabox-nav li').removeClass('ui-state-default ui-corner-top ui-tabs-active ui-tabs-active')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   985
        $(this).find('.ot-metabox-nav li').on('mouseenter mouseleave', function() { $(this).removeClass('ui-state-hover') })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   986
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   987
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   988
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   989
    })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   990
     
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   991
  })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   992
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   993
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   994
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   995
/*!
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   996
 * Adds theme option tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   997
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   998
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   999
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1000
  $(document).on('ready', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1001
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1002
    // Loop over the theme options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
    $('#option-tree-settings-api .inside').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1004
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1005
      // Only if there is a tab option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1006
      if ( $(this).find('.type-tab').length ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1007
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1008
        // Add .ot-theme-option-panels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1009
        $(this).find('.type-tab').parents('.inside').wrapInner('<div class="ot-theme-option-panels" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1010
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1011
        // Wrap with .ot-theme-option-tabs & add .ot-theme-option-nav before .ot-theme-option-panels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1012
        $(this).find('.ot-theme-option-panels').wrap('<div class="ot-theme-option-tabs" />').before('<ul class="ot-theme-option-nav" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1013
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1014
        // Loop over settings and build the tabs nav
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1015
        $(this).find('.format-settings').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1016
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1017
          if ( $(this).find('.type-tab').length > 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1018
            var title = $(this).find('.type-tab').prev().find('.label').text()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1019
              , id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1020
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1021
            // Add a class, hide & append nav item 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1022
            $(this).addClass('is-panel').hide()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1023
            $(this).parents('.ot-theme-option-panels').prev('.ot-theme-option-nav').append('<li><a href="#' + id + '">' + title + '</a></li>')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1024
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1025
          } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1026
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1027
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1028
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1029
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1030
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1031
        // Loop over the panels and wrap and ID them.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1032
        $(this).find('.is-panel').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1033
          var id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1034
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1035
          $(this).add( $(this).nextUntil('.is-panel') ).wrapAll('<div id="' + id + '" class="tab-content" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1036
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1037
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1038
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1039
        // Create the tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1040
        $(this).find('.ot-theme-option-tabs').tabs({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1041
          activate: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1042
            OT_UI.load_editors();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1043
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1044
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1045
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1046
        // Move the orphaned settings to the top
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1047
        $(this).find('.ot-theme-option-panels > .format-settings').prependTo($(this).find('.ot-theme-option-tabs'))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1048
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1049
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1050
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1051
    })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1052
     
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1053
  })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1054
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1055
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1056
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1057
/*!
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1058
 * Fixes the state of metabox radio buttons after a Drag & Drop event.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1059
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1060
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1061
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1062
  $(document).on('ready', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1063
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1064
    // detect mousedown and store all checked radio buttons
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1065
    $('.hndle').on('mousedown', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1066
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1067
      // get parent element of .hndle selected. 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1068
      // We only need to monitor radios insde the object that is being moved.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1069
      var parent_id = $(this).closest('div').attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1070
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1071
      // set live event listener for mouse up on the content .wrap 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1072
      // then give the dragged div time to settle before firing the reclick function
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1073
      $('.wrap').on('mouseup', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1074
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1075
        var ot_checked_radios = {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1076
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1077
        // loop over all checked radio buttons inside of parent element
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1078
        $('#' + parent_id + ' input[type="radio"]').each( function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1079
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1080
          // stores checked radio buttons
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1081
          if ( $(this).is(':checked') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1082
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1083
            ot_checked_radios[$(this).attr('name')] = $(this).val()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1084
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1085
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1086
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1087
          // write to the object
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1088
          $(document).data('ot_checked_radios', ot_checked_radios)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1089
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1090
        })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1091
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1092
        // restore all checked radio buttons 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1093
        setTimeout( function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1094
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1095
          // get object of checked radio button names and values
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1096
          var checked = $(document).data('ot_checked_radios')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1097
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1098
          // step thru each object element and trigger a click on it's corresponding radio button
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1099
          for ( key in checked ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1100
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1101
            $('input[name="' + key + '"]').filter('[value="' + checked[key] + '"]').trigger('click')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1102
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1103
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1104
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1105
          $('.wrap').unbind('mouseup')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1106
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1107
        }, 50 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1108
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1109
      })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1110
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1111
    })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1112
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1113
  })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1114
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1115
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1116
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1117
/*!
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1118
 * Adds opacity to the default colorpicker
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1119
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1120
 * Derivative work of the Codestar WP Color Picker.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1121
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1122
;(function ( $, window, document, undefined ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1123
  'use strict';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1124
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1125
  // adding alpha support for Automattic Color.js toString function.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1126
  if( typeof Color.fn.toString !== undefined ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1127
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1128
    Color.fn.toString = function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1129
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1130
      // check for alpha
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1131
      if ( this._alpha < 1 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1132
        return this.toCSS('rgba', this._alpha).replace(/\s+/g, '');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1133
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1134
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1135
      var hex = parseInt( this._color, 10 ).toString( 16 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1136
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1137
      if ( this.error ) { return ''; }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1138
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1139
      // maybe left pad it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1140
      if ( hex.length < 6 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1141
        for (var i = 6 - hex.length - 1; i >= 0; i--) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1142
          hex = '0' + hex;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1143
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1144
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1145
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1146
      return '#' + hex;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1147
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1148
    };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1149
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1150
  }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1151
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1152
  $.ot_ParseColorValue = function( val ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1153
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1154
    var value = val.replace(/\s+/g, ''),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1155
        alpha = ( value.indexOf('rgba') !== -1 ) ? parseFloat( value.replace(/^.*,(.+)\)/, '$1') * 100 ) : 100,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1156
        rgba  = ( alpha < 100 ) ? true : false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1157
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1158
    return { value: value, alpha: alpha, rgba: rgba };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1159
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1160
  };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1161
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1162
  $.fn.ot_wpColorPicker = function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1163
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1164
    return this.each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1165
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1166
      var $this = $(this);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1167
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1168
      // check for rgba enabled/disable
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1169
      if( $this.data('rgba') !== false ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1170
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1171
        // parse value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1172
        var picker = $.ot_ParseColorValue( $this.val() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1173
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1174
        // wpColorPicker core
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1175
        $this.wpColorPicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1176
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1177
          // wpColorPicker: change
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1178
          change: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1179
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1180
            // update checkerboard background color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1181
            $this.closest('.wp-picker-container').find('.option-tree-opacity-slider-offset').css('background-color', ui.color.toString());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1182
            $this.trigger('keyup');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1183
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1184
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1185
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1186
          // wpColorPicker: create
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1187
          create: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1188
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1189
            // set variables for alpha slider
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1190
            var a8cIris       = $this.data('a8cIris'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1191
                $container    = $this.closest('.wp-picker-container'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1192
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1193
                // appending alpha wrapper
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1194
                $alpha_wrap   = $('<div class="option-tree-opacity-wrap">' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1195
                                  '<div class="option-tree-opacity-slider"></div>' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1196
                                  '<div class="option-tree-opacity-slider-offset"></div>' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1197
                                  '<div class="option-tree-opacity-text"></div>' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1198
                                  '</div>').appendTo( $container.find('.wp-picker-holder') ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1199
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1200
                $alpha_slider = $alpha_wrap.find('.option-tree-opacity-slider'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1201
                $alpha_text   = $alpha_wrap.find('.option-tree-opacity-text'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1202
                $alpha_offset = $alpha_wrap.find('.option-tree-opacity-slider-offset');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1203
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1204
            // alpha slider
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1205
            $alpha_slider.slider({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1206
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1207
              // slider: slide
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1208
              slide: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1209
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1210
                var slide_value = parseFloat( ui.value / 100 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1211
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1212
                // update iris data alpha && wpColorPicker color option && alpha text
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1213
                a8cIris._color._alpha = slide_value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1214
                $this.wpColorPicker( 'color', a8cIris._color.toString() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1215
                $alpha_text.text( ( slide_value < 1 ? slide_value : '' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1216
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1217
              },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1218
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1219
              // slider: create
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1220
              create: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1221
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1222
                var slide_value = parseFloat( picker.alpha / 100 ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1223
                    alpha_text_value = slide_value < 1 ? slide_value : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1224
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1225
                // update alpha text && checkerboard background color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1226
                $alpha_text.text(alpha_text_value);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1227
                $alpha_offset.css('background-color', picker.value);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1228
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1229
                // wpColorPicker clear button for update iris data alpha && alpha text && slider color option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1230
                $container.on('click', '.wp-picker-clear', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1231
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1232
                  a8cIris._color._alpha = 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1233
                  $alpha_text.text('');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1234
                  $alpha_slider.slider('option', 'value', 100).trigger('slide');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1235
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1236
                });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1237
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1238
                // wpColorPicker default button for update iris data alpha && alpha text && slider color option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1239
                $container.on('click', '.wp-picker-default', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1240
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1241
                  var default_picker = $.ot_ParseColorValue( $this.data('default-color') ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1242
                      default_value  = parseFloat( default_picker.alpha / 100 ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1243
                      default_text   = default_value < 1 ? default_value : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1244
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1245
                  a8cIris._color._alpha = default_value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1246
                  $alpha_text.text(default_text);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1247
                  $alpha_slider.slider('option', 'value', default_picker.alpha).trigger('slide');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1248
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1249
                });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1250
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1251
                // show alpha wrapper on click color picker button
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1252
                $container.on('click', '.wp-color-result', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1253
                  $alpha_wrap.toggle();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1254
                });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1255
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1256
                // hide alpha wrapper on click body
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1257
                $('body').on( 'click.wpcolorpicker', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1258
                  $alpha_wrap.hide();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1259
                });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1260
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1261
              },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1262
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1263
              // slider: options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1264
              value: picker.alpha,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1265
              step: 1,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1266
              min: 1,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1267
              max: 100
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1268
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1269
            });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1270
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1271
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1272
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1273
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1274
      } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1275
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1276
        // wpColorPicker default picker
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1277
        $this.wpColorPicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1278
          change: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1279
            $this.trigger('keyup');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1280
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1281
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1282
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1283
      }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1284
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1285
    });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1286
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1287
  };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1288
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1289
  $(document).ready( function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1290
    $('.hide-color-picker.ot-colorpicker-opacity').ot_wpColorPicker();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1291
  });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1292
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1293
})( jQuery, window, document );