Child Theme Configurator - Version 1.2.2

Version Description

  • New Features: You can now rename selectors in place from the Query/Selector panel. Made stylesheet backup optional. Bugs fixed: Incorrect parsing of background position when '0', fixed type error when background image url value is removed.
Download this release

Release Info

Developer lilaeamedia
Plugin Icon 128x128 Child Theme Configurator
Version 1.2.2
Comparing to
See all releases

Code changes from version 1.2.1 to 1.2.2

child-theme-configurator.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined('ABSPATH')) exit;
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Create a Child Theme from any installed Theme. Each CSS selector, rule and value can then be searched, previewed and modified.
9
- Version: 1.2.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
6
  Plugin Name: Child Theme Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Create a Child Theme from any installed Theme. Each CSS selector, rule and value can then be searched, previewed and modified.
9
+ Version: 1.2.2
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
chld-thm-cfg.js DELETED
@@ -1,946 +0,0 @@
1
- /*!
2
- * Script: chld-thm-cfg.js
3
- * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
- * Description: Handles jQuery, AJAX and other UI
5
- * Version: 1.2.1
6
- * Author: Lilaea Media
7
- * Author URI: http://www.lilaeamedia.com/
8
- * License: GPLv2
9
- * Copyright (C) 2013 Lilaea Media
10
- */
11
- jQuery(document).ready(function($){
12
-
13
- var lf = "\n",
14
- currentQuery = 'base',
15
- currentSel,
16
- saveEvents = {},
17
- // initialize functions
18
- ctc_setup_iris = function(obj) {
19
- $(obj).iris({
20
- change: function() {
21
- ctc_coalesce_inputs(obj);
22
- }
23
- });
24
- },
25
- from_ascii = function(str) {
26
- var ascii = parseInt(str),
27
- chr = String.fromCharCode(ascii)
28
- return chr;
29
- },
30
- to_ascii = function(str) {
31
- var ascii = str.charCodeAt(0);
32
- return ascii;
33
- },
34
- ctc_coalesce_inputs = function(obj) {
35
- var regex = /^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+))(_\w+)?$/,
36
- $container = $(obj).parents('.ctc-selector-row, .ctc-parent-row').first(),
37
- $swatch = $container.find('.ctc-swatch').first(),
38
- cssrules = { 'parent': {}, 'child': {} },
39
- gradient = {
40
- 'parent': {
41
- 'origin': '',
42
- 'start': '',
43
- 'end': ''
44
- },
45
- 'child': {
46
- 'origin': '',
47
- 'start': '',
48
- 'end': ''
49
- }
50
- },
51
- has_gradient = { 'child': false, 'parent': false },
52
- postdata = {};
53
- // set up objects for all neighboring inputs
54
- $container.find('.ctc-parent-value, .ctc-child-value').each(function(){
55
- var inputid = $(this).attr('id'),
56
- inputparts = inputid.toString().match(regex),
57
- inputseq = inputparts[2],
58
- inputtheme = inputparts[3],
59
- inputrule = ('undefined' == typeof inputparts[4] ? '' : inputparts[4]),
60
- qsid = inputparts[5],
61
- rulepart = ('undefined' == typeof inputparts[6] ? '' : inputparts[6]),
62
- value = ('parent' == inputtheme ? $(this).text() : $(this).val()),
63
- important = 'ctc_' + inputseq + '_child_' + inputrule + '_i_' + qsid,
64
- parts, subparts;
65
- if ('child' == inputtheme) {
66
- postdata[inputid] = value;
67
- postdata[important] = ($('#' + important).is(':checked')) ? 1 : 0;
68
- }
69
- /*if ('' === value) {
70
- $('#'+important).prop('checked', false);
71
- return;
72
- }*/
73
- // handle specific inputs
74
- if (false === ctc_is_empty(rulepart)) {
75
- switch(rulepart) {
76
- case '_border_width':
77
- cssrules[inputtheme][inputrule + '-width'] = value;
78
- break;
79
- case '_border_style':
80
- cssrules[inputtheme][inputrule + '-style'] = value;
81
- break;
82
- case '_border_color':
83
- cssrules[inputtheme][inputrule + '-color'] = value;
84
- break;
85
- case '_background_url':
86
- cssrules[inputtheme]['background-image'] = ctc_image_url(inputtheme, value);
87
- break;
88
- case '_background_color':
89
- cssrules[inputtheme]['background-color'] = obj.value;
90
- break;
91
- case '_background_color1':
92
- gradient[inputtheme].start = value;
93
- has_gradient[inputtheme] = true;
94
- break;
95
- case '_background_color2':
96
- gradient[inputtheme].end = value;
97
- has_gradient[inputtheme] = true;
98
- break;
99
- case '_background_origin':
100
- gradient[inputtheme].origin = value;
101
- has_gradient[inputtheme] = true;
102
- break;
103
- }
104
- } else {
105
- // handle borders
106
- if (parts = inputrule.toString().match(/^border(\-(top|right|bottom|left))?$/) && !value.match(/none/)) {
107
- subparts = value.toString().split(/ +/);
108
- cssrules[inputtheme][inputrule + '-width'] = 'undefined' == typeof subparts[0] ? '' : subparts[0];
109
- cssrules[inputtheme][inputrule + '-style'] = 'undefined' == typeof subparts[1] ? '' : subparts[1];
110
- cssrules[inputtheme][inputrule + '-color'] = 'undefined' == typeof subparts[2] ? '' : subparts[2];
111
- // handle background images
112
- } else if ( 'background-image' == inputrule ) {
113
- if (value.toString().match(/url\(/)) {
114
- cssrules[inputtheme]['background-image'] = ctc_image_url(inputtheme, value);
115
- } else {
116
- subparts = value.toString().split(/ +/);
117
- if (subparts.length > 2) {
118
- gradient[inputtheme].origin = 'undefined' == typeof subparts[0] ? 'top' : subparts[0];
119
- gradient[inputtheme].start = 'undefined' == typeof subparts[1] ? 'transparent' : subparts[1];
120
- gradient[inputtheme].end = 'undefined' == typeof subparts[2] ? 'transparent' : subparts[2];
121
- has_gradient[inputtheme] = true;
122
- } else {
123
- cssrules[inputtheme]['background-image'] = value;
124
- }
125
- }
126
- } else {
127
- cssrules[inputtheme][inputrule] = value;
128
- }
129
- }
130
- });
131
- // update swatch
132
- if ('undefined' != typeof $swatch) {
133
- $($swatch).removeAttr('style');
134
- if (has_gradient.parent) { $($swatch).ctcgrad(gradient.parent.origin, [gradient.parent.start, gradient.parent.end]); }
135
- $($swatch).css(cssrules.parent);
136
- if (!($swatch.attr('id').toString().match(/parent/))){
137
- if (has_gradient.child) { $($swatch).ctcgrad(gradient.child.origin, [gradient.child.start, gradient.child.end]); }
138
- $($swatch).css(cssrules.child);
139
- }
140
- }
141
- return postdata;
142
- },
143
- ctc_update_cache = function(response) {
144
- var currQuery, currSelId, currRule;
145
- $(response).each(function(){
146
- switch (this.obj) {
147
- case 'imports':
148
- ctcAjax.imports = this.data;
149
- break;
150
-
151
- case 'rule_val':
152
- ctcAjax.rule_val[this.key] = this.data;
153
- currRuleId = this.key;
154
- break;
155
-
156
- case 'val_qry':
157
- ctcAjax.val_qry[this.key] = this.data;
158
- break;
159
-
160
- case 'rule':
161
- ctcAjax.rule = this.data;
162
- break;
163
-
164
- case 'sel_ndx':
165
- if (ctc_is_empty(this.key)) {
166
- ctcAjax.sel_ndx = this.data;
167
- } else if ('qsid' == this.key) {
168
- if (ctc_is_empty(ctcAjax.sel_ndx[this.data.query])) {
169
- ctcAjax.sel_ndx[this.data.query] = {}
170
- }
171
- ctcAjax.sel_ndx[this.data.query][this.data.selector] = this.data.qsid;
172
- } else {
173
- ctcAjax.sel_ndx[this.key] = this.data;
174
- currQuery = this.key;
175
- }
176
- break;
177
-
178
- case 'sel_val':
179
- ctcAjax.sel_val[this.key] = this.data;
180
- currSelId = this.key;
181
- break;
182
- }
183
- });
184
- },
185
- ctc_image_url = function(theme, value) {
186
- var parts = value.toString().match(/url\([" ]*(.+?)[" ]*\)/),
187
- path = ctc_is_empty(parts) ? null : parts[1],
188
- url = ctcAjax.theme_uri + '/' + ('parent' == theme ? ctcAjax.parnt : ctcAjax.child) + '/',
189
- image_url;
190
- if (!path) {
191
- return false;
192
- } else if (path.toString().match(/^(https?:|\/)/)) {
193
- image_url = value;
194
- } else {
195
- image_url = 'url(' + url + path + ')';
196
- }
197
- return image_url;
198
- },
199
-
200
- ctc_is_empty = function(obj) {
201
- // first bail when definitely empty or undefined (true) NOTE: zero is not empty
202
- if ('undefined' == typeof obj || false === obj || null === obj || '' === obj) { return true; }
203
- // then, if this is bool, string or number it must not be empty (false)
204
- if (true === obj || "string" === typeof obj || "number" === typeof obj) { return false; }
205
- // thanks to Abena Kuttin for Win safe version
206
- // check for object type to be safe
207
- if ("object" === typeof obj) {
208
- // Use a standard for in loop
209
- for (var x in obj) {
210
- // A for in will iterate over members on the prototype
211
- // chain as well, but Object.getOwnPropertyNames returns
212
- // only those directly on the object, so use hasOwnProperty.
213
- if (obj.hasOwnProperty(x)) {
214
- // any value means not empty (false)
215
- return false;
216
- }
217
- }
218
- // no properties, so return empty (true)
219
- return true;
220
- }
221
- // this must be an unsupported datatype, so return not empty
222
- return false;
223
-
224
- },
225
-
226
- ctc_load_queries = function() {
227
- var arr = [];
228
- if (1 === loading.sel_ndx) return arr;
229
- if (0 === loading.sel_ndx) { // {
230
- // retrieve from server
231
- loading.sel_ndx = 1;
232
- ctc_query_css('sel_ndx', null, ctc_setup_query_menu);
233
- return arr;
234
- }
235
- if (false === ctc_is_empty(ctcAjax.sel_ndx)) {
236
- $.each(ctcAjax.sel_ndx, function(key, value) {
237
- var obj = { label: key, value: key };
238
- arr.push(obj);
239
- });
240
- }
241
- return arr;
242
- },
243
-
244
- ctc_load_selectors = function(query) {
245
- var arr = [];
246
- if (1 === loading.sel_ndx) {
247
- return arr;
248
- }
249
- if (0 === loading.sel_ndx) {
250
- // retrieve from server
251
- loading.sel_ndx = 1;
252
- ctc_query_css('sel_ndx', query, ctc_setup_selector_menu);
253
- return arr;
254
- }
255
- if (false === ctc_is_empty(ctcAjax.sel_ndx[query])) {
256
- $.each(ctcAjax.sel_ndx[query], function(key, value) {
257
- var obj = { label: key, value: value };
258
- arr.push(obj);
259
- });
260
- }
261
- return arr;
262
- },
263
-
264
- ctc_load_rules = function() {
265
- var arr = [];
266
- if (1 === loading.rule) return arr;
267
- if (0 === loading.rule) {
268
- loading.rule = 1;
269
- ctc_query_css('rule', null, ctc_setup_rule_menu);
270
- return arr;
271
- }
272
- if (false === ctc_is_empty(ctcAjax.rule)) {
273
- $.each(ctcAjax.rule, function(key, value) {
274
- var obj = { label: value.replace(/\d+/g, from_ascii), value: key };
275
- arr.push(obj);
276
- });
277
- }
278
- return arr.sort(function (a, b) {
279
- if (a.label > b.label)
280
- return 1;
281
- if (a.label < b.label)
282
- return -1;
283
- return 0;
284
- });
285
- },
286
-
287
- ctc_render_child_rule_input = function(qsid, rule, seq) {
288
- var html = '',
289
- value = (ctc_is_empty(ctcAjax.sel_val[qsid])
290
- || ctc_is_empty(ctcAjax.sel_val[qsid].value)
291
- || ctc_is_empty(ctcAjax.sel_val[qsid].value[rule]) ? '' : ctcAjax.sel_val[qsid].value[rule]),
292
- oldRuleObj = ctc_decode_value(rule, ('undefined' == typeof value ? '' : value['parnt'])),
293
- oldRuleFlag = (false === ctc_is_empty(value['i_parnt']) && value['i_parnt']) ?
294
- ctcAjax.important_label : '',
295
- newRuleObj = ctc_decode_value(rule, ('undefined' == typeof value ? '' : value['child'])),
296
- newRuleFlag = (false === ctc_is_empty(value['i_child']) && value['i_child']) ? 1 : 0,
297
- impid = 'ctc_' + seq + '_child_' + rule + '_i_' + qsid;
298
- if (false === ctc_is_empty(ctcAjax.sel_val[qsid])) {
299
- html += '<div class="ctc-' + ('ovrd' == seq ? 'input' : 'selector' ) + '-row clearfix">' + lf;
300
- html += '<div class="ctc-input-cell">' + ('ovrd' == seq ? rule.replace(/\d+/g, from_ascii) : ctcAjax.sel_val[qsid].selector
301
- + '<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_' + qsid + '" >' + ctcAjax.edit_txt + '</a> '
302
- + (ctc_is_empty(oldRuleObj.orig) ? ctcAjax.child_only_txt : ''))
303
- + '</div>' + lf;
304
- if ('ovrd' == seq) {
305
- html += '<div class="ctc-parent-value ctc-input-cell" id="ctc_' + seq + '_parent_' + rule + '_' + qsid + '">'
306
- + (ctc_is_empty(oldRuleObj.orig) ? '[no value]' : oldRuleObj.orig + oldRuleFlag) + '</div>' + lf;
307
- }
308
- html += '<div class="ctc-input-cell">' + lf;
309
- if (false === ctc_is_empty(oldRuleObj.names)){
310
- $.each(oldRuleObj.names, function(ndx, newname) {
311
- newname = (ctc_is_empty(newname) ? '' : newname);
312
- html += '<div class="ctc-child-input-cell">' + lf;
313
- var id = 'ctc_' + seq + '_child_' + rule + '_' + qsid + newname,
314
- newval;
315
- if (false === (newval = newRuleObj.values.shift()) ){
316
- newval = '';
317
- }
318
-
319
- html += (ctc_is_empty(newname) ? '' : ctcAjax.field_labels[newname] + ':<br/>')
320
- + '<input type="text" id="' + id + '" name="' + id + '" class="ctc-child-value'
321
- + ((newname + rule).toString().match(/color/) ? ' color-picker' : '')
322
- + ((newname).toString().match(/url/) ? ' ctc-input-wide' : '')
323
- + '" value="' + newval + '" />' + lf;
324
- html += '</div>' + lf;
325
- });
326
- html += '<label for="' + impid + '"><input type="checkbox" id="' + impid + '" name="' + impid + '" value="1" '
327
- + (1 === newRuleFlag ? 'checked' : '') + ' />' + ctcAjax.important_label + '</label>' + lf;
328
- }
329
- html += '</div>' + lf;
330
- html += ('ovrd' == seq ? '' : '<div class="ctc-swatch ctc-specific" id="ctc_child_' + rule + '_' + qsid + '_swatch">'
331
- + ctcAjax.swatch_txt + '</div>' + lf
332
- + '<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_' + rule + '_' + qsid + '_cell">' + lf
333
- + '<input type="button" class="button ctc-save-input" id="ctc_save_' + rule + '_' + qsid
334
- + '" name="ctc_save_' + rule + '_' + qsid + '" value="Save" /></div>' + lf);
335
- html += '</div><!-- end input row -->' + lf;
336
- }
337
- return html;
338
- },
339
-
340
- ctc_render_selector_inputs = function(qsid) {
341
- if (1 === loading.sel_val) {
342
- return false;
343
- }
344
- if (0 == loading.sel_val) {
345
- loading.sel_val = 1;
346
- ctc_query_css('sel_val', qsid, ctc_render_selector_inputs);
347
- return false;
348
- }
349
- var id, html, val;
350
- if (ctc_is_empty(ctcAjax.sel_val[qsid])) {
351
- $('#ctc_sel_ovrd_rule_inputs').html('')
352
- } else {
353
- if (ctc_is_empty(ctcAjax.sel_val[qsid].seq)) {
354
- $('#ctc_child_load_order_container').html('');
355
- } else {
356
- id = 'ctc_ovrd_child_seq_' + qsid;
357
- val = parseInt(ctcAjax.sel_val[qsid].seq);
358
- html = '<input type="text" id="' + id + '" name="' + id + '" class="ctc-child-value" value="' + val + '" />';
359
- $('#ctc_child_load_order_container').html(html);
360
- }
361
- if (ctc_is_empty(ctcAjax.sel_val[qsid].value)){
362
- $('#ctc_sel_ovrd_rule_inputs').html('');
363
- } else {
364
- html = '';
365
- $.each(ctcAjax.sel_val[qsid].value, function(rule, value) {
366
- html += ctc_render_child_rule_input(qsid, rule, 'ovrd');
367
- });
368
- $('#ctc_sel_ovrd_rule_inputs').html(html).find('.color-picker').each(function() {
369
- ctc_setup_iris(this);
370
- });
371
- ctc_coalesce_inputs('#ctc_child_all_0_swatch');
372
- }
373
- }
374
- }
375
-
376
- ctc_render_rule_value_inputs = function(ruleid) {
377
- if (1 === loading.rule_val) return false;
378
-
379
- if (0 == loading.rule_val) {
380
- loading.rule_val = 1;
381
- ctc_query_css('rule_val', ruleid, ctc_render_rule_value_inputs);
382
- return false;
383
- }
384
- var rule = ctcAjax.rule[ruleid],
385
- html = '<div class="ctc-input-row clearfix" id="ctc_rule_row_' + rule + '">' + lf;
386
- if (false === ctc_is_empty(ctcAjax.rule_val[ruleid])){
387
- $.each(ctcAjax.rule_val[ruleid], function(valid, value) {
388
- var oldRuleObj = ctc_decode_value(rule, value);
389
- html += '<div class="ctc-parent-row clearfix" id="ctc_rule_row_' + rule + '_' + valid + '">' + lf;
390
- html += '<div class="ctc-input-cell ctc-parent-value" id="ctc_' + valid + '_parent_' + rule + '_' + valid + '">'
391
- + oldRuleObj.orig + '</div>' + lf;
392
- html += '<div class="ctc-input-cell">' + lf;
393
- html += '<div class="ctc-swatch ctc-specific" id="ctc_' + valid + '_parent_' + rule + '_' + valid + '_swatch">'
394
- + ctcAjax.swatch_txt + '</div></div>' + lf;
395
- html += '<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_' + rule + '_' + valid + '">'
396
- + ctcAjax.selector_txt + '</a></div>' + lf;
397
- html += '<div id="ctc_selector_' + rule + '_' + valid + '_container" class="ctc-selector-container clearfix">' + lf;
398
- html += '<a href="#" id="ctc_selector_' + rule + '_' + valid + '_close" class="ctc-selector-handle" style="float:right">'
399
- + ctcAjax.close_txt + '</a><div id="ctc_status_val_qry_' + valid + '"></div>' + lf;
400
- html += '<div id="ctc_selector_' + rule + '_' + valid + '_rows"></div>' + lf;
401
- html += '</div></div>' + lf;
402
- });
403
- html += '</div>' + lf;
404
- }
405
- $('#ctc_rule_value_inputs').html(html).find('.ctc-swatch').each(function() {
406
- ctc_coalesce_inputs(this);
407
- });
408
- },
409
-
410
- ctc_render_selector_value_inputs = function(valid) {
411
- if (1 == loading.val_qry) return false;
412
- var params,
413
- page_ruleid,
414
- rule = $('#ctc_rule_menu_selected').text().replace(/[^\w\-]/g, to_ascii),
415
- selector,
416
- html = '';
417
- if (0 === loading.val_qry) {
418
- loading.val_qry = 1;
419
- params = { 'rule': rule };
420
- ctc_query_css('val_qry', valid, ctc_render_selector_value_inputs, params);
421
- return false;
422
- }
423
- if (false === ctc_is_empty(ctcAjax.val_qry[valid])){
424
- $.each(ctcAjax.val_qry[valid], function(rule, queries) {
425
- page_rule = rule;
426
- $.each(queries, function(query, selectors) {
427
- html += '<h4 class="ctc-query-heading">' + query + '</h4>' + lf;
428
- if (false === ctc_is_empty(selectors)){
429
- $.each(selectors, function(qsid, data) {
430
- ctcAjax.sel_val[qsid] = data;
431
- html += ctc_render_child_rule_input(qsid, rule, valid);
432
- });
433
- }
434
- });
435
- });
436
- }
437
- selector = '#ctc_selector_' + rule + '_' + valid + '_rows';
438
- $(selector).html(html).find('.color-picker').each(function() {
439
- ctc_setup_iris(this);
440
- });
441
- $(selector).find('.ctc-swatch').each(function() {
442
- ctc_coalesce_inputs(this);
443
- });
444
-
445
- },
446
- ctc_query_css = function(obj, key, callback, params) {
447
- var postdata = { 'ctc_query_obj' : obj, 'ctc_query_key': key },
448
- status_sel = '#ctc_status_' + obj + ('val_qry' == obj ? '_' + key : '');
449
-
450
- if ('object' === typeof params) {
451
- $.each(params, function(key, val){
452
- postdata['ctc_query_' + key] = val;
453
- });
454
- }
455
- $('.ctc-status-icon').remove();
456
- $(status_sel).append('<span class="ctc-status-icon spinner"></span>');
457
- $('.spinner').show();
458
- // add wp ajax action to array
459
- postdata['action'] = 'ctc_query';
460
- postdata['_wpnonce'] = $('#_wpnonce').val();
461
- // ajax post input data
462
- $.post(
463
- // get ajax url from localized object
464
- ctcAjax.ajaxurl,
465
- //Data
466
- postdata,
467
- //on success function
468
- function(response){
469
- // hide spinner
470
- loading[obj] = 2;
471
- $('.ctc-status-icon').removeClass('spinner');
472
- // show check mark
473
- if (ctc_is_empty(response)) {
474
- $('.ctc-status-icon').addClass('failure');
475
- } else {
476
- $('.ctc-status-icon').addClass('success');
477
- // update data objects
478
- ctc_update_cache(response);
479
- if ('function' === typeof callback) {
480
- callback(key);
481
- }
482
- return false;
483
- }
484
- },'json'
485
- ).fail(function(){
486
- loading[obj] = 0;
487
- // hide spinner
488
- $('.ctc-status-icon').removeClass('spinner');
489
- // show check mark
490
- $('.ctc-status-icon').addClass('failure');
491
- });
492
- return false;
493
- },
494
- ctc_save = function(obj) {
495
- var postdata = {},
496
- $selector, $query, $imports, $rule,
497
- id = $(obj).attr('id');
498
- if (ctc_is_empty(saveEvents[id])) {
499
- saveEvents[id] = 0;
500
- }
501
- saveEvents[id]++;
502
- // disable the button until ajax returns
503
- $(obj).prop('disabled', true);
504
- // clear previous success/fail icons
505
- $('.ctc-status-icon').remove();
506
- // show spinner
507
- $(obj).parent('.ctc-textarea-button-cell, .ctc-button-cell').append('<span class="ctc-status-icon spinner"></span>');
508
- $('.spinner').show();
509
- if (($selector = $('#ctc_new_selectors')) && 'ctc_save_new_selectors' == $(obj).attr('id')) {
510
- postdata['ctc_new_selectors'] = $selector.val();
511
- if ($query = $('#ctc_sel_ovrd_query_selected')) {
512
- postdata['ctc_sel_ovrd_query'] = $query.text();
513
- }
514
- } else if (($imports = $('#ctc_child_imports')) && 'ctc_save_imports' == $(obj).attr('id')) {
515
- postdata['ctc_child_imports'] = $imports.val();
516
- } else {
517
- // coalesce inputs
518
- postdata = ctc_coalesce_inputs(obj);
519
- }
520
- // add wp ajax action to array
521
- postdata['action'] = 'ctc_update';
522
- postdata['_wpnonce'] = $('#_wpnonce').val();
523
- // ajax post input data
524
- $.post(
525
- // get ajax url from localized object
526
- ctcAjax.ajaxurl,
527
- //Data
528
- postdata,
529
- //on success function
530
- function(response){
531
- // release button
532
- $(obj).prop('disabled', false);
533
- // hide spinner
534
- $('.ctc-status-icon').removeClass('spinner');
535
- // show check mark
536
- if (ctc_is_empty(response)) {
537
- $('.ctc-status-icon').addClass('failure');
538
- } else {
539
- $('.ctc-status-icon').addClass('success');
540
- $('#ctc_new_selectors').val('');
541
- // update data objects
542
- ctc_update_cache(response);
543
- ctc_setup_menus();
544
- }
545
- return false;
546
- }, 'json'
547
- ).fail(function(){
548
- // release button
549
- $(obj).prop('disabled', false);
550
- // hide spinner
551
- $('.ctc-status-icon').removeClass('spinner');
552
- // show check mark
553
- $('.ctc-status-icon').addClass('failure');
554
- });
555
- return false;
556
- },
557
- /* stub for future ajax loader
558
- ctc_load_css = function(e) {
559
-
560
-
561
- var postdata = $(this).serializeArray();
562
- // disable the button until ajax returns
563
- $('#ctc_load_styles').prop('disabled', true);
564
- // clear previous success/fail icons
565
- $('.ctc-status-icon').remove();
566
- // show spinner
567
- $('#ctc_load_styles').parent('.ctc-input-cell').append('<span class="ctc-status-icon spinner"></span>');
568
- $('.spinner').show();
569
- return true;
570
-
571
- // ajax post input data
572
- $.post(
573
- // get ajax url from localized object
574
- ctcAjax.ajaxurl,
575
- //Data
576
- postdata,
577
- //on success function
578
- function(response){
579
- // release button
580
- $('#ctc_load_styles').prop('disabled', false);
581
- // hide spinner
582
- $('.ctc-status-icon').removeClass('spinner');
583
- // show check mark
584
- if (ctc_is_empty(response.updated)) {
585
- $('.ctc-status-icon').addClass('failure');
586
- // update notice
587
- if (false === ctc_is_empty(response.error)) {
588
- ctc_set_notice({'error': response.error});
589
- }
590
- } else {
591
- $('.ctc-status-icon').addClass('success');
592
- // update notice
593
- if (false === ctc_is_empty(response.updated)) {
594
- ctc_set_notice({'updated': response.updated});
595
- }
596
- if (false === ctc_is_empty(response.themes)) {
597
- ctcAjax.themes = response.themes;
598
- }
599
- if (false === ctc_is_empty(response.menu)) {
600
- $('#ctc_theme_child').html(response.menu);
601
- }
602
- $('.nav-tab, .ctc-option-panel, .ctc-radio, .ctc-select, label').fadeIn('fast');
603
- }
604
- return false;
605
- },
606
- 'json'
607
- ).fail(function(){
608
- // release button
609
- $('#ctc_load_styles').prop('disabled', false);
610
- // hide spinner
611
- $('.ctc-status-icon').removeClass('spinner');
612
- // show check mark
613
- $('.ctc-status-icon').addClass('failure');
614
- });
615
- return false;
616
- },*/
617
- ctc_decode_value = function(rule, value) {
618
- value = ('undefined' == typeof value ? '' : value);
619
- var obj = { 'orig': value };
620
- if (rule.toString().match(/^border(\-(top|right|bottom|left))?$/)) {
621
- var params = value.toString().split(/ +/);
622
- obj['names'] = [
623
- '_border_width',
624
- '_border_style',
625
- '_border_color',
626
- ];
627
- obj['values'] = [
628
- ('undefined' == typeof params[0] ? '' : params[0]),
629
- ('undefined' == typeof params[1] ? '' : params[1]),
630
- ('undefined' == typeof params[2] ? '' : params[2])
631
- ];
632
- } else if (rule.toString().match(/^background\-image/)) {
633
- obj['names'] = [
634
- '_background_url',
635
- '_background_origin',
636
- '_background_color1',
637
- '_background_color2'
638
- ];
639
- obj['values'] = ['','','',''];
640
- if (false === (ctc_is_empty(value)) && !(value.toString().match(/url/))) {
641
- var params = value.toString().split(/:/);
642
- obj['values'][1] = ('undefined' == typeof params[0] ? '' : params[0]);
643
- obj['values'][2] = ('undefined' == typeof params[1] ? '' : params[1]);
644
- obj['values'][3] = ('undefined' == typeof params[3] ? '' : params[3]);
645
- obj['orig'] = [ obj['values'][1], obj['values'][2], obj['values'][3] ].join(' '); // display "origin color1 color2"
646
- } else {
647
- obj['values'][0] = value;
648
- }
649
- } else {
650
- obj['names'] = [''];
651
- obj['values'] = [ value ];
652
- }
653
- return obj;
654
- },
655
-
656
- ctc_set_query = function(value) {
657
- currentQuery = value;
658
- $('#ctc_sel_ovrd_query').val('');
659
- $('#ctc_sel_ovrd_query_selected').text(value);
660
- $('#ctc_sel_ovrd_selector').val('');
661
- $('#ctc_sel_ovrd_selector_selected').html('&nbsp;');
662
- $('#ctc_sel_ovrd_rule_inputs').html('');
663
- ctc_setup_selector_menu(value);
664
- ctc_coalesce_inputs('#ctc_child_all_0_swatch');
665
- $('#ctc_new_selector_row').show();
666
- },
667
-
668
- ctc_set_selector = function(value,label) {
669
- $('#ctc_sel_ovrd_selector').val('');
670
- $('#ctc_sel_ovrd_selector_selected').text(label);
671
- $('#ctc_sel_ovrd_qsid').val(value);
672
- currentSel = value;
673
- if (1 != loading.sel_val) loading.sel_val = 0;
674
- ctc_render_selector_inputs(value);
675
- $('#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs').show();
676
- },
677
-
678
- ctc_set_rule = function(value,label) {
679
- $('#ctc_rule_menu').val('');
680
- $('#ctc_rule_menu_selected').text(label);
681
- if (1 != loading.rule_val) loading.rule_val = 0;
682
- ctc_render_rule_value_inputs(value);
683
- $('#ctc_rule_value_inputs,#ctc_input_row_rule_header').show();
684
- },
685
- ctc_setup_query_menu = function() {
686
- ctc_queries = ctc_load_queries();
687
- $('#ctc_sel_ovrd_query').autocomplete({
688
- source: ctc_queries,
689
- minLength: 0,
690
- selectFirst: true,
691
- autoFocus: true,
692
- select: function(e, ui) {
693
- ctc_set_query(ui.item.value);
694
- return false;
695
- },
696
- focus: function(e) { e.preventDefault(); }
697
- });
698
- },
699
- ctc_setup_selector_menu = function(query) {
700
- ctc_selectors = ctc_load_selectors(query);
701
- $('#ctc_sel_ovrd_selector').autocomplete({
702
- source: ctc_selectors,
703
- selectFirst: true,
704
- autoFocus: true,
705
- select: function(e, ui) {
706
- ctc_set_selector(ui.item.value, ui.item.label);
707
- return false;
708
- },
709
- focus: function(e) { e.preventDefault(); }
710
- });
711
- },
712
- ctc_setup_rule_menu = function() {
713
- ctc_rules = ctc_load_rules();
714
- $('#ctc_rule_menu').autocomplete({
715
- source: ctc_rules,
716
- //minLength: 0,
717
- selectFirst: true,
718
- autoFocus: true,
719
- select: function(e, ui) {
720
- ctc_set_rule(ui.item.value, ui.item.label);
721
- return false;
722
- },
723
- focus: function(e) { e.preventDefault(); }
724
- });
725
- },
726
- ctc_filtered_rules = function(request, response) {
727
- var arr = [],
728
- noval = (ctc_is_empty(ctcAjax.sel_val[currentSel])) || (ctc_is_empty(ctcAjax.sel_val[currentSel].value));
729
- if (ctc_is_empty(ctc_rules)) {
730
- ctc_rules = ctc_load_rules();
731
- }
732
- $.each(ctc_rules, function(key, val){
733
- var skip = false,
734
- matcher = new RegExp( $.ui.autocomplete.escapeRegex( request.term ), "i" );
735
- if (matcher.test( val.label )) {
736
- if (false === noval) {
737
- // skip rule if in current selector array
738
- $.each(ctcAjax.sel_val[currentSel].value, function(rule, value) {
739
- if (val.label == rule.replace(/\d+/g, from_ascii)) {
740
- skip = true;
741
- return false;
742
- }
743
- });
744
- if (skip) {
745
- return;
746
- }
747
- }
748
- // add rule
749
- arr.push(val);
750
- }
751
- });
752
- response(arr);
753
- },
754
- ctc_setup_new_rule_menu = function() {
755
- $('#ctc_new_rule_menu').autocomplete({
756
- source: ctc_filtered_rules,
757
- //minLength: 0,
758
- selectFirst: true,
759
- autoFocus: true,
760
- select: function(e, ui) {
761
- e.preventDefault();
762
- var n = $(ctc_render_child_rule_input(currentSel, ui.item.label, 'ovrd'));
763
- $('#ctc_sel_ovrd_rule_inputs').append(n);
764
- $('#ctc_new_rule_menu').val('');
765
- if (ctc_is_empty(ctcAjax.sel_val[currentSel].value)) {
766
- ctcAjax.sel_val[currentSel]['value'] = {};
767
- }
768
- ctcAjax.sel_val[currentSel].value[ui.item.label] = {'child': ''};
769
- n.find('input[type="text"]').each(function(ndx, el){
770
- if ($(el).hasClass('color-picker'))
771
- ctc_setup_iris(el);
772
- $(el).focus();
773
- });
774
- return false;
775
- },
776
- focus: function(e) { e.preventDefault(); }
777
- });
778
- },
779
- ctc_setup_menus = function() {
780
- ctc_setup_query_menu();
781
- ctc_setup_selector_menu(currentQuery);
782
- ctc_setup_rule_menu();
783
- ctc_setup_new_rule_menu();
784
- },
785
- ctc_theme_exists = function(testslug, testtype) {
786
- var exists = false;
787
- $.each(ctcAjax.themes, function(type, theme){
788
- $.each(theme, function(slug, data){
789
- if (slug == testslug && ('parnt' == type || 'new' == testtype)) {
790
- exists = true;
791
- return false;
792
- }
793
- });
794
- if (exists) return false;
795
- });
796
- return exists;
797
- },
798
-
799
- ctc_set_notice = function(noticearr) {
800
- var errorHtml = '';
801
- if (false === ctc_is_empty(noticearr)) {
802
- $.each(noticearr, function(type, list){
803
- errorHtml += '<div class="' + type + '"><ul>' + lf;
804
- $(list).each(function(ndx, el){
805
- errorHtml += '<li>' + el.toString() + '</li>' + lf;
806
- });
807
- errorHtml += '</ul></div>';
808
- });
809
- }
810
- $('#ctc_error_notice').html(errorHtml);
811
- },
812
- ctc_validate = function() {
813
- var regex = /[^\w\-]/,
814
- newslug = $('#ctc_child_template').val().toString().replace(regex).toLowerCase(),
815
- slug = $('#ctc_theme_child').val().toString().replace(regex).toLowerCase(),
816
- type = $('input[name=ctc_child_type]:checked').val(),
817
- errors = [];
818
- if ('new' == type) slug = newslug;
819
- if (ctc_theme_exists(slug, type)) {
820
- errors.push(ctcAjax.theme_exists_txt.toString().replace(/%s/, slug));
821
- }
822
- if ('' === slug) {
823
- errors.push(ctcAjax.inval_theme_txt);
824
- }
825
- if ('' === $('#ctc_child_name').val()) {
826
- errors.push(ctcAjax.inval_name_txt);
827
- }
828
- if (errors.length) {
829
- ctc_set_notice({'error': errors});
830
- return false;
831
- }
832
- return true;
833
- },
834
- ctc_set_theme_menu = function(e) {
835
- var slug = $('#ctc_theme_child').val();
836
- if (false === ctc_is_empty(ctcAjax.themes.child[slug])) {
837
- $('#ctc_child_name').val(ctcAjax.themes.child[slug].Name);
838
- $('#ctc_child_author').val(ctcAjax.themes.child[slug].Author);
839
- $('#ctc_child_version').val(ctcAjax.themes.child[slug].Version);
840
- }
841
- },
842
- fade_update_notice = function() {
843
- $('.updated, .error').slideUp('slow', function(){ $('.updated').remove(); });
844
- },
845
- ctc_focus_panel = function(id) {
846
- var panelid = id + '_panel';
847
- $('.nav-tab').removeClass('nav-tab-active');
848
- $('.ctc-option-panel').removeClass('ctc-option-panel-active');
849
- $('.ctc-selector-container').hide();
850
- $(id).addClass('nav-tab-active');
851
- $('.ctc-option-panel-container').scrollTop(0);
852
- $(panelid).addClass('ctc-option-panel-active');
853
- },
854
- ctc_selector_edit = function(obj) {
855
- var qsid = $(obj).attr('id').match(/_(\d+)$/)[1],
856
- q = ctcAjax.sel_val[qsid].query,
857
- s = ctcAjax.sel_val[qsid].selector,
858
- id = '#query_selector_options';
859
- ctc_set_query(q);
860
- ctc_set_selector(qsid, s);
861
- ctc_focus_panel(id);
862
-
863
- },
864
- // initialize vars
865
- // ajax semaphores: 0 = reload, 1 = loading, 2 = loaded
866
- loading = {
867
- 'rule': 2,
868
- 'sel_ndx': 2,
869
- 'val_qry': 0,
870
- 'rule_val': 0,
871
- 'sel_val': 0
872
- },
873
-
874
- ctc_selectors = [],
875
- ctc_queries = [],
876
- ctc_rules = [];
877
- // -- end var definitions
878
-
879
- // initialize Iris color picker
880
- $('.color-picker').each(function() {
881
- ctc_setup_iris(this);
882
- });
883
- // bind event handlers
884
- $('.ctc-option-panel-container').on('focus', '.color-picker', function(){
885
- ctc_set_notice('')
886
- $(this).iris('toggle');
887
- $('.iris-picker').css({'position':'absolute', 'z-index':10});
888
- });
889
- $('.ctc-option-panel-container').on('focus', 'input', function() {
890
- ctc_set_notice('')
891
- $('.color-picker').not(this).iris('hide');
892
- });
893
- $('.ctc-option-panel-container').on('change', '.ctc-child-value, input[type=checkbox]', function() {
894
- ctc_coalesce_inputs(this);
895
- });
896
- $('.ctc-option-panel-container').on('click', '.ctc-selector-handle', function(e) {
897
- e.preventDefault();
898
- ctc_set_notice('')
899
- var id = $(this).attr('id').toString().replace('_close', ''),
900
- valid = id.toString().match(/_(\d+)$/)[1];
901
- if ($('#' + id + '_container').is(':hidden')) {
902
- if (1 != loading.val_qry) loading.val_qry = 0;
903
- ctc_render_selector_value_inputs(valid);
904
- }
905
- $('#' + id + '_container').fadeToggle('fast');
906
- $('.ctc-selector-container').not('#' + id + '_container').fadeOut('fast');
907
- });
908
- $('.nav-tab').on('click', function(e){
909
- e.preventDefault();
910
- // clear the notice box
911
- ctc_set_notice('')
912
- var id = '#' + $(this).attr('id');
913
- ctc_focus_panel(id);
914
- });
915
- $('#view_child_options,#view_parnt_options').on('click', function(e){
916
- ctc_set_notice('')
917
- var stamp = new Date().getTime(),
918
- theme = $(this).attr('id').toString().match(/(child|parnt)/)[1],
919
- css_uri = ctcAjax.theme_uri + '/' + ctcAjax[theme] + '/style.css?' + stamp;
920
- $.get(
921
- css_uri,
922
- function(response){
923
- $('#view_'+theme+'_options_panel').text(response);
924
- }
925
- ).fail(function(){
926
- $('#view_'+theme+'_options_panel').text(ctcAjax.css_fail_txt);
927
- });
928
- });
929
- $('#ctc_load_form').on('submit', function() {
930
- return (ctc_validate() && confirm(ctcAjax.load_txt) ) ;
931
- });
932
- $('#parent_child_options_panel').on('change', '#ctc_theme_child', ctc_set_theme_menu );
933
- $(document).on('click', '.ctc-save-input', function(e) {
934
- ctc_save(this);
935
- });
936
- $(document).on('click', '.ctc-selector-edit', function(e) {
937
- ctc_selector_edit(this);
938
- });
939
- // initialize menus
940
- ctc_setup_menus();
941
- ctc_set_query(currentQuery);
942
- $('input[type=submit],input[type=button]').prop('disabled', false);
943
- setTimeout(fade_update_notice, 6000);
944
- });
945
-
946
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
chld-thm-cfg.min.js DELETED
@@ -1,11 +0,0 @@
1
- /*!
2
- * Script: chld-thm-cfg.js
3
- * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
- * Description: Handles jQuery, AJAX and other UI
5
- * Version: 1.2.1
6
- * Author: Lilaea Media
7
- * Author URI: http://www.lilaeamedia.com/
8
- * License: GPLv2
9
- * Copyright (C) 2013 Lilaea Media
10
- */
11
- ;jQuery(document).ready(function(g){var p="\n",m="base",a,o={},q=function(r){g(r).iris({change:function(){k(r)}})},l=function(t){var r=parseInt(t),s=String.fromCharCode(r);return s},i=function(s){var r=s.charCodeAt(0);return r},k=function(x){var t=/^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+))(_\w+)?$/,y=g(x).parents(".ctc-selector-row, .ctc-parent-row").first(),w=y.find(".ctc-swatch").first(),v={parent:{},child:{}},u={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},s={child:false,parent:false},r={};y.find(".ctc-parent-value, .ctc-child-value").each(function(){var G=g(this).attr("id"),z=G.toString().match(t),H=z[2],A=z[3],J=("undefined"==typeof z[4]?"":z[4]),F=z[5],E=("undefined"==typeof z[6]?"":z[6]),I=("parent"==A?g(this).text():g(this).val()),B="ctc_"+H+"_child_"+J+"_i_"+F,D,C;if("child"==A){r[G]=I;r[B]=(g("#"+B).is(":checked"))?1:0}if(false===b(E)){switch(E){case"_border_width":v[A][J+"-width"]=I;break;case"_border_style":v[A][J+"-style"]=I;break;case"_border_color":v[A][J+"-color"]=I;break;case"_background_url":v[A]["background-image"]=d(A,I);break;case"_background_color":v[A]["background-color"]=x.value;break;case"_background_color1":u[A].start=I;s[A]=true;break;case"_background_color2":u[A].end=I;s[A]=true;break;case"_background_origin":u[A].origin=I;s[A]=true;break}}else{if(D=J.toString().match(/^border(\-(top|right|bottom|left))?$/)&&!I.match(/none/)){C=I.toString().split(/ +/);v[A][J+"-width"]="undefined"==typeof C[0]?"":C[0];v[A][J+"-style"]="undefined"==typeof C[1]?"":C[1];v[A][J+"-color"]="undefined"==typeof C[2]?"":C[2]}else{if("background-image"==J){if(I.toString().match(/url\(/)){v[A]["background-image"]=d(A,I)}else{C=I.toString().split(/ +/);if(C.length>2){u[A].origin="undefined"==typeof C[0]?"top":C[0];u[A].start="undefined"==typeof C[1]?"transparent":C[1];u[A].end="undefined"==typeof C[2]?"transparent":C[2];s[A]=true}else{v[A]["background-image"]=I}}}else{v[A][J]=I}}}});if("undefined"!=typeof w){g(w).removeAttr("style");if(s.parent){g(w).ctcgrad(u.parent.origin,[u.parent.start,u.parent.end])}g(w).css(v.parent);if(!(w.attr("id").toString().match(/parent/))){if(s.child){g(w).ctcgrad(u.child.origin,[u.child.start,u.child.end])}g(w).css(v.child)}}return r},c=function(t){var s,u,r;g(t).each(function(){switch(this.obj){case"imports":ctcAjax.imports=this.data;break;case"rule_val":ctcAjax.rule_val[this.key]=this.data;currRuleId=this.key;break;case"val_qry":ctcAjax.val_qry[this.key]=this.data;break;case"rule":ctcAjax.rule=this.data;break;case"sel_ndx":if(b(this.key)){ctcAjax.sel_ndx=this.data}else{if("qsid"==this.key){if(b(ctcAjax.sel_ndx[this.data.query])){ctcAjax.sel_ndx[this.data.query]={}}ctcAjax.sel_ndx[this.data.query][this.data.selector]=this.data.qsid}else{ctcAjax.sel_ndx[this.key]=this.data;s=this.key}}break;case"sel_val":ctcAjax.sel_val[this.key]=this.data;u=this.key;break}})},d=function(v,s){var u=s.toString().match(/url\([" ]*(.+?)[" ]*\)/),t=b(u)?null:u[1],r=ctcAjax.theme_uri+"/"+("parent"==v?ctcAjax.parnt:ctcAjax.child)+"/",w;if(!t){return false}else{if(t.toString().match(/^(https?:|\/)/)){w=s}else{w="url("+r+t+")"}}return w},b=function(s){if("undefined"==typeof s||false===s||null===s||""===s){return true}if(true===s||"string"===typeof s||"number"===typeof s){return false}if("object"===typeof s){for(var r in s){if(s.hasOwnProperty(r)){return false}}return true}return false},j=function(){var r=[];if(1===loading.sel_ndx){return r}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",null,ctc_setup_query_menu);return r}if(false===b(ctcAjax.sel_ndx)){g.each(ctcAjax.sel_ndx,function(s,t){var u={label:s,value:s};r.push(u)})}return r},f=function(s){var r=[];if(1===loading.sel_ndx){return r}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",s,ctc_setup_selector_menu);return r}if(false===b(ctcAjax.sel_ndx[s])){g.each(ctcAjax.sel_ndx[s],function(t,u){var v={label:t,value:u};r.push(v)})}return r},n=function(){var r=[];if(1===loading.rule){return r}if(0===loading.rule){loading.rule=1;ctc_query_css("rule",null,ctc_setup_rule_menu);return r}if(false===b(ctcAjax.rule)){g.each(ctcAjax.rule,function(s,t){var u={label:t.replace(/\d+/g,l),value:s};r.push(u)})}return r.sort(function(t,s){if(t.label>s.label){return 1}if(t.label<s.label){return -1}return 0})},h=function(v,x,A){var t="",y=(b(ctcAjax.sel_val[v])||b(ctcAjax.sel_val[v].value)||b(ctcAjax.sel_val[v].value[x])?"":ctcAjax.sel_val[v].value[x]),s=ctc_decode_value(x,("undefined"==typeof y?"":y.parnt)),w=(false===b(y.i_parnt)&&y.i_parnt)?ctcAjax.important_label:"",u=ctc_decode_value(x,("undefined"==typeof y?"":y.child)),r=(false===b(y.i_child)&&y.i_child)?1:0,z="ctc_"+A+"_child_"+x+"_i_"+v;if(false===b(ctcAjax.sel_val[v])){t+='<div class="ctc-'+("ovrd"==A?"input":"selector")+'-row clearfix">'+p;t+='<div class="ctc-input-cell">'+("ovrd"==A?x.replace(/\d+/g,l):ctcAjax.sel_val[v].selector+'<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_'+v+'" >'+ctcAjax.edit_txt+"</a> "+(b(s.orig)?ctcAjax.child_only_txt:""))+"</div>"+p;if("ovrd"==A){t+='<div class="ctc-parent-value ctc-input-cell" id="ctc_'+A+"_parent_"+x+"_"+v+'">'+(b(s.orig)?"[no value]":s.orig+w)+"</div>"+p}t+='<div class="ctc-input-cell">'+p;if(false===b(s.names)){g.each(s.names,function(B,C){C=(b(C)?"":C);t+='<div class="ctc-child-input-cell">'+p;var E="ctc_"+A+"_child_"+x+"_"+v+C,D;if(false===(D=u.values.shift())){D=""}t+=(b(C)?"":ctcAjax.field_labels[C]+":<br/>")+'<input type="text" id="'+E+'" name="'+E+'" class="ctc-child-value'+((C+x).toString().match(/color/)?" color-picker":"")+((C).toString().match(/url/)?" ctc-input-wide":"")+'" value="'+D+'" />'+p;t+="</div>"+p});t+='<label for="'+z+'"><input type="checkbox" id="'+z+'" name="'+z+'" value="1" '+(1===r?"checked":"")+" />"+ctcAjax.important_label+"</label>"+p}t+="</div>"+p;t+=("ovrd"==A?"":'<div class="ctc-swatch ctc-specific" id="ctc_child_'+x+"_"+v+'_swatch">'+ctcAjax.swatch_txt+"</div>"+p+'<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+x+"_"+v+'_cell">'+p+'<input type="button" class="button ctc-save-input" id="ctc_save_'+x+"_"+v+'" name="ctc_save_'+x+"_"+v+'" value="Save" /></div>'+p);t+="</div><!-- end input row -->"+p}return t},e=function(r){if(1===loading.sel_val){return false}if(0==loading.sel_val){loading.sel_val=1;ctc_query_css("sel_val",r,e);return false}var u,s,t;if(b(ctcAjax.sel_val[r])){g("#ctc_sel_ovrd_rule_inputs").html("")}else{if(b(ctcAjax.sel_val[r].seq)){g("#ctc_child_load_order_container").html("")}else{u="ctc_ovrd_child_seq_"+r;t=parseInt(ctcAjax.sel_val[r].seq);s='<input type="text" id="'+u+'" name="'+u+'" class="ctc-child-value" value="'+t+'" />';g("#ctc_child_load_order_container").html(s)}if(b(ctcAjax.sel_val[r].value)){g("#ctc_sel_ovrd_rule_inputs").html("")}else{s="";g.each(ctcAjax.sel_val[r].value,function(w,v){s+=h(r,w,"ovrd")});g("#ctc_sel_ovrd_rule_inputs").html(s).find(".color-picker").each(function(){q(this)});k("#ctc_child_all_0_swatch")}}};ctc_render_rule_value_inputs=function(s){if(1===loading.rule_val){return false}if(0==loading.rule_val){loading.rule_val=1;ctc_query_css("rule_val",s,ctc_render_rule_value_inputs);return false}var t=ctcAjax.rule[s],r='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+t+'">'+p;if(false===b(ctcAjax.rule_val[s])){g.each(ctcAjax.rule_val[s],function(v,w){var u=ctc_decode_value(t,w);r+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+t+"_"+v+'">'+p;r+='<div class="ctc-input-cell ctc-parent-value" id="ctc_'+v+"_parent_"+t+"_"+v+'">'+u.orig+"</div>"+p;r+='<div class="ctc-input-cell">'+p;r+='<div class="ctc-swatch ctc-specific" id="ctc_'+v+"_parent_"+t+"_"+v+'_swatch">'+ctcAjax.swatch_txt+"</div></div>"+p;r+='<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+t+"_"+v+'">'+ctcAjax.selector_txt+"</a></div>"+p;r+='<div id="ctc_selector_'+t+"_"+v+'_container" class="ctc-selector-container clearfix">'+p;r+='<a href="#" id="ctc_selector_'+t+"_"+v+'_close" class="ctc-selector-handle" style="float:right">'+ctcAjax.close_txt+'</a><div id="ctc_status_val_qry_'+v+'"></div>'+p;r+='<div id="ctc_selector_'+t+"_"+v+'_rows"></div>'+p;r+="</div></div>"+p});r+="</div>"+p}g("#ctc_rule_value_inputs").html(r).find(".ctc-swatch").each(function(){k(this)})},ctc_render_selector_value_inputs=function(u){if(1==loading.val_qry){return false}var w,s,v=g("#ctc_rule_menu_selected").text().replace(/[^\w\-]/g,i),r,t="";if(0===loading.val_qry){loading.val_qry=1;w={rule:v};ctc_query_css("val_qry",u,ctc_render_selector_value_inputs,w);return false}if(false===b(ctcAjax.val_qry[u])){g.each(ctcAjax.val_qry[u],function(y,x){page_rule=y;g.each(x,function(A,z){t+='<h4 class="ctc-query-heading">'+A+"</h4>"+p;if(false===b(z)){g.each(z,function(B,C){ctcAjax.sel_val[B]=C;t+=h(B,y,u)})}})})}r="#ctc_selector_"+v+"_"+u+"_rows";g(r).html(t).find(".color-picker").each(function(){q(this)});g(r).find(".ctc-swatch").each(function(){k(this)})},ctc_query_css=function(t,s,w,u){var r={ctc_query_obj:t,ctc_query_key:s},v="#ctc_status_"+t+("val_qry"==t?"_"+s:"");if("object"===typeof u){g.each(u,function(x,y){r["ctc_query_"+x]=y})}g(".ctc-status-icon").remove();g(v).append('<span class="ctc-status-icon spinner"></span>');g(".spinner").show();r.action="ctc_query";r._wpnonce=g("#_wpnonce").val();g.post(ctcAjax.ajaxurl,r,function(x){loading[t]=2;g(".ctc-status-icon").removeClass("spinner");if(b(x)){g(".ctc-status-icon").addClass("failure")}else{g(".ctc-status-icon").addClass("success");c(x);if("function"===typeof w){w(s)}return false}},"json").fail(function(){loading[t]=0;g(".ctc-status-icon").removeClass("spinner");g(".ctc-status-icon").addClass("failure")});return false},ctc_save=function(v){var u={},w,t,r,s,x=g(v).attr("id");if(b(o[x])){o[x]=0}o[x]++;g(v).prop("disabled",true);g(".ctc-status-icon").remove();g(v).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner"></span>');g(".spinner").show();if((w=g("#ctc_new_selectors"))&&"ctc_save_new_selectors"==g(v).attr("id")){u.ctc_new_selectors=w.val();if(t=g("#ctc_sel_ovrd_query_selected")){u.ctc_sel_ovrd_query=t.text()}}else{if((r=g("#ctc_child_imports"))&&"ctc_save_imports"==g(v).attr("id")){u.ctc_child_imports=r.val()}else{u=k(v)}}u.action="ctc_update";u._wpnonce=g("#_wpnonce").val();g.post(ctcAjax.ajaxurl,u,function(y){g(v).prop("disabled",false);g(".ctc-status-icon").removeClass("spinner");if(b(y)){g(".ctc-status-icon").addClass("failure")}else{g(".ctc-status-icon").addClass("success");g("#ctc_new_selectors").val("");c(y);ctc_setup_menus()}return false},"json").fail(function(){g(v).prop("disabled",false);g(".ctc-status-icon").removeClass("spinner");g(".ctc-status-icon").addClass("failure")});return false},ctc_decode_value=function(t,r){r=("undefined"==typeof r?"":r);var s={orig:r};if(t.toString().match(/^border(\-(top|right|bottom|left))?$/)){var u=r.toString().split(/ +/);s.names=["_border_width","_border_style","_border_color"];s.values=[("undefined"==typeof u[0]?"":u[0]),("undefined"==typeof u[1]?"":u[1]),("undefined"==typeof u[2]?"":u[2])]}else{if(t.toString().match(/^background\-image/)){s.names=["_background_url","_background_origin","_background_color1","_background_color2"];s.values=["","","",""];if(false===(b(r))&&!(r.toString().match(/url/))){var u=r.toString().split(/:/);s.values[1]=("undefined"==typeof u[0]?"":u[0]);s.values[2]=("undefined"==typeof u[1]?"":u[1]);s.values[3]=("undefined"==typeof u[3]?"":u[3]);s.orig=[s.values[1],s.values[2],s.values[3]].join(" ")}else{s.values[0]=r}}else{s.names=[""];s.values=[r]}}return s},ctc_set_query=function(r){m=r;g("#ctc_sel_ovrd_query").val("");g("#ctc_sel_ovrd_query_selected").text(r);g("#ctc_sel_ovrd_selector").val("");g("#ctc_sel_ovrd_selector_selected").html("&nbsp;");g("#ctc_sel_ovrd_rule_inputs").html("");ctc_setup_selector_menu(r);k("#ctc_child_all_0_swatch");g("#ctc_new_selector_row").show()},ctc_set_selector=function(s,r){g("#ctc_sel_ovrd_selector").val("");g("#ctc_sel_ovrd_selector_selected").text(r);g("#ctc_sel_ovrd_qsid").val(s);a=s;if(1!=loading.sel_val){loading.sel_val=0}e(s);g("#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").show()},ctc_set_rule=function(s,r){g("#ctc_rule_menu").val("");g("#ctc_rule_menu_selected").text(r);if(1!=loading.rule_val){loading.rule_val=0}ctc_render_rule_value_inputs(s);g("#ctc_rule_value_inputs,#ctc_input_row_rule_header").show()},ctc_setup_query_menu=function(){ctc_queries=j();g("#ctc_sel_ovrd_query").autocomplete({source:ctc_queries,minLength:0,selectFirst:true,autoFocus:true,select:function(s,r){ctc_set_query(r.item.value);return false},focus:function(r){r.preventDefault()}})},ctc_setup_selector_menu=function(r){ctc_selectors=f(r);g("#ctc_sel_ovrd_selector").autocomplete({source:ctc_selectors,selectFirst:true,autoFocus:true,select:function(t,s){ctc_set_selector(s.item.value,s.item.label);return false},focus:function(s){s.preventDefault()}})},ctc_setup_rule_menu=function(){ctc_rules=n();g("#ctc_rule_menu").autocomplete({source:ctc_rules,selectFirst:true,autoFocus:true,select:function(s,r){ctc_set_rule(r.item.value,r.item.label);return false},focus:function(r){r.preventDefault()}})},ctc_filtered_rules=function(u,s){var r=[],t=(b(ctcAjax.sel_val[a]))||(b(ctcAjax.sel_val[a].value));if(b(ctc_rules)){ctc_rules=n()}g.each(ctc_rules,function(v,y){var w=false,x=new RegExp(g.ui.autocomplete.escapeRegex(u.term),"i");if(x.test(y.label)){if(false===t){g.each(ctcAjax.sel_val[a].value,function(A,z){if(y.label==A.replace(/\d+/g,l)){w=true;return false}});if(w){return}}r.push(y)}});s(r)},ctc_setup_new_rule_menu=function(){g("#ctc_new_rule_menu").autocomplete({source:ctc_filtered_rules,selectFirst:true,autoFocus:true,select:function(s,r){s.preventDefault();var t=g(h(a,r.item.label,"ovrd"));g("#ctc_sel_ovrd_rule_inputs").append(t);g("#ctc_new_rule_menu").val("");if(b(ctcAjax.sel_val[a].value)){ctcAjax.sel_val[a]["value"]={}}ctcAjax.sel_val[a].value[r.item.label]={child:""};t.find('input[type="text"]').each(function(u,v){if(g(v).hasClass("color-picker")){q(v)}g(v).focus()});return false},focus:function(r){r.preventDefault()}})},ctc_setup_menus=function(){ctc_setup_query_menu();ctc_setup_selector_menu(m);ctc_setup_rule_menu();ctc_setup_new_rule_menu()},ctc_theme_exists=function(r,s){var t=false;g.each(ctcAjax.themes,function(u,v){g.each(v,function(w,x){if(w==r&&("parnt"==u||"new"==s)){t=true;return false}});if(t){return false}});return t},ctc_set_notice=function(r){var s="";if(false===b(r)){g.each(r,function(t,u){s+='<div class="'+t+'"><ul>'+p;g(u).each(function(v,w){s+="<li>"+w.toString()+"</li>"+p});s+="</ul></div>"})}g("#ctc_error_notice").html(s)},ctc_validate=function(){var u=/[^\w\-]/,s=g("#ctc_child_template").val().toString().replace(u).toLowerCase(),r=g("#ctc_theme_child").val().toString().replace(u).toLowerCase(),t=g("input[name=ctc_child_type]:checked").val(),v=[];if("new"==t){r=s}if(ctc_theme_exists(r,t)){v.push(ctcAjax.theme_exists_txt.toString().replace(/%s/,r))}if(""===r){v.push(ctcAjax.inval_theme_txt)}if(""===g("#ctc_child_name").val()){v.push(ctcAjax.inval_name_txt)}if(v.length){ctc_set_notice({error:v});return false}return true},ctc_set_theme_menu=function(s){var r=g("#ctc_theme_child").val();if(false===b(ctcAjax.themes.child[r])){g("#ctc_child_name").val(ctcAjax.themes.child[r].Name);g("#ctc_child_author").val(ctcAjax.themes.child[r].Author);g("#ctc_child_version").val(ctcAjax.themes.child[r].Version)}},fade_update_notice=function(){g(".updated, .error").slideUp("slow",function(){g(".updated").remove()})},ctc_focus_panel=function(s){var r=s+"_panel";g(".nav-tab").removeClass("nav-tab-active");g(".ctc-option-panel").removeClass("ctc-option-panel-active");g(".ctc-selector-container").hide();g(s).addClass("nav-tab-active");g(".ctc-option-panel-container").scrollTop(0);g(r).addClass("ctc-option-panel-active")},ctc_selector_edit=function(v){var r=g(v).attr("id").match(/_(\d+)$/)[1],u=ctcAjax.sel_val[r].query,t=ctcAjax.sel_val[r].selector,w="#query_selector_options";ctc_set_query(u);ctc_set_selector(r,t);ctc_focus_panel(w)},loading={rule:2,sel_ndx:2,val_qry:0,rule_val:0,sel_val:0},ctc_selectors=[],ctc_queries=[],ctc_rules=[];g(".color-picker").each(function(){q(this)});g(".ctc-option-panel-container").on("focus",".color-picker",function(){ctc_set_notice("");g(this).iris("toggle");g(".iris-picker").css({position:"absolute","z-index":10})});g(".ctc-option-panel-container").on("focus","input",function(){ctc_set_notice("");g(".color-picker").not(this).iris("hide")});g(".ctc-option-panel-container").on("change",".ctc-child-value, input[type=checkbox]",function(){k(this)});g(".ctc-option-panel-container").on("click",".ctc-selector-handle",function(s){s.preventDefault();ctc_set_notice("");var t=g(this).attr("id").toString().replace("_close",""),r=t.toString().match(/_(\d+)$/)[1];if(g("#"+t+"_container").is(":hidden")){if(1!=loading.val_qry){loading.val_qry=0}ctc_render_selector_value_inputs(r)}g("#"+t+"_container").fadeToggle("fast");g(".ctc-selector-container").not("#"+t+"_container").fadeOut("fast")});g(".nav-tab").on("click",function(r){r.preventDefault();ctc_set_notice("");var s="#"+g(this).attr("id");ctc_focus_panel(s)});g("#view_child_options,#view_parnt_options").on("click",function(u){ctc_set_notice("");var r=new Date().getTime(),t=g(this).attr("id").toString().match(/(child|parnt)/)[1],s=ctcAjax.theme_uri+"/"+ctcAjax[t]+"/style.css?"+r;g.get(s,function(v){g("#view_"+t+"_options_panel").text(v)}).fail(function(){g("#view_"+t+"_options_panel").text(ctcAjax.css_fail_txt)})});g("#ctc_load_form").on("submit",function(){return(ctc_validate()&&confirm(ctcAjax.load_txt))});g("#parent_child_options_panel").on("change","#ctc_theme_child",ctc_set_theme_menu);g(document).on("click",".ctc-save-input",function(r){ctc_save(this)});g(document).on("click",".ctc-selector-edit",function(r){ctc_selector_edit(this)});ctc_setup_menus();ctc_set_query(m);g("input[type=submit],input[type=button]").prop("disabled",false);setTimeout(fade_update_notice,6000)});
 
 
 
 
 
 
 
 
 
 
 
css/chld-thm-cfg.css CHANGED
@@ -106,7 +106,12 @@
106
 
107
  .ctc-selector-handle {
108
  }
109
-
 
 
 
 
 
110
  .ctc-selector-container {
111
  clear: both;
112
  background: #f9f9f9;
106
 
107
  .ctc-selector-handle {
108
  }
109
+ .ctc-rewrite-toggle {
110
+ font-size:0.8em;
111
+ padding-left:1em;
112
+ display:none;
113
+ outline:none;
114
+ }
115
  .ctc-selector-container {
116
  clear: both;
117
  background: #f9f9f9;
includes/class-ctc-css.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined('ABSPATH')) exit;
6
  Class: Child_Theme_Configurator_CSS
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Handles all CSS output, parsing, normalization
9
- Version: 1.2.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -43,7 +43,7 @@ class Child_Theme_Configurator_CSS {
43
 
44
  function __construct() {
45
  // scalars
46
- $this->version = '1.2.1';
47
  $this->querykey = 0;
48
  $this->selkey = 0;
49
  $this->qskey = 0;
@@ -164,7 +164,7 @@ class Child_Theme_Configurator_CSS {
164
  endif;
165
  $position = array();
166
  foreach(preg_split('/ +/', trim($parts[1])) as $part):
167
- if (empty($part) || '' === $part) continue;
168
  if (false === strpos($part, 'repeat')):
169
  $position[] = $part;
170
  else:
@@ -311,7 +311,9 @@ class Child_Theme_Configurator_CSS {
311
  * CTC object arrays, creating update cache in the process.
312
  * Update cache is returned to UI via AJAX to refresh page
313
  */
314
- function update_arrays($template, $query, $sel, $rule = null, $value = null, $important = 0) {
 
 
315
  // add selector and query to index
316
  if (!isset($this->dict_query[$query])) $this->dict_query[$query] = ++$this->querykey;
317
  if (!isset($this->dict_sel[$sel])) $this->dict_sel[$sel] = ++$this->selkey;
@@ -361,6 +363,14 @@ class Child_Theme_Configurator_CSS {
361
  'data' => $this->denorm_sel_val($qsid),
362
  );
363
  $this->updates[] = $updatearr;
 
 
 
 
 
 
 
 
364
  endif;
365
  }
366
 
@@ -402,8 +412,6 @@ class Child_Theme_Configurator_CSS {
402
  preg_match_all($regex, $segment, $matches);
403
  foreach($matches[1] as $sel):
404
  $stuff = array_shift($matches[2]);
405
- // normalize selector styling
406
- $sel = implode(', ', preg_split('#\s*,\s*#s', trim($sel)));
407
  $this->update_arrays($template, $query, $sel);
408
  foreach (explode(';', $stuff) as $ruleval):
409
  if (false === strpos($ruleval, ':')) continue;
@@ -461,7 +469,6 @@ class Child_Theme_Configurator_CSS {
461
  * Preserves selector sequence and !important flags of parent stylesheet.
462
  * @media query blocks are sorted using internal heuristics (see sort_queries)
463
  * New selectors are appended to the end of each media query block.
464
- * TODO: allow user to modify selector sequence, !important flags and @media sort
465
  */
466
  function write_css($backup = false) {
467
  // verify write permissions
@@ -681,6 +688,7 @@ class Child_Theme_Configurator_CSS {
681
  /*
682
  * parse_css_input
683
  * Normalize raw user CSS input so that the parser can read it.
 
684
  */
685
  function parse_css_input($styles) {
686
  return $styles;
@@ -698,6 +706,7 @@ class Child_Theme_Configurator_CSS {
698
  elseif (isset($_POST['ctc_child_imports'])):
699
  $this->parse_css('child', $_POST['ctc_child_imports']);
700
  else:
 
701
  // set the custom sequence value
702
  foreach (preg_grep('#^ctc_ovrd_child_seq_#', array_keys($_POST)) as $post_key):
703
  if (preg_match('#^ctc_ovrd_child_seq_(\d+)$#', $post_key, $matches)):
@@ -705,8 +714,6 @@ class Child_Theme_Configurator_CSS {
705
  $this->dict_seq[$qsid] = intval($_POST[$post_key]);
706
  endif;
707
  endforeach;
708
- foreach (preg_grep('#^ctc_(ovrd|\d+)_child_seq_#', array_keys($_POST)) as $post_key):
709
- endforeach;
710
  $parts = array();
711
  foreach (preg_grep('#^ctc_(ovrd|\d+)_child#', array_keys($_POST)) as $post_key):
712
  if (preg_match('#^ctc_(ovrd|\d+)_child_([\w\-]+?)_(\d+?)(_(.+))?$#', $post_key, $matches)):
@@ -726,8 +733,21 @@ class Child_Theme_Configurator_CSS {
726
  $parts[$qsid][$rule]['query'] = $selarr['query'];
727
  $parts[$qsid][$rule]['selector'] = $selarr['selector'];
728
  else:
729
- $this->update_arrays('child', $selarr['query'], $selarr['selector'],
730
- $rule, $value, $important);
 
 
 
 
 
 
 
 
 
 
 
 
 
731
  endif;
732
  endif;
733
  endforeach;
@@ -758,8 +778,14 @@ class Child_Theme_Configurator_CSS {
758
  else:
759
  $value = '';
760
  endif;
761
- $this->update_arrays('child', $rule_part['query'], $rule_part['selector'],
762
- $rule, trim($value), $rule_part['important']);
 
 
 
 
 
 
763
  endforeach;
764
  endforeach;
765
  endif;
6
  Class: Child_Theme_Configurator_CSS
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Handles all CSS output, parsing, normalization
9
+ Version: 1.2.2
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
43
 
44
  function __construct() {
45
  // scalars
46
+ $this->version = '1.2.2';
47
  $this->querykey = 0;
48
  $this->selkey = 0;
49
  $this->qskey = 0;
164
  endif;
165
  $position = array();
166
  foreach(preg_split('/ +/', trim($parts[1])) as $part):
167
+ if ('' === $part) continue; // empty($part) ||
168
  if (false === strpos($part, 'repeat')):
169
  $position[] = $part;
170
  else:
311
  * CTC object arrays, creating update cache in the process.
312
  * Update cache is returned to UI via AJAX to refresh page
313
  */
314
+ function update_arrays($template, $query, $sel, $rule = null, $value = null, $important = 0, $seq = null) {
315
+ // normalize selector styling
316
+ $sel = implode(', ', preg_split('#\s*,\s*#s', trim($sel)));
317
  // add selector and query to index
318
  if (!isset($this->dict_query[$query])) $this->dict_query[$query] = ++$this->querykey;
319
  if (!isset($this->dict_sel[$sel])) $this->dict_sel[$sel] = ++$this->selkey;
363
  'data' => $this->denorm_sel_val($qsid),
364
  );
365
  $this->updates[] = $updatearr;
366
+ if (isset($seq)): // this is a renamed selector
367
+ $this->dict_seq[$qsid] = $seq;
368
+ $this->updates[] = array(
369
+ 'obj' => 'rewrite',
370
+ 'key' => $qsid,
371
+ 'data' => $sel,
372
+ );
373
+ endif;
374
  endif;
375
  }
376
 
412
  preg_match_all($regex, $segment, $matches);
413
  foreach($matches[1] as $sel):
414
  $stuff = array_shift($matches[2]);
 
 
415
  $this->update_arrays($template, $query, $sel);
416
  foreach (explode(';', $stuff) as $ruleval):
417
  if (false === strpos($ruleval, ':')) continue;
469
  * Preserves selector sequence and !important flags of parent stylesheet.
470
  * @media query blocks are sorted using internal heuristics (see sort_queries)
471
  * New selectors are appended to the end of each media query block.
 
472
  */
473
  function write_css($backup = false) {
474
  // verify write permissions
688
  /*
689
  * parse_css_input
690
  * Normalize raw user CSS input so that the parser can read it.
691
+ * TODO: this is a stub for future use
692
  */
693
  function parse_css_input($styles) {
694
  return $styles;
706
  elseif (isset($_POST['ctc_child_imports'])):
707
  $this->parse_css('child', $_POST['ctc_child_imports']);
708
  else:
709
+ $newselector = isset($_POST['ctc_rewrite_selector']) ? sanitize_text_field(stripslashes($_POST['ctc_rewrite_selector'])) : NULL;
710
  // set the custom sequence value
711
  foreach (preg_grep('#^ctc_ovrd_child_seq_#', array_keys($_POST)) as $post_key):
712
  if (preg_match('#^ctc_ovrd_child_seq_(\d+)$#', $post_key, $matches)):
714
  $this->dict_seq[$qsid] = intval($_POST[$post_key]);
715
  endif;
716
  endforeach;
 
 
717
  $parts = array();
718
  foreach (preg_grep('#^ctc_(ovrd|\d+)_child#', array_keys($_POST)) as $post_key):
719
  if (preg_match('#^ctc_(ovrd|\d+)_child_([\w\-]+?)_(\d+?)(_(.+))?$#', $post_key, $matches)):
733
  $parts[$qsid][$rule]['query'] = $selarr['query'];
734
  $parts[$qsid][$rule]['selector'] = $selarr['selector'];
735
  else:
736
+ if ($newselector && $newselector != $selarr['selector']):
737
+ // If this is a renamed selector, add new selector to array
738
+ // and clear original child selector values.
739
+ // Passing the sequence in the last argument serves two purposes:
740
+ // 1. sets sequence for new renamed selector.
741
+ // 2. tells the update_arrays function to flag this as a
742
+ // renamed selector to pass back in result array.
743
+ $this->update_arrays('child', $selarr['query'], $newselector,
744
+ $rule, trim($value), $important, $this->dict_seq[$qsid]);
745
+ $this->update_arrays('child', $selarr['query'], $selarr['selector'], $rule, '');
746
+ else:
747
+ // Otherwise, just update with the new values:
748
+ $this->update_arrays('child', $selarr['query'], $selarr['selector'],
749
+ $rule, trim($value), $important);
750
+ endif;
751
  endif;
752
  endif;
753
  endforeach;
778
  else:
779
  $value = '';
780
  endif;
781
+ if ($newselector && $newselector != $rule_part['selector']):
782
+ $this->update_arrays('child', $rule_part['query'], $newselector,
783
+ $rule, trim($value), $rule_part['important'], $this->dict_seq[$qsid]);
784
+ $this->update_arrays('child', $rule_part['query'], $rule_part['selector'], $rule, '');
785
+ else:
786
+ $this->update_arrays('child', $rule_part['query'], $rule_part['selector'],
787
+ $rule, trim($value), $rule_part['important']);
788
+ endif;
789
  endforeach;
790
  endforeach;
791
  endif;
includes/class-ctc-ui.php CHANGED
@@ -5,7 +5,7 @@ if ( !defined('ABSPATH')) exit;
5
  Class: Child_Theme_Configurator_UI
6
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
7
  Description: Handles the plugin User Interface
8
- Version: 1.2.1
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
@@ -144,6 +144,17 @@ class Child_Theme_Configurator_UI {
144
  value="<? echo esc_attr($css->get_property('version')); ?>" placeholder="version" autocomplete="off" />
145
  </div>
146
  </div>
 
 
 
 
 
 
 
 
 
 
 
147
  <div class="ctc-input-row clearfix" id="input_row_child_template">
148
  <div class="ctc-input-cell">
149
  <label>&nbsp;</label>
@@ -203,7 +214,7 @@ class Child_Theme_Configurator_UI {
203
  <div class="ctc-input-row clearfix" id="input_row_selector">
204
  <div class="ctc-input-cell"> <strong>
205
  <?php _e('Selector', 'chld_thm_cfg'); ?>
206
- </strong> </div>
207
  <div class="ctc-input-cell" id="ctc_sel_ovrd_selector_selected">&nbsp;</div>
208
  <div class="ctc-input-cell">
209
  <div class="ui-widget">
5
  Class: Child_Theme_Configurator_UI
6
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
7
  Description: Handles the plugin User Interface
8
+ Version: 1.2.2
9
  Author: Lilaea Media
10
  Author URI: http://www.lilaeamedia.com/
11
  Text Domain: chld_thm_cfg
144
  value="<? echo esc_attr($css->get_property('version')); ?>" placeholder="version" autocomplete="off" />
145
  </div>
146
  </div>
147
+ <div class="ctc-input-row clearfix" id="input_row_child_template">
148
+ <div class="ctc-input-cell">
149
+ <label>
150
+ <?php _e('Backup Stylesheet', 'chld_thm_cfg'); ?>
151
+ </label>
152
+ </div>
153
+ <div class="ctc-input-cell">
154
+ <input class="ctc_checkbox" id="ctc_backup" name="ctc_backup" type="checkbox"
155
+ value="1" checked />
156
+ </div>
157
+ </div>
158
  <div class="ctc-input-row clearfix" id="input_row_child_template">
159
  <div class="ctc-input-cell">
160
  <label>&nbsp;</label>
214
  <div class="ctc-input-row clearfix" id="input_row_selector">
215
  <div class="ctc-input-cell"> <strong>
216
  <?php _e('Selector', 'chld_thm_cfg'); ?>
217
+ </strong> <a href="#" class="ctc-rewrite-toggle"></a></div>
218
  <div class="ctc-input-cell" id="ctc_sel_ovrd_selector_selected">&nbsp;</div>
219
  <div class="ctc-input-cell">
220
  <div class="ui-widget">
includes/class-ctc.php CHANGED
@@ -6,7 +6,7 @@ if ( !defined('ABSPATH')) exit;
6
  Class: Child_Theme_Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Main Controller Class
9
- Version: 1.2.1
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
@@ -18,7 +18,7 @@ require_once('class-ctc-ui.php');
18
  require_once('class-ctc-css.php');
19
  class Child_Theme_Configurator {
20
 
21
- var $version = '1.2.1';
22
  var $css;
23
  var $optionsName;
24
  var $menuName;
@@ -96,6 +96,8 @@ class Child_Theme_Configurator {
96
  'selector_txt' => __('Selectors', 'chld_thm_cfg'),
97
  'close_txt' => __('Close', 'chld_thm_cfg'),
98
  'edit_txt' => __('Edit', 'chld_thm_cfg'),
 
 
99
  'css_fail_txt' => __('The stylesheet cannot be displayed.', 'chld_thm_cfg'),
100
  'child_only_txt' => __('(Child Only)', 'chld_thm_cfg'),
101
  'inval_theme_txt' => __('Please enter a valid Child Theme', 'chld_thm_cfg'),
@@ -154,8 +156,10 @@ class Child_Theme_Configurator {
154
  $this->css->parse_post_data();
155
  $this->css->write_css();
156
  $result = $this->css->get_property('updates');
 
157
  $this->css->reset_updates();
158
  update_option($this->optionsName, $this->css);
 
159
  die(json_encode($result));
160
  else:
161
  die(0);
@@ -232,7 +236,7 @@ class Child_Theme_Configurator {
232
  $this->css->set_property('child_version', $version);
233
  $this->css->parse_css_file('parnt');
234
  $this->css->parse_css_file('child');
235
- if (!$this->css->write_css(true)): // true backs up current stylesheet
236
  $this->errors[] = __('Your theme directory is not writable. Please adjust permissions and try again.', 'chld_thm_cfg');
237
  return false;
238
  endif;
@@ -258,7 +262,9 @@ class Child_Theme_Configurator {
258
  return in_array($theme, array_keys(wp_get_themes()));
259
  }
260
 
261
- // this is a stub for future use
 
 
262
  function sanitize_options($input) {
263
  return $input;
264
  }
6
  Class: Child_Theme_Configurator
7
  Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
8
  Description: Main Controller Class
9
+ Version: 1.2.2
10
  Author: Lilaea Media
11
  Author URI: http://www.lilaeamedia.com/
12
  Text Domain: chld_thm_cfg
18
  require_once('class-ctc-css.php');
19
  class Child_Theme_Configurator {
20
 
21
+ var $version = '1.2.2';
22
  var $css;
23
  var $optionsName;
24
  var $menuName;
96
  'selector_txt' => __('Selectors', 'chld_thm_cfg'),
97
  'close_txt' => __('Close', 'chld_thm_cfg'),
98
  'edit_txt' => __('Edit', 'chld_thm_cfg'),
99
+ 'cancel_txt' => __('Cancel', 'chld_thm_cfg'),
100
+ 'rename_txt' => __('Rename', 'chld_thm_cfg'),
101
  'css_fail_txt' => __('The stylesheet cannot be displayed.', 'chld_thm_cfg'),
102
  'child_only_txt' => __('(Child Only)', 'chld_thm_cfg'),
103
  'inval_theme_txt' => __('Please enter a valid Child Theme', 'chld_thm_cfg'),
156
  $this->css->parse_post_data();
157
  $this->css->write_css();
158
  $result = $this->css->get_property('updates');
159
+ // clear updates so they aren't saved in options object
160
  $this->css->reset_updates();
161
  update_option($this->optionsName, $this->css);
162
+ // send all updates back to browser to update cache
163
  die(json_encode($result));
164
  else:
165
  die(0);
236
  $this->css->set_property('child_version', $version);
237
  $this->css->parse_css_file('parnt');
238
  $this->css->parse_css_file('child');
239
+ if (!$this->css->write_css(isset($_POST['ctc_backup']))): // true backs up current stylesheet
240
  $this->errors[] = __('Your theme directory is not writable. Please adjust permissions and try again.', 'chld_thm_cfg');
241
  return false;
242
  endif;
262
  return in_array($theme, array_keys(wp_get_themes()));
263
  }
264
 
265
+ /*
266
+ * TODO: this is a stub for future use
267
+ */
268
  function sanitize_options($input) {
269
  return $input;
270
  }
js/chld-thm-cfg.js CHANGED
@@ -2,7 +2,7 @@
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
- * Version: 1.2.1
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
@@ -14,6 +14,8 @@ jQuery(document).ready(function($){
14
  currentQuery = 'base',
15
  currentSel,
16
  saveEvents = {},
 
 
17
  // initialize functions
18
  ctc_setup_iris = function(obj) {
19
  $(obj).iris({
@@ -141,7 +143,7 @@ jQuery(document).ready(function($){
141
  return postdata;
142
  },
143
  ctc_update_cache = function(response) {
144
- var currQuery, currSelId, currRule;
145
  $(response).each(function(){
146
  switch (this.obj) {
147
  case 'imports':
@@ -178,13 +180,17 @@ jQuery(document).ready(function($){
178
  case 'sel_val':
179
  ctcAjax.sel_val[this.key] = this.data;
180
  currSelId = this.key;
181
- break;
 
 
 
 
182
  }
183
  });
184
  },
185
  ctc_image_url = function(theme, value) {
186
  var parts = value.toString().match(/url\([" ]*(.+?)[" ]*\)/),
187
- path = ('undefined' == typeof parts ? null : parts[1]),
188
  url = ctcAjax.theme_uri + '/' + ('parent' == theme ? ctcAjax.parnt : ctcAjax.child) + '/',
189
  image_url;
190
  if (!path) {
@@ -494,7 +500,7 @@ jQuery(document).ready(function($){
494
  ctc_save = function(obj) {
495
  var postdata = {},
496
  $selector, $query, $imports, $rule,
497
- id = $(obj).attr('id');
498
  if (ctc_is_empty(saveEvents[id])) {
499
  saveEvents[id] = 0;
500
  }
@@ -517,6 +523,18 @@ jQuery(document).ready(function($){
517
  // coalesce inputs
518
  postdata = ctc_coalesce_inputs(obj);
519
  }
 
 
 
 
 
 
 
 
 
 
 
 
520
  // add wp ajax action to array
521
  postdata['action'] = 'ctc_update';
522
  postdata['_wpnonce'] = $('#_wpnonce').val();
@@ -528,6 +546,7 @@ jQuery(document).ready(function($){
528
  postdata,
529
  //on success function
530
  function(response){
 
531
  // release button
532
  $(obj).prop('disabled', false);
533
  // hide spinner
@@ -541,6 +560,10 @@ jQuery(document).ready(function($){
541
  // update data objects
542
  ctc_update_cache(response);
543
  ctc_setup_menus();
 
 
 
 
544
  }
545
  return false;
546
  }, 'json'
@@ -672,7 +695,8 @@ jQuery(document).ready(function($){
672
  currentSel = value;
673
  if (1 != loading.sel_val) loading.sel_val = 0;
674
  ctc_render_selector_inputs(value);
675
- $('#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs').show();
 
676
  },
677
 
678
  ctc_set_rule = function(value,label) {
@@ -680,6 +704,7 @@ jQuery(document).ready(function($){
680
  $('#ctc_rule_menu_selected').text(label);
681
  if (1 != loading.rule_val) loading.rule_val = 0;
682
  ctc_render_rule_value_inputs(value);
 
683
  $('#ctc_rule_value_inputs,#ctc_input_row_rule_header').show();
684
  },
685
  ctc_setup_query_menu = function() {
@@ -759,7 +784,7 @@ jQuery(document).ready(function($){
759
  autoFocus: true,
760
  select: function(e, ui) {
761
  e.preventDefault();
762
- var n = $(ctc_render_child_rule_input(currentSel, ui.item.label, 'ovrd'));
763
  $('#ctc_sel_ovrd_rule_inputs').append(n);
764
  $('#ctc_new_rule_menu').val('');
765
  if (ctc_is_empty(ctcAjax.sel_val[currentSel].value)) {
@@ -859,8 +884,21 @@ jQuery(document).ready(function($){
859
  ctc_set_query(q);
860
  ctc_set_selector(qsid, s);
861
  ctc_focus_panel(id);
862
-
863
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
864
  // initialize vars
865
  // ajax semaphores: 0 = reload, 1 = loading, 2 = loaded
866
  loading = {
@@ -936,6 +974,11 @@ jQuery(document).ready(function($){
936
  $(document).on('click', '.ctc-selector-edit', function(e) {
937
  ctc_selector_edit(this);
938
  });
 
 
 
 
 
939
  // initialize menus
940
  ctc_setup_menus();
941
  ctc_set_query(currentQuery);
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
+ * Version: 1.2.2
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
14
  currentQuery = 'base',
15
  currentSel,
16
  saveEvents = {},
17
+ rewrite_id,
18
+ rewrite_sel,
19
  // initialize functions
20
  ctc_setup_iris = function(obj) {
21
  $(obj).iris({
143
  return postdata;
144
  },
145
  ctc_update_cache = function(response) {
146
+ var currQuery, currSelId, currRuleId;
147
  $(response).each(function(){
148
  switch (this.obj) {
149
  case 'imports':
180
  case 'sel_val':
181
  ctcAjax.sel_val[this.key] = this.data;
182
  currSelId = this.key;
183
+ break;
184
+ case 'rewrite':
185
+ rewrite_id = this.key;
186
+ rewrite_sel = this.data;
187
+ break;
188
  }
189
  });
190
  },
191
  ctc_image_url = function(theme, value) {
192
  var parts = value.toString().match(/url\([" ]*(.+?)[" ]*\)/),
193
+ path = ctc_is_empty(parts) ? null : parts[1],
194
  url = ctcAjax.theme_uri + '/' + ('parent' == theme ? ctcAjax.parnt : ctcAjax.child) + '/',
195
  image_url;
196
  if (!path) {
500
  ctc_save = function(obj) {
501
  var postdata = {},
502
  $selector, $query, $imports, $rule,
503
+ id = $(obj).attr('id'), newsel;
504
  if (ctc_is_empty(saveEvents[id])) {
505
  saveEvents[id] = 0;
506
  }
523
  // coalesce inputs
524
  postdata = ctc_coalesce_inputs(obj);
525
  }
526
+ // add rename selector value if it exists
527
+ $('#ctc_sel_ovrd_selector_selected').find('#ctc_rewrite_selector').each(function(){
528
+ newsel = $('#ctc_rewrite_selector').val(),
529
+ origsel = $('#ctc_rewrite_selector_orig').val();
530
+ if (ctc_is_empty(newsel) || !newsel.toString().match(/\w/)) {
531
+ newsel = origsel;
532
+ } else {
533
+ postdata['ctc_rewrite_selector'] = newsel;
534
+ }
535
+ $('.ctc-rewrite-toggle').text(ctcAjax.rename_txt);
536
+ $('#ctc_sel_ovrd_selector_selected').html(newsel);
537
+ });
538
  // add wp ajax action to array
539
  postdata['action'] = 'ctc_update';
540
  postdata['_wpnonce'] = $('#_wpnonce').val();
546
  postdata,
547
  //on success function
548
  function(response){
549
+ console.log(response);
550
  // release button
551
  $(obj).prop('disabled', false);
552
  // hide spinner
560
  // update data objects
561
  ctc_update_cache(response);
562
  ctc_setup_menus();
563
+ if (false === ctc_is_empty(rewrite_id)) {
564
+ ctc_set_selector(rewrite_id, rewrite_sel);
565
+ rewrite_id = rewrite_sel = null;
566
+ }
567
  }
568
  return false;
569
  }, 'json'
695
  currentSel = value;
696
  if (1 != loading.sel_val) loading.sel_val = 0;
697
  ctc_render_selector_inputs(value);
698
+ $('.ctc-rewrite-toggle').text(ctcAjax.rename_txt);
699
+ $('#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs,.ctc-rewrite-toggle').show();
700
  },
701
 
702
  ctc_set_rule = function(value,label) {
704
  $('#ctc_rule_menu_selected').text(label);
705
  if (1 != loading.rule_val) loading.rule_val = 0;
706
  ctc_render_rule_value_inputs(value);
707
+ $('.ctc-rewrite-toggle').text(ctcAjax.rename_txt);
708
  $('#ctc_rule_value_inputs,#ctc_input_row_rule_header').show();
709
  },
710
  ctc_setup_query_menu = function() {
784
  autoFocus: true,
785
  select: function(e, ui) {
786
  e.preventDefault();
787
+ var n = $(ctc_render_child_rule_input(currentSel, ui.item.label.replace(/[^\w\-]/g, to_ascii), 'ovrd'));
788
  $('#ctc_sel_ovrd_rule_inputs').append(n);
789
  $('#ctc_new_rule_menu').val('');
790
  if (ctc_is_empty(ctcAjax.sel_val[currentSel].value)) {
884
  ctc_set_query(q);
885
  ctc_set_selector(qsid, s);
886
  ctc_focus_panel(id);
 
887
  },
888
+ ctc_selector_input_toggle = function(obj) {
889
+ var origval;
890
+ if ($('#ctc_rewrite_selector').length) {
891
+ origval = $('#ctc_rewrite_selector_orig').val();
892
+ $('#ctc_sel_ovrd_selector_selected').text(origval);
893
+ $(obj).text(ctcAjax.rename_txt);
894
+ } else {
895
+ origval = $('#ctc_sel_ovrd_selector_selected').text();
896
+ $('#ctc_sel_ovrd_selector_selected').html('<input id="ctc_rewrite_selector" name="ctc_rewrite_selector" type="text" value="'
897
+ + origval + '" autocomplete="off" /><input id="ctc_rewrite_selector_orig" name="ctc_rewrite_selector_orig" type="hidden" value="'
898
+ + origval + '"/>');
899
+ $(obj).text(ctcAjax.cancel_txt);
900
+ }
901
+ }
902
  // initialize vars
903
  // ajax semaphores: 0 = reload, 1 = loading, 2 = loaded
904
  loading = {
974
  $(document).on('click', '.ctc-selector-edit', function(e) {
975
  ctc_selector_edit(this);
976
  });
977
+ $(document).on('click', '.ctc-rewrite-toggle', function(e) {
978
+ e.preventDefault();
979
+ ctc_selector_input_toggle(this);
980
+ });//ctc_rewrite_toggle
981
+
982
  // initialize menus
983
  ctc_setup_menus();
984
  ctc_set_query(currentQuery);
js/chld-thm-cfg.min.js CHANGED
@@ -2,10 +2,10 @@
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
- * Version: 1.2.1
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
9
  * Copyright (C) 2013 Lilaea Media
10
  */
11
- ;jQuery(document).ready(function(g){var p="\n",m="base",a,o={},q=function(r){g(r).iris({change:function(){k(r)}})},l=function(t){var r=parseInt(t),s=String.fromCharCode(r);return s},i=function(s){var r=s.charCodeAt(0);return r},k=function(x){var t=/^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+))(_\w+)?$/,y=g(x).parents(".ctc-selector-row, .ctc-parent-row").first(),w=y.find(".ctc-swatch").first(),v={parent:{},child:{}},u={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},s={child:false,parent:false},r={};y.find(".ctc-parent-value, .ctc-child-value").each(function(){var G=g(this).attr("id"),z=G.toString().match(t),H=z[2],A=z[3],J=("undefined"==typeof z[4]?"":z[4]),F=z[5],E=("undefined"==typeof z[6]?"":z[6]),I=("parent"==A?g(this).text():g(this).val()),B="ctc_"+H+"_child_"+J+"_i_"+F,D,C;if("child"==A){r[G]=I;r[B]=(g("#"+B).is(":checked"))?1:0}if(false===b(E)){switch(E){case"_border_width":v[A][J+"-width"]=I;break;case"_border_style":v[A][J+"-style"]=I;break;case"_border_color":v[A][J+"-color"]=I;break;case"_background_url":v[A]["background-image"]=d(A,I);break;case"_background_color":v[A]["background-color"]=x.value;break;case"_background_color1":u[A].start=I;s[A]=true;break;case"_background_color2":u[A].end=I;s[A]=true;break;case"_background_origin":u[A].origin=I;s[A]=true;break}}else{if(D=J.toString().match(/^border(\-(top|right|bottom|left))?$/)&&!I.match(/none/)){C=I.toString().split(/ +/);v[A][J+"-width"]="undefined"==typeof C[0]?"":C[0];v[A][J+"-style"]="undefined"==typeof C[1]?"":C[1];v[A][J+"-color"]="undefined"==typeof C[2]?"":C[2]}else{if("background-image"==J){if(I.toString().match(/url\(/)){v[A]["background-image"]=d(A,I)}else{C=I.toString().split(/ +/);if(C.length>2){u[A].origin="undefined"==typeof C[0]?"top":C[0];u[A].start="undefined"==typeof C[1]?"transparent":C[1];u[A].end="undefined"==typeof C[2]?"transparent":C[2];s[A]=true}else{v[A]["background-image"]=I}}}else{v[A][J]=I}}}});if("undefined"!=typeof w){g(w).removeAttr("style");if(s.parent){g(w).ctcgrad(u.parent.origin,[u.parent.start,u.parent.end])}g(w).css(v.parent);if(!(w.attr("id").toString().match(/parent/))){if(s.child){g(w).ctcgrad(u.child.origin,[u.child.start,u.child.end])}g(w).css(v.child)}}return r},c=function(t){var s,u,r;g(t).each(function(){switch(this.obj){case"imports":ctcAjax.imports=this.data;break;case"rule_val":ctcAjax.rule_val[this.key]=this.data;currRuleId=this.key;break;case"val_qry":ctcAjax.val_qry[this.key]=this.data;break;case"rule":ctcAjax.rule=this.data;break;case"sel_ndx":if(b(this.key)){ctcAjax.sel_ndx=this.data}else{if("qsid"==this.key){if(b(ctcAjax.sel_ndx[this.data.query])){ctcAjax.sel_ndx[this.data.query]={}}ctcAjax.sel_ndx[this.data.query][this.data.selector]=this.data.qsid}else{ctcAjax.sel_ndx[this.key]=this.data;s=this.key}}break;case"sel_val":ctcAjax.sel_val[this.key]=this.data;u=this.key;break}})},d=function(v,s){var u=s.toString().match(/url\([" ]*(.+?)[" ]*\)/),t=("undefined"==typeof u?null:u[1]),r=ctcAjax.theme_uri+"/"+("parent"==v?ctcAjax.parnt:ctcAjax.child)+"/",w;if(!t){return false}else{if(t.toString().match(/^(https?:|\/)/)){w=s}else{w="url("+r+t+")"}}return w},b=function(s){if("undefined"==typeof s||false===s||null===s||""===s){return true}if(true===s||"string"===typeof s||"number"===typeof s){return false}if("object"===typeof s){for(var r in s){if(s.hasOwnProperty(r)){return false}}return true}return false},j=function(){var r=[];if(1===loading.sel_ndx){return r}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",null,ctc_setup_query_menu);return r}if(false===b(ctcAjax.sel_ndx)){g.each(ctcAjax.sel_ndx,function(s,t){var u={label:s,value:s};r.push(u)})}return r},f=function(s){var r=[];if(1===loading.sel_ndx){return r}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",s,ctc_setup_selector_menu);return r}if(false===b(ctcAjax.sel_ndx[s])){g.each(ctcAjax.sel_ndx[s],function(t,u){var v={label:t,value:u};r.push(v)})}return r},n=function(){var r=[];if(1===loading.rule){return r}if(0===loading.rule){loading.rule=1;ctc_query_css("rule",null,ctc_setup_rule_menu);return r}if(false===b(ctcAjax.rule)){g.each(ctcAjax.rule,function(s,t){var u={label:t.replace(/\d+/g,l),value:s};r.push(u)})}return r.sort(function(t,s){if(t.label>s.label){return 1}if(t.label<s.label){return -1}return 0})},h=function(v,x,A){var t="",y=(b(ctcAjax.sel_val[v])||b(ctcAjax.sel_val[v].value)||b(ctcAjax.sel_val[v].value[x])?"":ctcAjax.sel_val[v].value[x]),s=ctc_decode_value(x,("undefined"==typeof y?"":y.parnt)),w=(false===b(y.i_parnt)&&y.i_parnt)?ctcAjax.important_label:"",u=ctc_decode_value(x,("undefined"==typeof y?"":y.child)),r=(false===b(y.i_child)&&y.i_child)?1:0,z="ctc_"+A+"_child_"+x+"_i_"+v;if(false===b(ctcAjax.sel_val[v])){t+='<div class="ctc-'+("ovrd"==A?"input":"selector")+'-row clearfix">'+p;t+='<div class="ctc-input-cell">'+("ovrd"==A?x.replace(/\d+/g,l):ctcAjax.sel_val[v].selector+'<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_'+v+'" >'+ctcAjax.edit_txt+"</a> "+(b(s.orig)?ctcAjax.child_only_txt:""))+"</div>"+p;if("ovrd"==A){t+='<div class="ctc-parent-value ctc-input-cell" id="ctc_'+A+"_parent_"+x+"_"+v+'">'+(b(s.orig)?"[no value]":s.orig+w)+"</div>"+p}t+='<div class="ctc-input-cell">'+p;if(false===b(s.names)){g.each(s.names,function(B,C){C=(b(C)?"":C);t+='<div class="ctc-child-input-cell">'+p;var E="ctc_"+A+"_child_"+x+"_"+v+C,D;if(false===(D=u.values.shift())){D=""}t+=(b(C)?"":ctcAjax.field_labels[C]+":<br/>")+'<input type="text" id="'+E+'" name="'+E+'" class="ctc-child-value'+((C+x).toString().match(/color/)?" color-picker":"")+((C).toString().match(/url/)?" ctc-input-wide":"")+'" value="'+D+'" />'+p;t+="</div>"+p});t+='<label for="'+z+'"><input type="checkbox" id="'+z+'" name="'+z+'" value="1" '+(1===r?"checked":"")+" />"+ctcAjax.important_label+"</label>"+p}t+="</div>"+p;t+=("ovrd"==A?"":'<div class="ctc-swatch ctc-specific" id="ctc_child_'+x+"_"+v+'_swatch">'+ctcAjax.swatch_txt+"</div>"+p+'<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+x+"_"+v+'_cell">'+p+'<input type="button" class="button ctc-save-input" id="ctc_save_'+x+"_"+v+'" name="ctc_save_'+x+"_"+v+'" value="Save" /></div>'+p);t+="</div><!-- end input row -->"+p}return t},e=function(r){if(1===loading.sel_val){return false}if(0==loading.sel_val){loading.sel_val=1;ctc_query_css("sel_val",r,e);return false}var u,s,t;if(b(ctcAjax.sel_val[r])){g("#ctc_sel_ovrd_rule_inputs").html("")}else{if(b(ctcAjax.sel_val[r].seq)){g("#ctc_child_load_order_container").html("")}else{u="ctc_ovrd_child_seq_"+r;t=parseInt(ctcAjax.sel_val[r].seq);s='<input type="text" id="'+u+'" name="'+u+'" class="ctc-child-value" value="'+t+'" />';g("#ctc_child_load_order_container").html(s)}if(b(ctcAjax.sel_val[r].value)){g("#ctc_sel_ovrd_rule_inputs").html("")}else{s="";g.each(ctcAjax.sel_val[r].value,function(w,v){s+=h(r,w,"ovrd")});g("#ctc_sel_ovrd_rule_inputs").html(s).find(".color-picker").each(function(){q(this)});k("#ctc_child_all_0_swatch")}}};ctc_render_rule_value_inputs=function(s){if(1===loading.rule_val){return false}if(0==loading.rule_val){loading.rule_val=1;ctc_query_css("rule_val",s,ctc_render_rule_value_inputs);return false}var t=ctcAjax.rule[s],r='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+t+'">'+p;if(false===b(ctcAjax.rule_val[s])){g.each(ctcAjax.rule_val[s],function(v,w){var u=ctc_decode_value(t,w);r+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+t+"_"+v+'">'+p;r+='<div class="ctc-input-cell ctc-parent-value" id="ctc_'+v+"_parent_"+t+"_"+v+'">'+u.orig+"</div>"+p;r+='<div class="ctc-input-cell">'+p;r+='<div class="ctc-swatch ctc-specific" id="ctc_'+v+"_parent_"+t+"_"+v+'_swatch">'+ctcAjax.swatch_txt+"</div></div>"+p;r+='<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+t+"_"+v+'">'+ctcAjax.selector_txt+"</a></div>"+p;r+='<div id="ctc_selector_'+t+"_"+v+'_container" class="ctc-selector-container clearfix">'+p;r+='<a href="#" id="ctc_selector_'+t+"_"+v+'_close" class="ctc-selector-handle" style="float:right">'+ctcAjax.close_txt+'</a><div id="ctc_status_val_qry_'+v+'"></div>'+p;r+='<div id="ctc_selector_'+t+"_"+v+'_rows"></div>'+p;r+="</div></div>"+p});r+="</div>"+p}g("#ctc_rule_value_inputs").html(r).find(".ctc-swatch").each(function(){k(this)})},ctc_render_selector_value_inputs=function(u){if(1==loading.val_qry){return false}var w,s,v=g("#ctc_rule_menu_selected").text().replace(/[^\w\-]/g,i),r,t="";if(0===loading.val_qry){loading.val_qry=1;w={rule:v};ctc_query_css("val_qry",u,ctc_render_selector_value_inputs,w);return false}if(false===b(ctcAjax.val_qry[u])){g.each(ctcAjax.val_qry[u],function(y,x){page_rule=y;g.each(x,function(A,z){t+='<h4 class="ctc-query-heading">'+A+"</h4>"+p;if(false===b(z)){g.each(z,function(B,C){ctcAjax.sel_val[B]=C;t+=h(B,y,u)})}})})}r="#ctc_selector_"+v+"_"+u+"_rows";g(r).html(t).find(".color-picker").each(function(){q(this)});g(r).find(".ctc-swatch").each(function(){k(this)})},ctc_query_css=function(t,s,w,u){var r={ctc_query_obj:t,ctc_query_key:s},v="#ctc_status_"+t+("val_qry"==t?"_"+s:"");if("object"===typeof u){g.each(u,function(x,y){r["ctc_query_"+x]=y})}g(".ctc-status-icon").remove();g(v).append('<span class="ctc-status-icon spinner"></span>');g(".spinner").show();r.action="ctc_query";r._wpnonce=g("#_wpnonce").val();g.post(ctcAjax.ajaxurl,r,function(x){loading[t]=2;g(".ctc-status-icon").removeClass("spinner");if(b(x)){g(".ctc-status-icon").addClass("failure")}else{g(".ctc-status-icon").addClass("success");c(x);if("function"===typeof w){w(s)}return false}},"json").fail(function(){loading[t]=0;g(".ctc-status-icon").removeClass("spinner");g(".ctc-status-icon").addClass("failure")});return false},ctc_save=function(v){var u={},w,t,r,s,x=g(v).attr("id");if(b(o[x])){o[x]=0}o[x]++;g(v).prop("disabled",true);g(".ctc-status-icon").remove();g(v).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner"></span>');g(".spinner").show();if((w=g("#ctc_new_selectors"))&&"ctc_save_new_selectors"==g(v).attr("id")){u.ctc_new_selectors=w.val();if(t=g("#ctc_sel_ovrd_query_selected")){u.ctc_sel_ovrd_query=t.text()}}else{if((r=g("#ctc_child_imports"))&&"ctc_save_imports"==g(v).attr("id")){u.ctc_child_imports=r.val()}else{u=k(v)}}u.action="ctc_update";u._wpnonce=g("#_wpnonce").val();g.post(ctcAjax.ajaxurl,u,function(y){g(v).prop("disabled",false);g(".ctc-status-icon").removeClass("spinner");if(b(y)){g(".ctc-status-icon").addClass("failure")}else{g(".ctc-status-icon").addClass("success");g("#ctc_new_selectors").val("");c(y);ctc_setup_menus()}return false},"json").fail(function(){g(v).prop("disabled",false);g(".ctc-status-icon").removeClass("spinner");g(".ctc-status-icon").addClass("failure")});return false},ctc_decode_value=function(t,r){r=("undefined"==typeof r?"":r);var s={orig:r};if(t.toString().match(/^border(\-(top|right|bottom|left))?$/)){var u=r.toString().split(/ +/);s.names=["_border_width","_border_style","_border_color"];s.values=[("undefined"==typeof u[0]?"":u[0]),("undefined"==typeof u[1]?"":u[1]),("undefined"==typeof u[2]?"":u[2])]}else{if(t.toString().match(/^background\-image/)){s.names=["_background_url","_background_origin","_background_color1","_background_color2"];s.values=["","","",""];if(false===(b(r))&&!(r.toString().match(/url/))){var u=r.toString().split(/:/);s.values[1]=("undefined"==typeof u[0]?"":u[0]);s.values[2]=("undefined"==typeof u[1]?"":u[1]);s.values[3]=("undefined"==typeof u[3]?"":u[3]);s.orig=[s.values[1],s.values[2],s.values[3]].join(" ")}else{s.values[0]=r}}else{s.names=[""];s.values=[r]}}return s},ctc_set_query=function(r){m=r;g("#ctc_sel_ovrd_query").val("");g("#ctc_sel_ovrd_query_selected").text(r);g("#ctc_sel_ovrd_selector").val("");g("#ctc_sel_ovrd_selector_selected").html("&nbsp;");g("#ctc_sel_ovrd_rule_inputs").html("");ctc_setup_selector_menu(r);k("#ctc_child_all_0_swatch");g("#ctc_new_selector_row").show()},ctc_set_selector=function(s,r){g("#ctc_sel_ovrd_selector").val("");g("#ctc_sel_ovrd_selector_selected").text(r);g("#ctc_sel_ovrd_qsid").val(s);a=s;if(1!=loading.sel_val){loading.sel_val=0}e(s);g("#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs").show()},ctc_set_rule=function(s,r){g("#ctc_rule_menu").val("");g("#ctc_rule_menu_selected").text(r);if(1!=loading.rule_val){loading.rule_val=0}ctc_render_rule_value_inputs(s);g("#ctc_rule_value_inputs,#ctc_input_row_rule_header").show()},ctc_setup_query_menu=function(){ctc_queries=j();g("#ctc_sel_ovrd_query").autocomplete({source:ctc_queries,minLength:0,selectFirst:true,autoFocus:true,select:function(s,r){ctc_set_query(r.item.value);return false},focus:function(r){r.preventDefault()}})},ctc_setup_selector_menu=function(r){ctc_selectors=f(r);g("#ctc_sel_ovrd_selector").autocomplete({source:ctc_selectors,selectFirst:true,autoFocus:true,select:function(t,s){ctc_set_selector(s.item.value,s.item.label);return false},focus:function(s){s.preventDefault()}})},ctc_setup_rule_menu=function(){ctc_rules=n();g("#ctc_rule_menu").autocomplete({source:ctc_rules,selectFirst:true,autoFocus:true,select:function(s,r){ctc_set_rule(r.item.value,r.item.label);return false},focus:function(r){r.preventDefault()}})},ctc_filtered_rules=function(u,s){var r=[],t=(b(ctcAjax.sel_val[a]))||(b(ctcAjax.sel_val[a].value));if(b(ctc_rules)){ctc_rules=n()}g.each(ctc_rules,function(v,y){var w=false,x=new RegExp(g.ui.autocomplete.escapeRegex(u.term),"i");if(x.test(y.label)){if(false===t){g.each(ctcAjax.sel_val[a].value,function(A,z){if(y.label==A.replace(/\d+/g,l)){w=true;return false}});if(w){return}}r.push(y)}});s(r)},ctc_setup_new_rule_menu=function(){g("#ctc_new_rule_menu").autocomplete({source:ctc_filtered_rules,selectFirst:true,autoFocus:true,select:function(s,r){s.preventDefault();var t=g(h(a,r.item.label,"ovrd"));g("#ctc_sel_ovrd_rule_inputs").append(t);g("#ctc_new_rule_menu").val("");if(b(ctcAjax.sel_val[a].value)){ctcAjax.sel_val[a]["value"]={}}ctcAjax.sel_val[a].value[r.item.label]={child:""};t.find('input[type="text"]').each(function(u,v){if(g(v).hasClass("color-picker")){q(v)}g(v).focus()});return false},focus:function(r){r.preventDefault()}})},ctc_setup_menus=function(){ctc_setup_query_menu();ctc_setup_selector_menu(m);ctc_setup_rule_menu();ctc_setup_new_rule_menu()},ctc_theme_exists=function(r,s){var t=false;g.each(ctcAjax.themes,function(u,v){g.each(v,function(w,x){if(w==r&&("parnt"==u||"new"==s)){t=true;return false}});if(t){return false}});return t},ctc_set_notice=function(r){var s="";if(false===b(r)){g.each(r,function(t,u){s+='<div class="'+t+'"><ul>'+p;g(u).each(function(v,w){s+="<li>"+w.toString()+"</li>"+p});s+="</ul></div>"})}g("#ctc_error_notice").html(s)},ctc_validate=function(){var u=/[^\w\-]/,s=g("#ctc_child_template").val().toString().replace(u).toLowerCase(),r=g("#ctc_theme_child").val().toString().replace(u).toLowerCase(),t=g("input[name=ctc_child_type]:checked").val(),v=[];if("new"==t){r=s}if(ctc_theme_exists(r,t)){v.push(ctcAjax.theme_exists_txt.toString().replace(/%s/,r))}if(""===r){v.push(ctcAjax.inval_theme_txt)}if(""===g("#ctc_child_name").val()){v.push(ctcAjax.inval_name_txt)}if(v.length){ctc_set_notice({error:v});return false}return true},ctc_set_theme_menu=function(s){var r=g("#ctc_theme_child").val();if(false===b(ctcAjax.themes.child[r])){g("#ctc_child_name").val(ctcAjax.themes.child[r].Name);g("#ctc_child_author").val(ctcAjax.themes.child[r].Author);g("#ctc_child_version").val(ctcAjax.themes.child[r].Version)}},fade_update_notice=function(){g(".updated, .error").slideUp("slow",function(){g(".updated").remove()})},ctc_focus_panel=function(s){var r=s+"_panel";g(".nav-tab").removeClass("nav-tab-active");g(".ctc-option-panel").removeClass("ctc-option-panel-active");g(".ctc-selector-container").hide();g(s).addClass("nav-tab-active");g(".ctc-option-panel-container").scrollTop(0);g(r).addClass("ctc-option-panel-active")},ctc_selector_edit=function(v){var r=g(v).attr("id").match(/_(\d+)$/)[1],u=ctcAjax.sel_val[r].query,t=ctcAjax.sel_val[r].selector,w="#query_selector_options";ctc_set_query(u);ctc_set_selector(r,t);ctc_focus_panel(w)},loading={rule:2,sel_ndx:2,val_qry:0,rule_val:0,sel_val:0},ctc_selectors=[],ctc_queries=[],ctc_rules=[];g(".color-picker").each(function(){q(this)});g(".ctc-option-panel-container").on("focus",".color-picker",function(){ctc_set_notice("");g(this).iris("toggle");g(".iris-picker").css({position:"absolute","z-index":10})});g(".ctc-option-panel-container").on("focus","input",function(){ctc_set_notice("");g(".color-picker").not(this).iris("hide")});g(".ctc-option-panel-container").on("change",".ctc-child-value, input[type=checkbox]",function(){k(this)});g(".ctc-option-panel-container").on("click",".ctc-selector-handle",function(s){s.preventDefault();ctc_set_notice("");var t=g(this).attr("id").toString().replace("_close",""),r=t.toString().match(/_(\d+)$/)[1];if(g("#"+t+"_container").is(":hidden")){if(1!=loading.val_qry){loading.val_qry=0}ctc_render_selector_value_inputs(r)}g("#"+t+"_container").fadeToggle("fast");g(".ctc-selector-container").not("#"+t+"_container").fadeOut("fast")});g(".nav-tab").on("click",function(r){r.preventDefault();ctc_set_notice("");var s="#"+g(this).attr("id");ctc_focus_panel(s)});g("#view_child_options,#view_parnt_options").on("click",function(u){ctc_set_notice("");var r=new Date().getTime(),t=g(this).attr("id").toString().match(/(child|parnt)/)[1],s=ctcAjax.theme_uri+"/"+ctcAjax[t]+"/style.css?"+r;g.get(s,function(v){g("#view_"+t+"_options_panel").text(v)}).fail(function(){g("#view_"+t+"_options_panel").text(ctcAjax.css_fail_txt)})});g("#ctc_load_form").on("submit",function(){return(ctc_validate()&&confirm(ctcAjax.load_txt))});g("#parent_child_options_panel").on("change","#ctc_theme_child",ctc_set_theme_menu);g(document).on("click",".ctc-save-input",function(r){ctc_save(this)});g(document).on("click",".ctc-selector-edit",function(r){ctc_selector_edit(this)});ctc_setup_menus();ctc_set_query(m);g("input[type=submit],input[type=button]").prop("disabled",false);setTimeout(fade_update_notice,6000)});
2
  * Script: chld-thm-cfg.js
3
  * Plugin URI: http://www.lilaeamedia.com/plugins/child-theme-configurator/
4
  * Description: Handles jQuery, AJAX and other UI
5
+ * Version: 1.2.2
6
  * Author: Lilaea Media
7
  * Author URI: http://www.lilaeamedia.com/
8
  * License: GPLv2
9
  * Copyright (C) 2013 Lilaea Media
10
  */
11
+ ;jQuery(document).ready(function(c){var l="\n",s="base",h,b={},p,q,k=function(t){c(t).iris({change:function(){f(t)}})},e=function(v){var t=parseInt(v),u=String.fromCharCode(t);return u},m=function(u){var t=u.charCodeAt(0);return t},f=function(z){var v=/^(ctc_(ovrd|\d+)_(parent|child)_([0-9a-z\-]+)_(\d+))(_\w+)?$/,A=c(z).parents(".ctc-selector-row, .ctc-parent-row").first(),y=A.find(".ctc-swatch").first(),x={parent:{},child:{}},w={parent:{origin:"",start:"",end:""},child:{origin:"",start:"",end:""}},u={child:false,parent:false},t={};A.find(".ctc-parent-value, .ctc-child-value").each(function(){var I=c(this).attr("id"),B=I.toString().match(v),J=B[2],C=B[3],L=("undefined"==typeof B[4]?"":B[4]),H=B[5],G=("undefined"==typeof B[6]?"":B[6]),K=("parent"==C?c(this).text():c(this).val()),D="ctc_"+J+"_child_"+L+"_i_"+H,F,E;if("child"==C){t[I]=K;t[D]=(c("#"+D).is(":checked"))?1:0}if(false===r(G)){switch(G){case"_border_width":x[C][L+"-width"]=K;break;case"_border_style":x[C][L+"-style"]=K;break;case"_border_color":x[C][L+"-color"]=K;break;case"_background_url":x[C]["background-image"]=i(C,K);break;case"_background_color":x[C]["background-color"]=z.value;break;case"_background_color1":w[C].start=K;u[C]=true;break;case"_background_color2":w[C].end=K;u[C]=true;break;case"_background_origin":w[C].origin=K;u[C]=true;break}}else{if(F=L.toString().match(/^border(\-(top|right|bottom|left))?$/)&&!K.match(/none/)){E=K.toString().split(/ +/);x[C][L+"-width"]="undefined"==typeof E[0]?"":E[0];x[C][L+"-style"]="undefined"==typeof E[1]?"":E[1];x[C][L+"-color"]="undefined"==typeof E[2]?"":E[2]}else{if("background-image"==L){if(K.toString().match(/url\(/)){x[C]["background-image"]=i(C,K)}else{E=K.toString().split(/ +/);if(E.length>2){w[C].origin="undefined"==typeof E[0]?"top":E[0];w[C].start="undefined"==typeof E[1]?"transparent":E[1];w[C].end="undefined"==typeof E[2]?"transparent":E[2];u[C]=true}else{x[C]["background-image"]=K}}}else{x[C][L]=K}}}});if("undefined"!=typeof y){c(y).removeAttr("style");if(u.parent){c(y).ctcgrad(w.parent.origin,[w.parent.start,w.parent.end])}c(y).css(x.parent);if(!(y.attr("id").toString().match(/parent/))){if(u.child){c(y).ctcgrad(w.child.origin,[w.child.start,w.child.end])}c(y).css(x.child)}}return t},n=function(u){var t,v,w;c(u).each(function(){switch(this.obj){case"imports":ctcAjax.imports=this.data;break;case"rule_val":ctcAjax.rule_val[this.key]=this.data;w=this.key;break;case"val_qry":ctcAjax.val_qry[this.key]=this.data;break;case"rule":ctcAjax.rule=this.data;break;case"sel_ndx":if(r(this.key)){ctcAjax.sel_ndx=this.data}else{if("qsid"==this.key){if(r(ctcAjax.sel_ndx[this.data.query])){ctcAjax.sel_ndx[this.data.query]={}}ctcAjax.sel_ndx[this.data.query][this.data.selector]=this.data.qsid}else{ctcAjax.sel_ndx[this.key]=this.data;t=this.key}}break;case"sel_val":ctcAjax.sel_val[this.key]=this.data;v=this.key;break;case"rewrite":p=this.key;q=this.data;break}})},i=function(x,u){var w=u.toString().match(/url\([" ]*(.+?)[" ]*\)/),v=r(w)?null:w[1],t=ctcAjax.theme_uri+"/"+("parent"==x?ctcAjax.parnt:ctcAjax.child)+"/",y;if(!v){return false}else{if(v.toString().match(/^(https?:|\/)/)){y=u}else{y="url("+t+v+")"}}return y},r=function(u){if("undefined"==typeof u||false===u||null===u||""===u){return true}if(true===u||"string"===typeof u||"number"===typeof u){return false}if("object"===typeof u){for(var t in u){if(u.hasOwnProperty(t)){return false}}return true}return false},a=function(){var t=[];if(1===loading.sel_ndx){return t}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",null,ctc_setup_query_menu);return t}if(false===r(ctcAjax.sel_ndx)){c.each(ctcAjax.sel_ndx,function(u,v){var w={label:u,value:u};t.push(w)})}return t},o=function(u){var t=[];if(1===loading.sel_ndx){return t}if(0===loading.sel_ndx){loading.sel_ndx=1;ctc_query_css("sel_ndx",u,ctc_setup_selector_menu);return t}if(false===r(ctcAjax.sel_ndx[u])){c.each(ctcAjax.sel_ndx[u],function(v,w){var x={label:v,value:w};t.push(x)})}return t},d=function(){var t=[];if(1===loading.rule){return t}if(0===loading.rule){loading.rule=1;ctc_query_css("rule",null,ctc_setup_rule_menu);return t}if(false===r(ctcAjax.rule)){c.each(ctcAjax.rule,function(u,v){var w={label:v.replace(/\d+/g,e),value:u};t.push(w)})}return t.sort(function(v,u){if(v.label>u.label){return 1}if(v.label<u.label){return -1}return 0})},j=function(x,z,C){var v="",A=(r(ctcAjax.sel_val[x])||r(ctcAjax.sel_val[x].value)||r(ctcAjax.sel_val[x].value[z])?"":ctcAjax.sel_val[x].value[z]),u=ctc_decode_value(z,("undefined"==typeof A?"":A.parnt)),y=(false===r(A.i_parnt)&&A.i_parnt)?ctcAjax.important_label:"",w=ctc_decode_value(z,("undefined"==typeof A?"":A.child)),t=(false===r(A.i_child)&&A.i_child)?1:0,B="ctc_"+C+"_child_"+z+"_i_"+x;if(false===r(ctcAjax.sel_val[x])){v+='<div class="ctc-'+("ovrd"==C?"input":"selector")+'-row clearfix">'+l;v+='<div class="ctc-input-cell">'+("ovrd"==C?z.replace(/\d+/g,e):ctcAjax.sel_val[x].selector+'<br/><a href="#" class="ctc-selector-edit" id="ctc_selector_edit_'+x+'" >'+ctcAjax.edit_txt+"</a> "+(r(u.orig)?ctcAjax.child_only_txt:""))+"</div>"+l;if("ovrd"==C){v+='<div class="ctc-parent-value ctc-input-cell" id="ctc_'+C+"_parent_"+z+"_"+x+'">'+(r(u.orig)?"[no value]":u.orig+y)+"</div>"+l}v+='<div class="ctc-input-cell">'+l;if(false===r(u.names)){c.each(u.names,function(D,E){E=(r(E)?"":E);v+='<div class="ctc-child-input-cell">'+l;var G="ctc_"+C+"_child_"+z+"_"+x+E,F;if(false===(F=w.values.shift())){F=""}v+=(r(E)?"":ctcAjax.field_labels[E]+":<br/>")+'<input type="text" id="'+G+'" name="'+G+'" class="ctc-child-value'+((E+z).toString().match(/color/)?" color-picker":"")+((E).toString().match(/url/)?" ctc-input-wide":"")+'" value="'+F+'" />'+l;v+="</div>"+l});v+='<label for="'+B+'"><input type="checkbox" id="'+B+'" name="'+B+'" value="1" '+(1===t?"checked":"")+" />"+ctcAjax.important_label+"</label>"+l}v+="</div>"+l;v+=("ovrd"==C?"":'<div class="ctc-swatch ctc-specific" id="ctc_child_'+z+"_"+x+'_swatch">'+ctcAjax.swatch_txt+"</div>"+l+'<div class="ctc-child-input-cell ctc-button-cell" id="ctc_save_'+z+"_"+x+'_cell">'+l+'<input type="button" class="button ctc-save-input" id="ctc_save_'+z+"_"+x+'" name="ctc_save_'+z+"_"+x+'" value="Save" /></div>'+l);v+="</div><!-- end input row -->"+l}return v},g=function(t){if(1===loading.sel_val){return false}if(0==loading.sel_val){loading.sel_val=1;ctc_query_css("sel_val",t,g);return false}var w,u,v;if(r(ctcAjax.sel_val[t])){c("#ctc_sel_ovrd_rule_inputs").html("")}else{if(r(ctcAjax.sel_val[t].seq)){c("#ctc_child_load_order_container").html("")}else{w="ctc_ovrd_child_seq_"+t;v=parseInt(ctcAjax.sel_val[t].seq);u='<input type="text" id="'+w+'" name="'+w+'" class="ctc-child-value" value="'+v+'" />';c("#ctc_child_load_order_container").html(u)}if(r(ctcAjax.sel_val[t].value)){c("#ctc_sel_ovrd_rule_inputs").html("")}else{u="";c.each(ctcAjax.sel_val[t].value,function(y,x){u+=j(t,y,"ovrd")});c("#ctc_sel_ovrd_rule_inputs").html(u).find(".color-picker").each(function(){k(this)});f("#ctc_child_all_0_swatch")}}};ctc_render_rule_value_inputs=function(u){if(1===loading.rule_val){return false}if(0==loading.rule_val){loading.rule_val=1;ctc_query_css("rule_val",u,ctc_render_rule_value_inputs);return false}var v=ctcAjax.rule[u],t='<div class="ctc-input-row clearfix" id="ctc_rule_row_'+v+'">'+l;if(false===r(ctcAjax.rule_val[u])){c.each(ctcAjax.rule_val[u],function(x,y){var w=ctc_decode_value(v,y);t+='<div class="ctc-parent-row clearfix" id="ctc_rule_row_'+v+"_"+x+'">'+l;t+='<div class="ctc-input-cell ctc-parent-value" id="ctc_'+x+"_parent_"+v+"_"+x+'">'+w.orig+"</div>"+l;t+='<div class="ctc-input-cell">'+l;t+='<div class="ctc-swatch ctc-specific" id="ctc_'+x+"_parent_"+v+"_"+x+'_swatch">'+ctcAjax.swatch_txt+"</div></div>"+l;t+='<div class="ctc-input-cell"><a href="#" class="ctc-selector-handle" id="ctc_selector_'+v+"_"+x+'">'+ctcAjax.selector_txt+"</a></div>"+l;t+='<div id="ctc_selector_'+v+"_"+x+'_container" class="ctc-selector-container clearfix">'+l;t+='<a href="#" id="ctc_selector_'+v+"_"+x+'_close" class="ctc-selector-handle" style="float:right">'+ctcAjax.close_txt+'</a><div id="ctc_status_val_qry_'+x+'"></div>'+l;t+='<div id="ctc_selector_'+v+"_"+x+'_rows"></div>'+l;t+="</div></div>"+l});t+="</div>"+l}c("#ctc_rule_value_inputs").html(t).find(".ctc-swatch").each(function(){f(this)})},ctc_render_selector_value_inputs=function(w){if(1==loading.val_qry){return false}var y,u,x=c("#ctc_rule_menu_selected").text().replace(/[^\w\-]/g,m),t,v="";if(0===loading.val_qry){loading.val_qry=1;y={rule:x};ctc_query_css("val_qry",w,ctc_render_selector_value_inputs,y);return false}if(false===r(ctcAjax.val_qry[w])){c.each(ctcAjax.val_qry[w],function(A,z){page_rule=A;c.each(z,function(C,B){v+='<h4 class="ctc-query-heading">'+C+"</h4>"+l;if(false===r(B)){c.each(B,function(D,E){ctcAjax.sel_val[D]=E;v+=j(D,A,w)})}})})}t="#ctc_selector_"+x+"_"+w+"_rows";c(t).html(v).find(".color-picker").each(function(){k(this)});c(t).find(".ctc-swatch").each(function(){f(this)})},ctc_query_css=function(v,u,y,w){var t={ctc_query_obj:v,ctc_query_key:u},x="#ctc_status_"+v+("val_qry"==v?"_"+u:"");if("object"===typeof w){c.each(w,function(z,A){t["ctc_query_"+z]=A})}c(".ctc-status-icon").remove();c(x).append('<span class="ctc-status-icon spinner"></span>');c(".spinner").show();t.action="ctc_query";t._wpnonce=c("#_wpnonce").val();c.post(ctcAjax.ajaxurl,t,function(z){loading[v]=2;c(".ctc-status-icon").removeClass("spinner");if(r(z)){c(".ctc-status-icon").addClass("failure")}else{c(".ctc-status-icon").addClass("success");n(z);if("function"===typeof y){y(u)}return false}},"json").fail(function(){loading[v]=0;c(".ctc-status-icon").removeClass("spinner");c(".ctc-status-icon").addClass("failure")});return false},ctc_save=function(y){var w={},z,v,t,u,A=c(y).attr("id"),x;if(r(b[A])){b[A]=0}b[A]++;c(y).prop("disabled",true);c(".ctc-status-icon").remove();c(y).parent(".ctc-textarea-button-cell, .ctc-button-cell").append('<span class="ctc-status-icon spinner"></span>');c(".spinner").show();if((z=c("#ctc_new_selectors"))&&"ctc_save_new_selectors"==c(y).attr("id")){w.ctc_new_selectors=z.val();if(v=c("#ctc_sel_ovrd_query_selected")){w.ctc_sel_ovrd_query=v.text()}}else{if((t=c("#ctc_child_imports"))&&"ctc_save_imports"==c(y).attr("id")){w.ctc_child_imports=t.val()}else{w=f(y)}}c("#ctc_sel_ovrd_selector_selected").find("#ctc_rewrite_selector").each(function(){x=c("#ctc_rewrite_selector").val(),origsel=c("#ctc_rewrite_selector_orig").val();if(r(x)||!x.toString().match(/\w/)){x=origsel}else{w.ctc_rewrite_selector=x}c(".ctc-rewrite-toggle").text(ctcAjax.rename_txt);c("#ctc_sel_ovrd_selector_selected").html(x)});w.action="ctc_update";w._wpnonce=c("#_wpnonce").val();c.post(ctcAjax.ajaxurl,w,function(B){console.log(B);c(y).prop("disabled",false);c(".ctc-status-icon").removeClass("spinner");if(r(B)){c(".ctc-status-icon").addClass("failure")}else{c(".ctc-status-icon").addClass("success");c("#ctc_new_selectors").val("");n(B);ctc_setup_menus();if(false===r(p)){ctc_set_selector(p,q);p=q=null}}return false},"json").fail(function(){c(y).prop("disabled",false);c(".ctc-status-icon").removeClass("spinner");c(".ctc-status-icon").addClass("failure")});return false},ctc_decode_value=function(v,t){t=("undefined"==typeof t?"":t);var u={orig:t};if(v.toString().match(/^border(\-(top|right|bottom|left))?$/)){var w=t.toString().split(/ +/);u.names=["_border_width","_border_style","_border_color"];u.values=[("undefined"==typeof w[0]?"":w[0]),("undefined"==typeof w[1]?"":w[1]),("undefined"==typeof w[2]?"":w[2])]}else{if(v.toString().match(/^background\-image/)){u.names=["_background_url","_background_origin","_background_color1","_background_color2"];u.values=["","","",""];if(false===(r(t))&&!(t.toString().match(/url/))){var w=t.toString().split(/:/);u.values[1]=("undefined"==typeof w[0]?"":w[0]);u.values[2]=("undefined"==typeof w[1]?"":w[1]);u.values[3]=("undefined"==typeof w[3]?"":w[3]);u.orig=[u.values[1],u.values[2],u.values[3]].join(" ")}else{u.values[0]=t}}else{u.names=[""];u.values=[t]}}return u},ctc_set_query=function(t){s=t;c("#ctc_sel_ovrd_query").val("");c("#ctc_sel_ovrd_query_selected").text(t);c("#ctc_sel_ovrd_selector").val("");c("#ctc_sel_ovrd_selector_selected").html("&nbsp;");c("#ctc_sel_ovrd_rule_inputs").html("");ctc_setup_selector_menu(t);f("#ctc_child_all_0_swatch");c("#ctc_new_selector_row").show()},ctc_set_selector=function(u,t){c("#ctc_sel_ovrd_selector").val("");c("#ctc_sel_ovrd_selector_selected").text(t);c("#ctc_sel_ovrd_qsid").val(u);h=u;if(1!=loading.sel_val){loading.sel_val=0}g(u);c(".ctc-rewrite-toggle").text(ctcAjax.rename_txt);c("#ctc_sel_ovrd_new_rule, #ctc_sel_ovrd_rule_header,#ctc_sel_ovrd_rule_inputs_container,#ctc_sel_ovrd_rule_inputs,.ctc-rewrite-toggle").show()},ctc_set_rule=function(u,t){c("#ctc_rule_menu").val("");c("#ctc_rule_menu_selected").text(t);if(1!=loading.rule_val){loading.rule_val=0}ctc_render_rule_value_inputs(u);c(".ctc-rewrite-toggle").text(ctcAjax.rename_txt);c("#ctc_rule_value_inputs,#ctc_input_row_rule_header").show()},ctc_setup_query_menu=function(){ctc_queries=a();c("#ctc_sel_ovrd_query").autocomplete({source:ctc_queries,minLength:0,selectFirst:true,autoFocus:true,select:function(u,t){ctc_set_query(t.item.value);return false},focus:function(t){t.preventDefault()}})},ctc_setup_selector_menu=function(t){ctc_selectors=o(t);c("#ctc_sel_ovrd_selector").autocomplete({source:ctc_selectors,selectFirst:true,autoFocus:true,select:function(v,u){ctc_set_selector(u.item.value,u.item.label);return false},focus:function(u){u.preventDefault()}})},ctc_setup_rule_menu=function(){ctc_rules=d();c("#ctc_rule_menu").autocomplete({source:ctc_rules,selectFirst:true,autoFocus:true,select:function(u,t){ctc_set_rule(t.item.value,t.item.label);return false},focus:function(t){t.preventDefault()}})},ctc_filtered_rules=function(w,u){var t=[],v=(r(ctcAjax.sel_val[h]))||(r(ctcAjax.sel_val[h].value));if(r(ctc_rules)){ctc_rules=d()}c.each(ctc_rules,function(x,A){var y=false,z=new RegExp(c.ui.autocomplete.escapeRegex(w.term),"i");if(z.test(A.label)){if(false===v){c.each(ctcAjax.sel_val[h].value,function(C,B){if(A.label==C.replace(/\d+/g,e)){y=true;return false}});if(y){return}}t.push(A)}});u(t)},ctc_setup_new_rule_menu=function(){c("#ctc_new_rule_menu").autocomplete({source:ctc_filtered_rules,selectFirst:true,autoFocus:true,select:function(u,t){u.preventDefault();var v=c(j(h,t.item.label.replace(/[^\w\-]/g,m),"ovrd"));c("#ctc_sel_ovrd_rule_inputs").append(v);c("#ctc_new_rule_menu").val("");if(r(ctcAjax.sel_val[h].value)){ctcAjax.sel_val[h]["value"]={}}ctcAjax.sel_val[h].value[t.item.label]={child:""};v.find('input[type="text"]').each(function(w,x){if(c(x).hasClass("color-picker")){k(x)}c(x).focus()});return false},focus:function(t){t.preventDefault()}})},ctc_setup_menus=function(){ctc_setup_query_menu();ctc_setup_selector_menu(s);ctc_setup_rule_menu();ctc_setup_new_rule_menu()},ctc_theme_exists=function(t,u){var v=false;c.each(ctcAjax.themes,function(w,x){c.each(x,function(y,z){if(y==t&&("parnt"==w||"new"==u)){v=true;return false}});if(v){return false}});return v},ctc_set_notice=function(t){var u="";if(false===r(t)){c.each(t,function(v,w){u+='<div class="'+v+'"><ul>'+l;c(w).each(function(x,y){u+="<li>"+y.toString()+"</li>"+l});u+="</ul></div>"})}c("#ctc_error_notice").html(u)},ctc_validate=function(){var w=/[^\w\-]/,u=c("#ctc_child_template").val().toString().replace(w).toLowerCase(),t=c("#ctc_theme_child").val().toString().replace(w).toLowerCase(),v=c("input[name=ctc_child_type]:checked").val(),x=[];if("new"==v){t=u}if(ctc_theme_exists(t,v)){x.push(ctcAjax.theme_exists_txt.toString().replace(/%s/,t))}if(""===t){x.push(ctcAjax.inval_theme_txt)}if(""===c("#ctc_child_name").val()){x.push(ctcAjax.inval_name_txt)}if(x.length){ctc_set_notice({error:x});return false}return true},ctc_set_theme_menu=function(u){var t=c("#ctc_theme_child").val();if(false===r(ctcAjax.themes.child[t])){c("#ctc_child_name").val(ctcAjax.themes.child[t].Name);c("#ctc_child_author").val(ctcAjax.themes.child[t].Author);c("#ctc_child_version").val(ctcAjax.themes.child[t].Version)}},fade_update_notice=function(){c(".updated, .error").slideUp("slow",function(){c(".updated").remove()})},ctc_focus_panel=function(u){var t=u+"_panel";c(".nav-tab").removeClass("nav-tab-active");c(".ctc-option-panel").removeClass("ctc-option-panel-active");c(".ctc-selector-container").hide();c(u).addClass("nav-tab-active");c(".ctc-option-panel-container").scrollTop(0);c(t).addClass("ctc-option-panel-active")},ctc_selector_edit=function(w){var t=c(w).attr("id").match(/_(\d+)$/)[1],v=ctcAjax.sel_val[t].query,u=ctcAjax.sel_val[t].selector,x="#query_selector_options";ctc_set_query(v);ctc_set_selector(t,u);ctc_focus_panel(x)},ctc_selector_input_toggle=function(u){var t;if(c("#ctc_rewrite_selector").length){t=c("#ctc_rewrite_selector_orig").val();c("#ctc_sel_ovrd_selector_selected").text(t);c(u).text(ctcAjax.rename_txt)}else{t=c("#ctc_sel_ovrd_selector_selected").text();c("#ctc_sel_ovrd_selector_selected").html('<input id="ctc_rewrite_selector" name="ctc_rewrite_selector" type="text" value="'+t+'" autocomplete="off" /><input id="ctc_rewrite_selector_orig" name="ctc_rewrite_selector_orig" type="hidden" value="'+t+'"/>');c(u).text(ctcAjax.cancel_txt)}};loading={rule:2,sel_ndx:2,val_qry:0,rule_val:0,sel_val:0},ctc_selectors=[],ctc_queries=[],ctc_rules=[];c(".color-picker").each(function(){k(this)});c(".ctc-option-panel-container").on("focus",".color-picker",function(){ctc_set_notice("");c(this).iris("toggle");c(".iris-picker").css({position:"absolute","z-index":10})});c(".ctc-option-panel-container").on("focus","input",function(){ctc_set_notice("");c(".color-picker").not(this).iris("hide")});c(".ctc-option-panel-container").on("change",".ctc-child-value, input[type=checkbox]",function(){f(this)});c(".ctc-option-panel-container").on("click",".ctc-selector-handle",function(u){u.preventDefault();ctc_set_notice("");var v=c(this).attr("id").toString().replace("_close",""),t=v.toString().match(/_(\d+)$/)[1];if(c("#"+v+"_container").is(":hidden")){if(1!=loading.val_qry){loading.val_qry=0}ctc_render_selector_value_inputs(t)}c("#"+v+"_container").fadeToggle("fast");c(".ctc-selector-container").not("#"+v+"_container").fadeOut("fast")});c(".nav-tab").on("click",function(t){t.preventDefault();ctc_set_notice("");var u="#"+c(this).attr("id");ctc_focus_panel(u)});c("#view_child_options,#view_parnt_options").on("click",function(w){ctc_set_notice("");var t=new Date().getTime(),v=c(this).attr("id").toString().match(/(child|parnt)/)[1],u=ctcAjax.theme_uri+"/"+ctcAjax[v]+"/style.css?"+t;c.get(u,function(x){c("#view_"+v+"_options_panel").text(x)}).fail(function(){c("#view_"+v+"_options_panel").text(ctcAjax.css_fail_txt)})});c("#ctc_load_form").on("submit",function(){return(ctc_validate()&&confirm(ctcAjax.load_txt))});c("#parent_child_options_panel").on("change","#ctc_theme_child",ctc_set_theme_menu);c(document).on("click",".ctc-save-input",function(t){ctc_save(this)});c(document).on("click",".ctc-selector-edit",function(t){ctc_selector_edit(this)});c(document).on("click",".ctc-rewrite-toggle",function(t){t.preventDefault();ctc_selector_input_toggle(this)});ctc_setup_menus();ctc_set_query(s);c("input[type=submit],input[type=button]").prop("disabled",false);setTimeout(fade_update_notice,6000)});
lang/chld_thm_cfg.pot CHANGED
@@ -1,10 +1,10 @@
1
- # Copyright (C) 2014 Lilaea Media LLC
2
  # This file is distributed under the same license as the Child Theme Configurator package.
3
  msgid ""
4
  msgstr ""
5
- "Project-Id-Version: Child Theme Configurator 1.1.9\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/child-theme-configurator\n"
7
- "POT-Creation-Date: 2014-01-30 13:44:59+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
@@ -16,11 +16,11 @@ msgstr ""
16
  msgid "Parent/Child"
17
  msgstr ""
18
 
19
- #: includes/class-ctc-ui.php:49 includes/class-ctc-ui.php:379
20
  msgid "Query/Selector"
21
  msgstr ""
22
 
23
- #: includes/class-ctc-ui.php:52 includes/class-ctc-ui.php:393
24
  msgid "Rule/Value"
25
  msgstr ""
26
 
@@ -64,79 +64,83 @@ msgstr ""
64
  msgid "Version"
65
  msgstr ""
66
 
67
- #: includes/class-ctc-ui.php:153
 
 
 
 
68
  msgid "Generate Child Theme"
69
  msgstr ""
70
 
71
- #: includes/class-ctc-ui.php:164 includes/class-ctc-ui.php:233
72
  msgid "Rule"
73
  msgstr ""
74
 
75
- #: includes/class-ctc-ui.php:177
76
  msgid "Value"
77
  msgstr ""
78
 
79
- #: includes/class-ctc-ui.php:180 includes/class-ctc-ui.php:218
80
  #: includes/class-ctc.php:94
81
  msgid "Sample"
82
  msgstr ""
83
 
84
- #: includes/class-ctc-ui.php:183 includes/class-ctc.php:96
85
  msgid "Selectors"
86
  msgstr ""
87
 
88
- #: includes/class-ctc-ui.php:194
89
  msgid "Query"
90
  msgstr ""
91
 
92
- #: includes/class-ctc-ui.php:205
93
  msgid "Selector"
94
  msgstr ""
95
 
96
- #: includes/class-ctc-ui.php:236
97
  msgid "Parent Value"
98
  msgstr ""
99
 
100
- #: includes/class-ctc-ui.php:239
101
  msgid "Child Value"
102
  msgstr ""
103
 
104
- #: includes/class-ctc-ui.php:245
105
  msgid "New Rule"
106
  msgstr ""
107
 
108
- #: includes/class-ctc-ui.php:255
109
  msgid "Order"
110
  msgstr ""
111
 
112
- #: includes/class-ctc-ui.php:262
113
  msgid "Raw CSS"
114
  msgstr ""
115
 
116
- #: includes/class-ctc-ui.php:281
117
  msgid "@import Statements"
118
  msgstr ""
119
 
120
- #: includes/class-ctc-ui.php:337
121
  msgid "Child Theme <strong>%s</strong> has been generated successfully."
122
  msgstr ""
123
 
124
- #: includes/class-ctc-ui.php:355
125
  msgid "Tutorial Video"
126
  msgstr ""
127
 
128
- #: includes/class-ctc-ui.php:356
129
  msgid ""
130
  "<iframe width=\"480\" height=\"270\" src=\"//www.youtube.com/embed/"
131
  "xL2HkWQxgOA?rel=0&modestbranding=1\" frameborder=\"0\" allowfullscreen></"
132
  "iframe>"
133
  msgstr ""
134
 
135
- #: includes/class-ctc-ui.php:362
136
  msgid "Start Here"
137
  msgstr ""
138
 
139
- #: includes/class-ctc-ui.php:363
140
  msgid ""
141
  "\n"
142
  "<p>The first step is to create a child theme and import your parent theme "
@@ -157,7 +161,7 @@ msgid ""
157
  "\t\t\t\t "
158
  msgstr ""
159
 
160
- #: includes/class-ctc-ui.php:380
161
  msgid ""
162
  "\n"
163
  "<p>There are two ways to identify and override parent styles. The Child "
@@ -190,7 +194,7 @@ msgid ""
190
  "\t\t\t\t "
191
  msgstr ""
192
 
193
- #: includes/class-ctc-ui.php:394
194
  msgid ""
195
  "\n"
196
  "<p>There are two ways to identify and override parent styles. The Child "
@@ -217,11 +221,11 @@ msgid ""
217
  "\t\t\t\t "
218
  msgstr ""
219
 
220
- #: includes/class-ctc-ui.php:406
221
  msgid "Add New Styles"
222
  msgstr ""
223
 
224
- #: includes/class-ctc-ui.php:407
225
  msgid ""
226
  "\n"
227
  "<p>If you wish to add additional rules to a given selector, first load the "
@@ -241,11 +245,11 @@ msgid ""
241
  "\t\t\t\t "
242
  msgstr ""
243
 
244
- #: includes/class-ctc-ui.php:417
245
  msgid "@imports"
246
  msgstr ""
247
 
248
- #: includes/class-ctc-ui.php:418
249
  msgid ""
250
  "\n"
251
  "<p>You can add additional stylesheets and web fonts by typing @import rules "
@@ -263,11 +267,11 @@ msgid ""
263
  "\t\t\t\t "
264
  msgstr ""
265
 
266
- #: includes/class-ctc-ui.php:431
267
  msgid "Preview and Activate"
268
  msgstr ""
269
 
270
- #: includes/class-ctc-ui.php:432
271
  msgid ""
272
  "\n"
273
  "<p>Click the View Child or Parent CSS tab to reference the stylesheet code. "
@@ -281,11 +285,11 @@ msgid ""
281
  "\t\t\t\t "
282
  msgstr ""
283
 
284
- #: includes/class-ctc-ui.php:443
285
  msgid "FAQs"
286
  msgstr ""
287
 
288
- #: includes/class-ctc-ui.php:444
289
  msgid ""
290
  "\n"
291
  "<h5 id=\"specific_color\">How do I change a specific color/font style/"
@@ -348,11 +352,11 @@ msgid ""
348
  " "
349
  msgstr ""
350
 
351
- #: includes/class-ctc-ui.php:473
352
  msgid "Glossary"
353
  msgstr ""
354
 
355
- #: includes/class-ctc-ui.php:474
356
  msgid ""
357
  "\n"
358
  "<h3 id=\"terms\">Glossary</h3>\n"
@@ -392,31 +396,31 @@ msgid ""
392
  "\t\t\t\t "
393
  msgstr ""
394
 
395
- #: includes/class-ctc-ui.php:495
396
  msgid "Contact us"
397
  msgstr ""
398
 
399
- #: includes/class-ctc-ui.php:496
400
  msgid "Plugin Website"
401
  msgstr ""
402
 
403
- #: includes/class-ctc-ui.php:497
404
  msgid "Donate"
405
  msgstr ""
406
 
407
- #: includes/class-ctc-ui.php:498
408
  msgid "Give Us 5 Stars"
409
  msgstr ""
410
 
411
- #: includes/class-ctc-ui.php:499
412
  msgid "WordPress Codex"
413
  msgstr ""
414
 
415
- #: includes/class-ctc-ui.php:500
416
  msgid "WordPress Answers"
417
  msgstr ""
418
 
419
- #. #-#-#-#-# pot.txt (Child Theme Configurator 1.1.9) #-#-#-#-#
420
  #. Plugin Name of the plugin/theme
421
  #: includes/class-ctc.php:43
422
  msgid "Child Theme Configurator"
@@ -471,54 +475,62 @@ msgid "Edit"
471
  msgstr ""
472
 
473
  #: includes/class-ctc.php:99
474
- msgid "The stylesheet cannot be displayed."
475
  msgstr ""
476
 
477
  #: includes/class-ctc.php:100
478
- msgid "(Child Only)"
479
  msgstr ""
480
 
481
  #: includes/class-ctc.php:101
 
 
 
 
 
 
 
 
482
  msgid "Please enter a valid Child Theme"
483
  msgstr ""
484
 
485
- #: includes/class-ctc.php:102 includes/class-ctc.php:221
486
  msgid "Please enter a valid Child Theme name"
487
  msgstr ""
488
 
489
- #: includes/class-ctc.php:103
490
  msgid "<strong>%s</strong> exists. Please enter a different Child Theme"
491
  msgstr ""
492
 
493
- #: includes/class-ctc.php:206
494
  msgid "%s does not exist. Please select a valid Parent Theme"
495
  msgstr ""
496
 
497
- #: includes/class-ctc.php:209
498
  msgid "Please select a valid Parent Theme"
499
  msgstr ""
500
 
501
- #: includes/class-ctc.php:214
502
  msgid ""
503
  "<strong>%s</strong> exists. Please enter a different Child Theme template "
504
  "name"
505
  msgstr ""
506
 
507
- #: includes/class-ctc.php:218
508
  msgid "Please enter a valid Child Theme template name"
509
  msgstr ""
510
 
511
- #: includes/class-ctc.php:224
512
  msgid "You do not have permission to configure child themes."
513
  msgstr ""
514
 
515
- #: includes/class-ctc.php:236
516
  msgid ""
517
  "Your theme directory is not writable. Please adjust permissions and try "
518
  "again."
519
  msgstr ""
520
 
521
- #: includes/class-ctc.php:243
522
  msgid "Child Theme %s was unchanged."
523
  msgstr ""
524
 
1
+ # Copyright (C) 2014 Child Theme Configurator
2
  # This file is distributed under the same license as the Child Theme Configurator package.
3
  msgid ""
4
  msgstr ""
5
+ "Project-Id-Version: Child Theme Configurator 1.2.2\n"
6
  "Report-Msgid-Bugs-To: http://wordpress.org/tag/child-theme-configurator\n"
7
+ "POT-Creation-Date: 2014-02-15 19:13:22+00:00\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
16
  msgid "Parent/Child"
17
  msgstr ""
18
 
19
+ #: includes/class-ctc-ui.php:49 includes/class-ctc-ui.php:390
20
  msgid "Query/Selector"
21
  msgstr ""
22
 
23
+ #: includes/class-ctc-ui.php:52 includes/class-ctc-ui.php:404
24
  msgid "Rule/Value"
25
  msgstr ""
26
 
64
  msgid "Version"
65
  msgstr ""
66
 
67
+ #: includes/class-ctc-ui.php:150
68
+ msgid "Backup Stylesheet"
69
+ msgstr ""
70
+
71
+ #: includes/class-ctc-ui.php:164
72
  msgid "Generate Child Theme"
73
  msgstr ""
74
 
75
+ #: includes/class-ctc-ui.php:175 includes/class-ctc-ui.php:244
76
  msgid "Rule"
77
  msgstr ""
78
 
79
+ #: includes/class-ctc-ui.php:188
80
  msgid "Value"
81
  msgstr ""
82
 
83
+ #: includes/class-ctc-ui.php:191 includes/class-ctc-ui.php:229
84
  #: includes/class-ctc.php:94
85
  msgid "Sample"
86
  msgstr ""
87
 
88
+ #: includes/class-ctc-ui.php:194 includes/class-ctc.php:96
89
  msgid "Selectors"
90
  msgstr ""
91
 
92
+ #: includes/class-ctc-ui.php:205
93
  msgid "Query"
94
  msgstr ""
95
 
96
+ #: includes/class-ctc-ui.php:216
97
  msgid "Selector"
98
  msgstr ""
99
 
100
+ #: includes/class-ctc-ui.php:247
101
  msgid "Parent Value"
102
  msgstr ""
103
 
104
+ #: includes/class-ctc-ui.php:250
105
  msgid "Child Value"
106
  msgstr ""
107
 
108
+ #: includes/class-ctc-ui.php:256
109
  msgid "New Rule"
110
  msgstr ""
111
 
112
+ #: includes/class-ctc-ui.php:266
113
  msgid "Order"
114
  msgstr ""
115
 
116
+ #: includes/class-ctc-ui.php:273
117
  msgid "Raw CSS"
118
  msgstr ""
119
 
120
+ #: includes/class-ctc-ui.php:292
121
  msgid "@import Statements"
122
  msgstr ""
123
 
124
+ #: includes/class-ctc-ui.php:348
125
  msgid "Child Theme <strong>%s</strong> has been generated successfully."
126
  msgstr ""
127
 
128
+ #: includes/class-ctc-ui.php:366
129
  msgid "Tutorial Video"
130
  msgstr ""
131
 
132
+ #: includes/class-ctc-ui.php:367
133
  msgid ""
134
  "<iframe width=\"480\" height=\"270\" src=\"//www.youtube.com/embed/"
135
  "xL2HkWQxgOA?rel=0&modestbranding=1\" frameborder=\"0\" allowfullscreen></"
136
  "iframe>"
137
  msgstr ""
138
 
139
+ #: includes/class-ctc-ui.php:373
140
  msgid "Start Here"
141
  msgstr ""
142
 
143
+ #: includes/class-ctc-ui.php:374
144
  msgid ""
145
  "\n"
146
  "<p>The first step is to create a child theme and import your parent theme "
161
  "\t\t\t\t "
162
  msgstr ""
163
 
164
+ #: includes/class-ctc-ui.php:391
165
  msgid ""
166
  "\n"
167
  "<p>There are two ways to identify and override parent styles. The Child "
194
  "\t\t\t\t "
195
  msgstr ""
196
 
197
+ #: includes/class-ctc-ui.php:405
198
  msgid ""
199
  "\n"
200
  "<p>There are two ways to identify and override parent styles. The Child "
221
  "\t\t\t\t "
222
  msgstr ""
223
 
224
+ #: includes/class-ctc-ui.php:417
225
  msgid "Add New Styles"
226
  msgstr ""
227
 
228
+ #: includes/class-ctc-ui.php:418
229
  msgid ""
230
  "\n"
231
  "<p>If you wish to add additional rules to a given selector, first load the "
245
  "\t\t\t\t "
246
  msgstr ""
247
 
248
+ #: includes/class-ctc-ui.php:428
249
  msgid "@imports"
250
  msgstr ""
251
 
252
+ #: includes/class-ctc-ui.php:429
253
  msgid ""
254
  "\n"
255
  "<p>You can add additional stylesheets and web fonts by typing @import rules "
267
  "\t\t\t\t "
268
  msgstr ""
269
 
270
+ #: includes/class-ctc-ui.php:442
271
  msgid "Preview and Activate"
272
  msgstr ""
273
 
274
+ #: includes/class-ctc-ui.php:443
275
  msgid ""
276
  "\n"
277
  "<p>Click the View Child or Parent CSS tab to reference the stylesheet code. "
285
  "\t\t\t\t "
286
  msgstr ""
287
 
288
+ #: includes/class-ctc-ui.php:454
289
  msgid "FAQs"
290
  msgstr ""
291
 
292
+ #: includes/class-ctc-ui.php:455
293
  msgid ""
294
  "\n"
295
  "<h5 id=\"specific_color\">How do I change a specific color/font style/"
352
  " "
353
  msgstr ""
354
 
355
+ #: includes/class-ctc-ui.php:484
356
  msgid "Glossary"
357
  msgstr ""
358
 
359
+ #: includes/class-ctc-ui.php:485
360
  msgid ""
361
  "\n"
362
  "<h3 id=\"terms\">Glossary</h3>\n"
396
  "\t\t\t\t "
397
  msgstr ""
398
 
399
+ #: includes/class-ctc-ui.php:506
400
  msgid "Contact us"
401
  msgstr ""
402
 
403
+ #: includes/class-ctc-ui.php:507
404
  msgid "Plugin Website"
405
  msgstr ""
406
 
407
+ #: includes/class-ctc-ui.php:508
408
  msgid "Donate"
409
  msgstr ""
410
 
411
+ #: includes/class-ctc-ui.php:509
412
  msgid "Give Us 5 Stars"
413
  msgstr ""
414
 
415
+ #: includes/class-ctc-ui.php:510
416
  msgid "WordPress Codex"
417
  msgstr ""
418
 
419
+ #: includes/class-ctc-ui.php:511
420
  msgid "WordPress Answers"
421
  msgstr ""
422
 
423
+ #. #-#-#-#-# ctc.pot.txt (Child Theme Configurator 1.2.2) #-#-#-#-#
424
  #. Plugin Name of the plugin/theme
425
  #: includes/class-ctc.php:43
426
  msgid "Child Theme Configurator"
475
  msgstr ""
476
 
477
  #: includes/class-ctc.php:99
478
+ msgid "Cancel"
479
  msgstr ""
480
 
481
  #: includes/class-ctc.php:100
482
+ msgid "Rename"
483
  msgstr ""
484
 
485
  #: includes/class-ctc.php:101
486
+ msgid "The stylesheet cannot be displayed."
487
+ msgstr ""
488
+
489
+ #: includes/class-ctc.php:102
490
+ msgid "(Child Only)"
491
+ msgstr ""
492
+
493
+ #: includes/class-ctc.php:103
494
  msgid "Please enter a valid Child Theme"
495
  msgstr ""
496
 
497
+ #: includes/class-ctc.php:104 includes/class-ctc.php:223
498
  msgid "Please enter a valid Child Theme name"
499
  msgstr ""
500
 
501
+ #: includes/class-ctc.php:105
502
  msgid "<strong>%s</strong> exists. Please enter a different Child Theme"
503
  msgstr ""
504
 
505
+ #: includes/class-ctc.php:208
506
  msgid "%s does not exist. Please select a valid Parent Theme"
507
  msgstr ""
508
 
509
+ #: includes/class-ctc.php:211
510
  msgid "Please select a valid Parent Theme"
511
  msgstr ""
512
 
513
+ #: includes/class-ctc.php:216
514
  msgid ""
515
  "<strong>%s</strong> exists. Please enter a different Child Theme template "
516
  "name"
517
  msgstr ""
518
 
519
+ #: includes/class-ctc.php:220
520
  msgid "Please enter a valid Child Theme template name"
521
  msgstr ""
522
 
523
+ #: includes/class-ctc.php:226
524
  msgid "You do not have permission to configure child themes."
525
  msgstr ""
526
 
527
+ #: includes/class-ctc.php:238
528
  msgid ""
529
  "Your theme directory is not writable. Please adjust permissions and try "
530
  "again."
531
  msgstr ""
532
 
533
+ #: includes/class-ctc.php:245
534
  msgid "Child Theme %s was unchanged."
535
  msgstr ""
536
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: child theme, custom theme, CSS, responsive design, CSS editor, theme generator
5
  Requires at least: 3.7
6
  Tested up to: 3.8
7
- Stable tag: 1.2.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -81,6 +81,10 @@ You can override a specific value globally using the Rule/Value tab. See "Rule/V
81
 
82
  You can add queries and selectors using the "Raw CSS" textarea on the Query/Selector tab. See "Query/Selector," below.
83
 
 
 
 
 
84
  = How do I remove a style from the Parent Theme? =
85
 
86
  You shouldn't really "remove" a style from the Parent. You can, however, set the rule to "inherit," "none," or zero (depending on the rule). This will negate the Parent value. Some experimentation may be necessary.
@@ -121,6 +125,9 @@ You can also create a secondary stylesheet that contains @font-face rules and im
121
 
122
  == Changelog ==
123
 
 
 
 
124
  = 1.2.1 =
125
  * Bugs fixed: "star hack" rules no longer throwing js error. Important flag now works on borders and gradients.
126
 
@@ -179,6 +186,8 @@ You can also create a secondary stylesheet that contains @font-face rules and im
179
  * Initial release.
180
 
181
  == Upgrade Notice ==
 
 
182
 
183
  = 1.2.0 =
184
  * New features: Link to Query/Selector tab from specific Rule/Value selector, new rule focus on adding new rule. Bugs fixed: clear Query/Selector inputs when loaded selector is empty, use latest min.js script.
4
  Tags: child theme, custom theme, CSS, responsive design, CSS editor, theme generator
5
  Requires at least: 3.7
6
  Tested up to: 3.8
7
+ Stable tag: 1.2.2
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
81
 
82
  You can add queries and selectors using the "Raw CSS" textarea on the Query/Selector tab. See "Query/Selector," below.
83
 
84
+ = How do I use background images from the Parent Theme? =
85
+
86
+ Use a relative path in the Child Theme value, e.g., 'url(../parent_theme/images/background.png)', where 'parent_theme' is the parent theme's slug.
87
+
88
  = How do I remove a style from the Parent Theme? =
89
 
90
  You shouldn't really "remove" a style from the Parent. You can, however, set the rule to "inherit," "none," or zero (depending on the rule). This will negate the Parent value. Some experimentation may be necessary.
125
 
126
  == Changelog ==
127
 
128
+ = 1.2.2 =
129
+ * New Features: You can now rename selectors in place from the Query/Selector panel. Made stylesheet backup optional. Bugs fixed: Incorrect parsing of background position when '0', fixed type error when background image url value is removed.
130
+
131
  = 1.2.1 =
132
  * Bugs fixed: "star hack" rules no longer throwing js error. Important flag now works on borders and gradients.
133
 
186
  * Initial release.
187
 
188
  == Upgrade Notice ==
189
+ = 1.2.2 =
190
+ * New features and bugs fixed.
191
 
192
  = 1.2.0 =
193
  * New features: Link to Query/Selector tab from specific Rule/Value selector, new rule focus on adding new rule. Bugs fixed: clear Query/Selector inputs when loaded selector is empty, use latest min.js script.