wp/wp-content/plugins/option-tree/assets/js/ot-admin.js
author ymh <ymh.work@gmail.com>
Tue, 09 Jun 2015 03:35:32 +0200
changeset 5 5e2f62d02dcd
parent 0 d970ebf37754
child 7 cf61fcea0001
permissions -rw-r--r--
upgrade wordpress + plugins
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,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   244
            type: type
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   245
          },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   246
          complete: function( data ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   247
            if ( type == 'choice' || type == 'list_item_setting' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   248
              OT_UI.init_remove_active(list,'child-add');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   249
              OT_UI.init_hide_body(list,'child-add');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   250
            } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   251
              OT_UI.init_remove_active();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   252
              OT_UI.init_hide_body();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   253
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   254
            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
   255
            list.append(listItem);
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   256
            list.children().last().find('.option-tree-setting-edit').toggleClass('active');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   257
            list.children().last().find('.option-tree-setting-body').toggle();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   258
            list.children().last().find('.option-tree-setting-title').focus();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   259
            if ( type != 'the_contextual_help' ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   260
              OT_UI.update_ids(list);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   261
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   262
            OT_UI.init_sortable(listItem);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   263
            OT_UI.init_select_wrapper(listItem);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   264
            OT_UI.init_numeric_slider(listItem);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   265
            OT_UI.parse_condition();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   266
            self.processing = false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   267
          }
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
    remove: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   272
      $(e).parent().parent().parent('li').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   273
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   274
    edit_title: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   275
      if ( this.timer ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   276
        clearTimeout(e.timer);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   277
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   278
      this.timer = setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   279
        $(e).parent().parent().parent().parent().parent().children('.open').text(e.value);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   280
      }, 100);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   281
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   282
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   283
    update_id: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   284
      if ( this.timer ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   285
        clearTimeout(e.timer);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   286
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   287
      this.timer = setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   288
        OT_UI.update_ids($(e).parents('ul'));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   289
      }, 100);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   290
      return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   291
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   292
    update_ids: function(list) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   293
      var last_section, section, list_items = list.children('li');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   294
      list_items.each(function(index) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   295
        if ( $(this).hasClass('list-section') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   296
          section = $(this).find('.section-id').val().trim().toLowerCase().replace(/[^a-z0-9]/gi,'_');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   297
          if (!section) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   298
            section = $(this).find('.section-title').val().trim().toLowerCase().replace(/[^a-z0-9]/gi,'_');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   299
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   300
          if (!section) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   301
            section = last_section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   302
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   303
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   304
        if ($(this).hasClass('list-setting') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   305
          $(this).find('.hidden-section').attr({'value':section});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   306
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   307
        last_section = section;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   308
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   309
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   310
    condition_objects: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   311
      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
   312
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   313
    match_conditions: function(condition) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   314
      var match;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   315
      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
   316
      var conditions = [];
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   317
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   318
      while( match = regex.exec( condition ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   319
        conditions.push({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   320
          'check': match[1], 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   321
          'rule':  match[2], 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   322
          'value': match[3] || ''
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   323
        });
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
      return conditions;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   327
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   328
    parse_condition: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   329
      $( '.format-settings[id^="setting_"][data-condition]' ).each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   330
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   331
        var passed;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   332
        var conditions = OT_UI.match_conditions( $( this ).data( 'condition' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   333
        var operator = ( $( this ).data( 'operator' ) || 'and' ).toLowerCase();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   334
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   335
        $.each( conditions, function( index, condition ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   336
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   337
          var target   = $( '#setting_' + condition.check );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   338
          var targetEl = !! target.length && target.find( OT_UI.condition_objects() ).first();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   339
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   340
          if ( ! target.length || ( ! targetEl.length && condition.value.toString() != '' ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   341
            return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   342
          }
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
          var v1 = targetEl.length ? targetEl.val().toString() : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   345
          var v2 = condition.value.toString();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   346
          var result;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   347
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   348
          switch ( condition.rule ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   349
            case 'less_than':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   350
              result = ( parseInt( v1 ) < parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   351
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   352
            case 'less_than_or_equal_to':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   353
              result = ( parseInt( v1 ) <= parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   354
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   355
            case 'greater_than':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   356
              result = ( parseInt( v1 ) > parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   357
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   358
            case 'greater_than_or_equal_to':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   359
              result = ( parseInt( v1 ) >= parseInt( v2 ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   360
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   361
            case 'contains':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   362
              result = ( v1.indexOf(v2) !== -1 ? true : false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   363
              break; 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   364
            case 'is':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   365
              result = ( v1 == v2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   366
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   367
            case 'not':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   368
              result = ( v1 != v2 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   369
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   370
          }
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
          if ( 'undefined' == typeof passed ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   373
            passed = result;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   374
          }
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
          switch ( operator ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   377
            case 'or':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   378
              passed = ( passed || result );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   379
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   380
            case 'and':
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   381
            default:
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   382
              passed = ( passed && result );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   383
              break;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   384
          }
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
        if ( passed ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   389
          $(this).animate({opacity: 'show' , height: 'show'}, 200);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   390
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   391
          $(this).animate({opacity: 'hide' , height: 'hide'}, 200);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   392
        }
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
        delete passed;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   395
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
    init_conditions: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   399
      var delay = (function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   400
        var timer = 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   401
        return function(callback, ms) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   402
          clearTimeout(timer);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   403
          timer = setTimeout(callback, ms);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   404
        };
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
      $('.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
   408
        if (e.type === 'keyup') {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   409
          // handle keyup event only once every 500ms
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   410
          delay(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   411
            OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   412
          }, 500);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   413
        } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   414
          OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   415
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   416
        OT_UI.load_editors();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   417
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   418
      OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   419
    },
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   420
    init_upload: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   421
      $(document).on('click', '.ot_upload_media', function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   422
        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
   423
            post_id             = $(this).attr('rel'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   424
            save_attachment_id  = $('#'+field_id).hasClass('ot-upload-attachment-id'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   425
            btnContent          = '';
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   426
        if ( window.wp && wp.media ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   427
          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
   428
            title: $(this).attr('title'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   429
            button: {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   430
              text: option_tree.upload_text
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   431
            }, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   432
            multiple: false
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   433
          });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   434
          window.ot_media_frame.on('select', function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   435
            var attachment = window.ot_media_frame.state().get('selection').first(), 
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   436
                href = attachment.attributes.url,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   437
                attachment_id = attachment.attributes.id,
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   438
                mime = attachment.attributes.mime,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   439
                regex = /^image\/(?:jpe?g|png|gif|x-icon)$/i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   440
            if ( mime.match(regex) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   441
              btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+href+'" alt="" /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   442
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   443
            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
   444
            $('#'+field_id).val( ( save_attachment_id ? attachment_id : href ) );
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   445
            $('#'+field_id+'_media').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   446
            $('#'+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
   447
            $('#'+field_id+'_media').append(btnContent).slideDown();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   448
            window.ot_media_frame.off('select');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   449
          }).open();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   450
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   451
          var backup = window.send_to_editor,
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   452
              intval = window.setInterval( 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   453
                function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   454
                  if ( $('#TB_iframeContent').length > 0 && $('#TB_iframeContent').attr('src').indexOf( "&field_id=" ) !== -1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   455
                    $('#TB_iframeContent').contents().find('#tab-type_url').hide();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   456
                  }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   457
                  $('#TB_iframeContent').contents().find('.savesend .button').val(option_tree.upload_text); 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   458
                }, 50);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   459
          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
   460
          window.send_to_editor = function(html) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   461
            var href = $(html).find('img').attr('src');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   462
            if ( typeof href == 'undefined') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   463
              href = $(html).attr('src');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   464
            } 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   465
            if ( typeof href == 'undefined') {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   466
              href = $(html).attr('href');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   467
            }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   468
            var image = /\.(?:jpe?g|png|gif|ico)$/i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   469
            if (href.match(image) && OT_UI.url_exists(href)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   470
              btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+href+'" alt="" /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   471
            }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   472
            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
   473
            $('#'+field_id).val(href);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   474
            $('#'+field_id+'_media').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   475
            $('#'+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
   476
            $('#'+field_id+'_media').append(btnContent).slideDown();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   477
            OT_UI.fix_upload_parent();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   478
            tb_remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   479
            window.clearInterval(intval);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   480
            window.send_to_editor = backup;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   481
          };
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   482
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   483
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   484
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   485
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   486
    init_upload_remove: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   487
      $(document).on('click', '.option-tree-ui-remove-media', function(event) {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   488
        event.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   489
        var agree = confirm(option_tree.remove_agree);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   490
        if (agree) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   491
          OT_UI.remove_image(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   492
          return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   493
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   494
        return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   495
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   496
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   497
    init_upload_fix: function(elm) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   498
      var id  = $(elm).attr('id'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   499
          val = $(elm).val(),
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   500
          img = $(elm).parent().next('.option-tree-ui-media-wrap').find('img'),
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   501
          src = img.attr('src'),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   502
          btnContent = '';
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   503
      if ( val == src ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   504
        return;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   505
      }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   506
      if ( val != src ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   507
        img.attr('src', val);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   508
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   509
      if ( val !== '' && ( typeof src == 'undefined' || src == false ) && OT_UI.url_exists(val) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   510
        var image = /\.(?:jpe?g|png|gif|ico)$/i;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   511
        if (val.match(image)) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   512
          btnContent += '<div class="option-tree-ui-image-wrap"><img src="'+val+'" alt="" /></div>';
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   513
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   514
        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
   515
        $('#'+id).val(val);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   516
        $('#'+id+'_media').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   517
        $('#'+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
   518
        $('#'+id+'_media').append(btnContent).slideDown();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   519
      } else if ( val == '' || ! OT_UI.url_exists(val) ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   520
        $(elm).parent().next('.option-tree-ui-media-wrap').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   521
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   522
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   523
    init_numeric_slider: function(scope) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   524
      scope = scope || document;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   525
      $(".ot-numeric-slider-wrap", scope).each(function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   526
        var hidden = $(".ot-numeric-slider-hidden-input", this),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   527
            value  = hidden.val(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   528
            helper = $(".ot-numeric-slider-helper-input", this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   529
        if ( ! value ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   530
          value = hidden.data("min");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   531
          helper.val(value)
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   532
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   533
        $(".ot-numeric-slider", this).slider({
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   534
          min: hidden.data("min"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   535
          max: hidden.data("max"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   536
          step: hidden.data("step"),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   537
          value: value, 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   538
          slide: function(event, ui) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   539
            hidden.add(helper).val(ui.value).trigger('change');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   540
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   541
          create: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   542
            hidden.val($(this).slider('value'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   543
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   544
          change: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   545
            OT_UI.parse_condition();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   546
          }
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
    init_tabs: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   551
      $(".wrap.settings-wrap .ui-tabs").tabs({ 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   552
        fx: { 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   553
          opacity: "toggle", 
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   554
          duration: "fast"
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   555
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   556
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   557
      $(".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
   558
        var obj = "input[name='_wp_http_referer']";
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   559
        if ( $(obj).length > 0 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   560
          var url = $(obj).val(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   561
              hash = $(this).attr('href');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   562
          if ( url.indexOf("#") != -1 ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   563
            var o = url.split("#")[1],
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   564
                n = hash.split("#")[1];
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   565
            url = url.replace(o, n);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   566
          } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   567
            url = url + hash;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   568
          }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   569
          $(obj).val(url);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   570
        }
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
    init_radio_image_select: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   574
      $(document).on('click', '.option-tree-ui-radio-image', function() {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   575
        $(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
   576
        $(this).toggleClass('option-tree-ui-radio-image-selected');
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   577
        $(this).parent().find('.option-tree-ui-radio').prop('checked', true).trigger('change');
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   578
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   579
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   580
    init_select_wrapper: function(scope) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   581
      scope = scope || document;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   582
      $('.option-tree-ui-select', scope).each(function () {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   583
        if ( ! $(this).parent().hasClass('select-wrapper') ) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   584
          $(this).wrap('<div class="select-wrapper" />');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   585
          $(this).parent('.select-wrapper').prepend('<span>' + $(this).find('option:selected').text() + '</span>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   586
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   587
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   588
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   589
    bind_select_wrapper: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   590
      $(document).on('change', '.option-tree-ui-select', function () {
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   591
        $(this).prev('span').replaceWith('<span>' + $(this).find('option:selected').text() + '</span>');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   592
      });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   593
    },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   594
    init_google_fonts: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   595
      var update_items = function(input, items, element) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   596
        var itemsUI = input.closest('.type-google-font-group').find(element);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   597
        if ( itemsUI.length ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   598
          itemsUI.empty();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   599
          itemsUI.append($.map(items, function(item) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   600
            var input = document.createElement('input'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   601
                label = document.createElement('label');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   602
            input.type = 'checkbox';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   603
            input.id = ( itemsUI.data('field-id-prefix') || '' ) + item;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   604
            input.name =  ( itemsUI.data('field-name') || '' ) + '[]';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   605
            input.value =  item;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   606
            label.innerHTML = item;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   607
            $( label ).attr( 'for', input.id );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   608
            return $( document.createElement('p') ).addClass('checkbox-wrap').append([input, label]);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   609
          }));
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
      $(document).on('change', '.option-tree-google-font-family select', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   613
        var input = $(this);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   614
        $.ajax({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   615
          url: option_tree.ajax,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   616
          type: 'POST',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   617
          dataType: 'json',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   618
          data: {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   619
            action: 'ot_google_font',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   620
            family: input.val(), 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   621
            field_id: input.attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   622
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   623
        }).done(function(response) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   624
          if ( response.hasOwnProperty('variants') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   625
            update_items( input, response.variants, '.option-tree-google-font-variants' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   626
          }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   627
          if ( response.hasOwnProperty('subsets') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   628
            update_items( input, response.subsets, '.option-tree-google-font-subsets' );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   629
          }
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
      $('.js-add-google-font').on('click', function (event) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   633
        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
   634
            $el_clone = $(this).prev('.type-google-font-group-clone'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   635
            $clone = $el_clone.clone(true),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   636
            $count = $group.length ? $group.length : 0;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   637
        $clone.attr('class', 'type-google-font-group');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   638
        var replacer = function(index, elm) { 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   639
          return elm.replace('%key%', $count);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   640
        }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   641
        $('select', $clone).each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   642
          $(this).attr('id', replacer ).attr('name', replacer );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   643
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   644
        $('.option-tree-google-font-variants', $clone).each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   645
          $(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
   646
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   647
        $('.option-tree-google-font-subsets', $clone).each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   648
          $(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
   649
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   650
        $el_clone.before($clone)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   651
        event.preventDefault()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   652
      });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   653
      $('.js-remove-google-font').on('click', function (event) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   654
        $(this).parents('.type-google-font-group').remove();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   655
        event.preventDefault();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   656
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   657
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   658
    bind_colorpicker: function(field_id) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   659
      $('#'+field_id).wpColorPicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   660
        change: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   661
          OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   662
        }, 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   663
        clear: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   664
          OT_UI.parse_condition();
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   665
        }
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   666
      });
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
    bind_date_picker: function(field_id, date_format) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   669
      $('#'+field_id).datepicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   670
        showOtherMonths: true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   671
        showButtonPanel: true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   672
        currentText: option_tree.date_current,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   673
        closeText: option_tree.date_close,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   674
        dateFormat: date_format
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   675
      });
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
    bind_date_time_picker: function(field_id, date_format) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   678
      $('#'+field_id).datetimepicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   679
        showOtherMonths: true,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   680
        closeText: option_tree.date_close,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   681
        dateFormat: date_format
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   682
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   683
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   684
    fix_upload_parent: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   685
      $('.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
   686
        $(this).parent('.option-tree-ui-upload-parent').toggleClass('focus');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   687
        OT_UI.init_upload_fix(this);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   688
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   689
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   690
    remove_image: function(e) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   691
      $(e).parent().parent().find('.option-tree-ui-upload-input').attr('value','');
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   692
      $(e).parent('.option-tree-ui-media-wrap').remove();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   693
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   694
    fix_textarea: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   695
      $('.wp-editor-area').focus( function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   696
        $(this).parent('div').css({borderColor:'#bbb'});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   697
      }).blur( function(){
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   698
        $(this).parent('div').css({borderColor:'#ccc'});
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   699
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   700
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   701
    replicate_ajax: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   702
      if (location.href.indexOf("#") != -1) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   703
        var url = $("input[name=\'_wp_http_referer\']").val(),
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   704
            hash = location.href.substr(location.href.indexOf("#"));
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   705
        $("input[name=\'_wp_http_referer\']").val( url + hash );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   706
        this.scroll_to_top();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   707
      }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   708
      setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   709
        $(".wrap.settings-wrap .fade").fadeOut("fast");
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   710
      }, 3000 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   711
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   712
    reset_settings: function() {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   713
      $(document).on("click", ".reset-settings", function(event){
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   714
        var agree = confirm(option_tree.reset_agree);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   715
        if (agree) {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   716
          return true;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   717
        } else {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   718
          return false;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   719
        }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   720
        event.preventDefault();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   721
      });
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   722
    },
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   723
    css_editor_mode: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   724
      $('.ot-css-editor').each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   725
        var editor = ace.edit($(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   726
        var this_textarea = $('#textarea_' + $(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   727
        editor.setTheme("ace/theme/chrome");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   728
        editor.getSession().setMode("ace/mode/css");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   729
        editor.setShowPrintMargin( false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   730
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   731
        editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   732
        editor.getSession().on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   733
          this_textarea.val(editor.getSession().getValue());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   734
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   735
        this_textarea.on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   736
          editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   737
        });
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
    javascript_editor_mode: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   741
      $('.ot-javascript-editor').each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   742
        var editor = ace.edit($(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   743
        var this_textarea = $('#textarea_' + $(this).attr('id'));
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   744
        editor.setTheme("ace/theme/chrome");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   745
        editor.getSession().setMode("ace/mode/javascript");
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   746
        editor.setShowPrintMargin( false );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   747
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   748
        editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   749
        editor.getSession().on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   750
          this_textarea.val(editor.getSession().getValue());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   751
        });
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   752
        this_textarea.on('change', function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   753
          editor.getSession().setValue(this_textarea.val());
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   754
        });
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
    load_editors: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   758
      OT_UI.css_editor_mode();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   759
      OT_UI.javascript_editor_mode();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   760
    },
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   761
    url_exists: function(url) {
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   762
      var link = document.createElement('a')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   763
      link.href = url
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   764
      if ( link.hostname != window.location.hostname ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   765
        return true; // Stop the code from checking across domains.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   766
      }
0
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   767
      var http = new XMLHttpRequest();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   768
      http.open('HEAD', url, false);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   769
      http.send();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   770
      return http.status!=404;
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   771
    },
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   772
    scroll_to_top: function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   773
      setTimeout( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   774
        $(this).scrollTop(0);
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   775
      }, 50 );
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   776
    }
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   777
  };
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   778
  $(document).ready( function() {
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   779
    OT_UI.init();
d970ebf37754 first import
ymh <ymh.work@gmail.com>
parents:
diff changeset
   780
  });
5
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   781
})(jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   782
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   783
/* Gallery */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   784
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   785
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   786
  ot_gallery = {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   787
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   788
    frame: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   789
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   790
      var selection = this.select(elm)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   791
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   792
      this._frame = wp.media({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   793
        id:         'ot-gallery-frame'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   794
      , frame:      'post'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   795
      , state:      'gallery-edit'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   796
      , title:      wp.media.view.l10n.editGalleryTitle
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   797
      , editing:    true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   798
      , multiple:   true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   799
      , selection:  selection
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   800
      })
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
      this._frame.on('update', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   803
        var controller = ot_gallery._frame.states.get('gallery-edit')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   804
          , library = controller.get('library')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   805
          , ids = library.pluck('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   806
          , parent = $(elm).parents('.format-setting-inner')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   807
          , input = parent.children('.ot-gallery-value')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   808
          , shortcode = wp.media.gallery.shortcode( selection ).string().replace(/\"/g,"'")
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   809
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   810
        input.attr('value', ids)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   811
                        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   812
        if ( parent.children('.ot-gallery-list').length <= 0 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   813
          input.after('<ul class="ot-gallery-list" />')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   814
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   815
        $.ajax({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   816
          type: 'POST',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   817
          url: ajaxurl,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   818
          dataType: 'html',
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   819
          data: {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   820
            action: 'gallery_update'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   821
          , ids: ids
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   822
          },
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   823
          success: function(res) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   824
            parent.children('.ot-gallery-list').html(res);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   825
            if ( input.hasClass('ot-gallery-shortcode') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   826
              input.val(shortcode);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   827
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   828
            if ( $(elm).parent().children('.ot-gallery-delete').length <= 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   829
              $(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
   830
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   831
            $(elm).text(option_tree.edit);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   832
            OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   833
          }
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
      return this._frame
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   838
      
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
  , select: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   842
      var input = $(elm).parents('.format-setting-inner').children('.ot-gallery-value')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   843
        , ids = input.attr('value')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   844
        , _shortcode = input.hasClass('ot-gallery-shortcode') ? ids : '[gallery ids=\'' + ids + '\]'
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   845
        , 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
   846
        , defaultPostId = wp.media.gallery.defaults.id
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   847
        , attachments
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   848
        , selection
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   849
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   850
      // 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
   851
      if ( ! shortcode )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   852
        return
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   853
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   854
      // Ignore the rest of the match object.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   855
      shortcode = shortcode.shortcode
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   856
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   857
      if ( _.isUndefined( shortcode.get('id') ) && ! _.isUndefined( defaultPostId ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   858
        shortcode.set( 'id', defaultPostId )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   859
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   860
      if ( _.isUndefined( shortcode.get('ids') ) && ! input.hasClass('ot-gallery-shortcode') && ids )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   861
        shortcode.set( 'ids', ids )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   862
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   863
      if ( _.isUndefined( shortcode.get('ids') ) )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   864
        shortcode.set( 'ids', '0' )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   865
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   866
      attachments = wp.media.gallery.attachments( shortcode )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   867
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   868
      selection = new wp.media.model.Selection( attachments.models, {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   869
        props:    attachments.props.toJSON()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   870
      , multiple: true
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   871
      })
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
      selection.gallery = attachments.gallery
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   874
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   875
      // 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
   876
      selection.more().done( function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   877
        selection.props.set({ query: false })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   878
        selection.unmirror()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   879
        selection.props.unset('orderby')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   880
      })
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
      return selection
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   883
      
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
  , open: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   887
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   888
      ot_gallery.frame(elm).open()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   889
      
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
  , remove: function (elm) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   893
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   894
      if ( confirm( option_tree.confirm ) ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   895
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   896
        $(elm).parents('.format-setting-inner').children('.ot-gallery-value').attr('value', '');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   897
        $(elm).parents('.format-setting-inner').children('.ot-gallery-list').remove();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   898
        $(elm).next('.ot-gallery-edit').text( option_tree.create );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   899
        $(elm).remove();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   900
        OT_UI.parse_condition();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   901
        
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
  // Gallery delete
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   909
  $(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
   910
    e.preventDefault()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   911
    ot_gallery.remove($(this))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   912
  })
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
  // Gallery edit
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   915
  $(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
   916
    e.preventDefault()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   917
    ot_gallery.open($(this))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   918
  })
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
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   921
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
 * Adds metabox tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   924
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   925
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   926
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   927
  $(document).on('ready', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   928
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   929
    // Loop over the metaboxes
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   930
    $('.ot-metabox-wrapper').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   931
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   932
      // Only if there is a tab option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   933
      if ( $(this).find('.type-tab').length ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   934
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   935
        // Add .ot-metabox-panels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   936
        $(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
   937
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   938
        // 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
   939
        $(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
   940
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   941
        // Loop over settings and build the tabs nav
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   942
        $(this).find('.format-settings').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   943
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   944
          if ( $(this).find('.type-tab').length > 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   945
            var title = $(this).find('.type-tab').prev().find('label').text()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   946
              , id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   947
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   948
            // Add a class, hide & append nav item 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   949
            $(this).addClass('is-panel').hide()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   950
            $(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
   951
            
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
        // Loop over the panels and wrap and ID them.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   957
        $(this).find('.is-panel').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   958
          var id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   959
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   960
          $(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
   961
          
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
        // Create the tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   965
        $(this).find('.ot-metabox-tabs').tabs({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   966
          activate: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   967
            var parent = $(this).outerHeight(),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   968
                child = $(this).find('.ot-metabox-panels').outerHeight() + 8,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   969
                minHeight = parent - 34
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   970
            if ( $(this).find('.ot-metabox-panels').css('padding') == '12px' && child < parent ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   971
              $(this).find('.ot-metabox-panels').css({ minHeight: minHeight })
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   972
            }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   973
            OT_UI.load_editors();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   974
          }
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
        // Move the orphaned settings to the top
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   978
        $(this).find('.ot-metabox-panels > .format-settings').prependTo($(this))
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   979
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   980
        // Remove a bunch of classes to stop style conflicts.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   981
        $(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
   982
        $(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
   983
        $(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
   984
        $(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
   985
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
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   993
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
 * Adds theme option tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   996
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   997
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   998
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
   999
  $(document).on('ready', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1000
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1001
    // Loop over the theme options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1002
    $('#option-tree-settings-api .inside').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1003
    
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1004
      // Only if there is a tab option
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1005
      if ( $(this).find('.type-tab').length ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1006
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1007
        // Add .ot-theme-option-panels
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1008
        $(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
  1009
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1010
        // 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
  1011
        $(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
  1012
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1013
        // Loop over settings and build the tabs nav
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1014
        $(this).find('.format-settings').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1015
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1016
          if ( $(this).find('.type-tab').length > 0 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1017
            var title = $(this).find('.type-tab').prev().find('.label').text()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1018
              , id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1019
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1020
            // Add a class, hide & append nav item 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1021
            $(this).addClass('is-panel').hide()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1022
            $(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
  1023
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1024
          } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1025
          
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
        // Loop over the panels and wrap and ID them.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1031
        $(this).find('.is-panel').each( function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1032
          var id = $(this).attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1033
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1034
          $(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
  1035
          
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
        // Create the tabs
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1039
        $(this).find('.ot-theme-option-tabs').tabs({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1040
          activate: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1041
            OT_UI.load_editors();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1042
          }
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
        // Move the orphaned settings to the top
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1046
        $(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
  1047
      
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
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1055
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
 * 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
  1058
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1059
!function ($) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1060
  
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1061
  $(document).on('ready', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1062
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1063
    // detect mousedown and store all checked radio buttons
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1064
    $('.hndle').on('mousedown', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1065
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1066
      // get parent element of .hndle selected. 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1067
      // 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
  1068
      var parent_id = $(this).closest('div').attr('id')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1069
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1070
      // set live event listener for mouse up on the content .wrap 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1071
      // 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
  1072
      $('.wrap').on('mouseup', function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1073
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1074
        var ot_checked_radios = {}
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1075
        
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1076
        // loop over all checked radio buttons inside of parent element
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1077
        $('#' + parent_id + ' input[type="radio"]').each( function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1078
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1079
          // stores checked radio buttons
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1080
          if ( $(this).is(':checked') ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1081
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1082
            ot_checked_radios[$(this).attr('name')] = $(this).val()
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1083
          
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
          // write to the object
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1087
          $(document).data('ot_checked_radios', ot_checked_radios)
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1088
          
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
        // restore all checked radio buttons 
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1092
        setTimeout( function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1093
      
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1094
          // get object of checked radio button names and values
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1095
          var checked = $(document).data('ot_checked_radios')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1096
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1097
          // 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
  1098
          for ( key in checked ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1099
            
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1100
            $('input[name="' + key + '"]').filter('[value="' + checked[key] + '"]').trigger('click')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1101
            
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
          $('.wrap').unbind('mouseup')
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1105
          
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1106
        }, 50 )
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1107
      
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
}(window.jQuery);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1115
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
 * Adds opacity to the default colorpicker
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1118
 *
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1119
 * Derivative work of the Codestar WP Color Picker.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1120
 */
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1121
;(function ( $, window, document, undefined ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1122
  'use strict';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1123
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1124
  // adding alpha support for Automattic Color.js toString function.
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1125
  if( typeof Color.fn.toString !== undefined ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1126
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1127
    Color.fn.toString = function () {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1128
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1129
      // check for alpha
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1130
      if ( this._alpha < 1 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1131
        return this.toCSS('rgba', this._alpha).replace(/\s+/g, '');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1132
      }
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
      var hex = parseInt( this._color, 10 ).toString( 16 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1135
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1136
      if ( this.error ) { return ''; }
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1137
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1138
      // maybe left pad it
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1139
      if ( hex.length < 6 ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1140
        for (var i = 6 - hex.length - 1; i >= 0; i--) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1141
          hex = '0' + hex;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1142
        }
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
      return '#' + hex;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1146
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
  $.ot_ParseColorValue = function( val ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1152
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1153
    var value = val.replace(/\s+/g, ''),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1154
        alpha = ( value.indexOf('rgba') !== -1 ) ? parseFloat( value.replace(/^.*,(.+)\)/, '$1') * 100 ) : 100,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1155
        rgba  = ( alpha < 100 ) ? true : false;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1156
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1157
    return { value: value, alpha: alpha, rgba: rgba };
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1158
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
  $.fn.ot_wpColorPicker = function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1162
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1163
    return this.each(function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1164
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1165
      var $this = $(this);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1166
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1167
      // check for rgba enabled/disable
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1168
      if( $this.data('rgba') !== false ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1169
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1170
        // parse value
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1171
        var picker = $.ot_ParseColorValue( $this.val() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1172
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1173
        // wpColorPicker core
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1174
        $this.wpColorPicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1175
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1176
          // wpColorPicker: change
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1177
          change: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1178
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1179
            // update checkerboard background color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1180
            $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
  1181
            $this.trigger('keyup');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1182
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
          // wpColorPicker: create
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1186
          create: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1187
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1188
            // set variables for alpha slider
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1189
            var a8cIris       = $this.data('a8cIris'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1190
                $container    = $this.closest('.wp-picker-container'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1191
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1192
                // appending alpha wrapper
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1193
                $alpha_wrap   = $('<div class="option-tree-opacity-wrap">' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1194
                                  '<div class="option-tree-opacity-slider"></div>' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1195
                                  '<div class="option-tree-opacity-slider-offset"></div>' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1196
                                  '<div class="option-tree-opacity-text"></div>' +
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1197
                                  '</div>').appendTo( $container.find('.wp-picker-holder') ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1198
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1199
                $alpha_slider = $alpha_wrap.find('.option-tree-opacity-slider'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1200
                $alpha_text   = $alpha_wrap.find('.option-tree-opacity-text'),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1201
                $alpha_offset = $alpha_wrap.find('.option-tree-opacity-slider-offset');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1202
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1203
            // alpha slider
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1204
            $alpha_slider.slider({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1205
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1206
              // slider: slide
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1207
              slide: function( event, ui ) {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1208
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1209
                var slide_value = parseFloat( ui.value / 100 );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1210
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1211
                // update iris data alpha && wpColorPicker color option && alpha text
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1212
                a8cIris._color._alpha = slide_value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1213
                $this.wpColorPicker( 'color', a8cIris._color.toString() );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1214
                $alpha_text.text( ( slide_value < 1 ? slide_value : '' ) );
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1215
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
              // slider: create
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1219
              create: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1220
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1221
                var slide_value = parseFloat( picker.alpha / 100 ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1222
                    alpha_text_value = slide_value < 1 ? slide_value : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1223
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1224
                // update alpha text && checkerboard background color
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1225
                $alpha_text.text(alpha_text_value);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1226
                $alpha_offset.css('background-color', picker.value);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1227
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1228
                // 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
  1229
                $container.on('click', '.wp-picker-clear', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1230
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1231
                  a8cIris._color._alpha = 1;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1232
                  $alpha_text.text('');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1233
                  $alpha_slider.slider('option', 'value', 100).trigger('slide');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1234
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
                // 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
  1238
                $container.on('click', '.wp-picker-default', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1239
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1240
                  var default_picker = $.ot_ParseColorValue( $this.data('default-color') ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1241
                      default_value  = parseFloat( default_picker.alpha / 100 ),
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1242
                      default_text   = default_value < 1 ? default_value : '';
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1243
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1244
                  a8cIris._color._alpha = default_value;
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1245
                  $alpha_text.text(default_text);
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1246
                  $alpha_slider.slider('option', 'value', default_picker.alpha).trigger('slide');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1247
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
                // show alpha wrapper on click color picker button
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1251
                $container.on('click', '.wp-color-result', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1252
                  $alpha_wrap.toggle();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1253
                });
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
                // hide alpha wrapper on click body
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1256
                $('body').on( 'click.wpcolorpicker', function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1257
                  $alpha_wrap.hide();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1258
                });
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
              // slider: options
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1263
              value: picker.alpha,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1264
              step: 1,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1265
              min: 1,
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1266
              max: 100
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1267
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
      } else {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1274
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1275
        // wpColorPicker default picker
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1276
        $this.wpColorPicker({
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1277
          change: function() {
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1278
            $this.trigger('keyup');
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1279
          }
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
  $(document).ready( function(){
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1289
    $('.hide-color-picker.ot-colorpicker-opacity').ot_wpColorPicker();
5e2f62d02dcd upgrade wordpress + plugins
ymh <ymh.work@gmail.com>
parents: 0
diff changeset
  1290
  });
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
})( jQuery, window, document );