Options Framework - Version 1.4

Version Description

  • Add missing sanitization to typography color (@weplantmedia)
  • New colorpicker (props @mattweibe for getting this in WordPress core)
  • Farsi translations (@vahidd.com)
  • Added password option type (props @neojp)
  • Allow ids to passed to tabs (props @themeblvd)
  • Added optionsframework_after_validate hook (h/t @vanpop and @pryley)
Download this release

Release Info

Developer downstairsdev
Plugin Icon wp plugin Options Framework
Version 1.4
Comparing to
See all releases

Code changes from version 1.3 to 1.4

css/color-picker.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .wp-color-picker{width:80px}.wp-picker-container .hidden{display:none}.wp-color-result{background-color:#f9f9f9;border:1px solid #bbb;border-radius:2px;cursor:pointer;display:inline-block;height:22px;margin:0 6px 6px 0;position:relative;top:1px;user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;vertical-align:bottom;display:inline-block;padding-left:30px}.wp-color-result:after{background:#f3f3f3;background-image:-webkit-gradient(linear,left top,left bottom,from(#fefefe),to(#f4f4f4));background-image:-webkit-linear-gradient(top,#fefefe,#f4f4f4);background-image:-moz-linear-gradient(top,#fefefe,#f4f4f4);background-image:-o-linear-gradient(top,#fefefe,#f4f4f4);background-image:linear-gradient(to bottom,#fefefe,#f4f4f4);color:#333;text-shadow:0 1px 0 #fff;border-radius:0 1px 1px 0;border-left:1px solid #bbb;content:attr(title);display:block;font-size:11px;line-height:22px;padding:0 6px;position:relative;right:0;text-align:center;top:0}.wp-color-result:hover{border-color:#aaa;box-shadow:0 1px 1px rgba(0,0,0,0.1);-moz-box-shadow:0 1px 1px rgba(0,0,0,0.1);-ms-box-shadow:0 1px 1px rgba(0,0,0,0.1);-o-box-shadow:0 1px 1px rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px rgba(0,0,0,0.1)}.wp-color-result:hover:after{color:#222;border-color:#aaa;border-left:1px solid #999}.wp-color-result.wp-picker-open{top:0}.wp-color-result.wp-picker-open:after{content:attr(data-current)}.wp-picker-container,.wp-picker-container:active{display:inline-block;outline:0}.wp-color-result:focus{border-color:#888;-moz-box-shadow:0 1px 2px rgba(0,0,0,0.2);-ms-box-shadow:0 1px 2px rgba(0,0,0,0.2);-o-box-shadow:0 1px 2px rgba(0,0,0,0.2);-webkit-box-shadow:0 1px 2px rgba(0,0,0,0.2);box-shadow:0 1px 2px rgba(0,0,0,0.2)}.wp-color-result:focus:after{border-color:#888}.wp-picker-open+.wp-picker-input-wrap{display:inline-block;vertical-align:top}.wp-picker-container .button{margin-left:6px}.wp-picker-container .iris-square-slider .ui-slider-handle:focus{background-color:#555}.wp-picker-container .iris-picker{border-color:#dfdfdf;margin-top:6px}input[type="text"].iris-error{background-color:#ffebe8;border-color:#c00;color:#000}
css/colorpicker.css DELETED
@@ -1,177 +0,0 @@
1
- .colorpicker {
2
- width: 356px;
3
- height: 176px;
4
- overflow: hidden;
5
- position: absolute;
6
- background: url(../images/colorpicker/colorpicker_background.png);
7
- font-family: Arial, Helvetica, sans-serif;
8
- display: none;
9
- }
10
- .colorpicker_color {
11
- width: 150px;
12
- height: 150px;
13
- left: 14px;
14
- top: 13px;
15
- position: absolute;
16
- background: #f00;
17
- overflow: hidden;
18
- cursor: crosshair;
19
- }
20
- .colorpicker_color div {
21
- position: absolute;
22
- top: 0;
23
- left: 0;
24
- width: 150px;
25
- height: 150px;
26
- background: url(../images/colorpicker/colorpicker_overlay.png);
27
- }
28
- .colorpicker_color div div {
29
- position: absolute;
30
- top: 0;
31
- left: 0;
32
- width: 11px;
33
- height: 11px;
34
- overflow: hidden;
35
- background: url(../images/colorpicker/colorpicker_select.gif);
36
- margin: -5px 0 0 -5px;
37
- }
38
- .colorpicker_hue {
39
- position: absolute;
40
- top: 13px;
41
- left: 171px;
42
- width: 35px;
43
- height: 150px;
44
- cursor: n-resize;
45
- }
46
- .colorpicker_hue div {
47
- position: absolute;
48
- width: 35px;
49
- height: 9px;
50
- overflow: hidden;
51
- background: url(../images/colorpicker/colorpicker_indic.gif) left top;
52
- margin: -4px 0 0 0;
53
- left: 0px;
54
- }
55
- .colorpicker_new_color {
56
- position: absolute;
57
- width: 60px;
58
- height: 30px;
59
- left: 213px;
60
- top: 13px;
61
- background: #f00;
62
- }
63
- .colorpicker_current_color {
64
- position: absolute;
65
- width: 60px;
66
- height: 30px;
67
- left: 283px;
68
- top: 13px;
69
- background: #f00;
70
- }
71
- .colorpicker input {
72
- background-color: transparent;
73
- border: 1px solid transparent;
74
- position: absolute;
75
- font-size: 10px;
76
- font-family: Arial, Helvetica, sans-serif;
77
- color: #898989;
78
- top: 4px;
79
- right: 11px;
80
- text-align: right;
81
- margin: 0;
82
- padding: 0;
83
- height: 12px;
84
- }
85
- .colorpicker_hex {
86
- position: absolute;
87
- width: 72px;
88
- height: 22px;
89
- background: url(../images/colorpicker/colorpicker_hex.png) top;
90
- left: 212px;
91
- top: 142px;
92
- }
93
- .colorpicker_hex input {
94
- right: 6px;
95
- }
96
- .colorpicker_field {
97
- height: 22px;
98
- width: 62px;
99
- background-position: top;
100
- position: absolute;
101
- }
102
- .colorpicker_field span {
103
- position: absolute;
104
- width: 12px;
105
- height: 22px;
106
- overflow: hidden;
107
- top: 0;
108
- right: 0;
109
- cursor: n-resize;
110
- }
111
- .colorpicker_rgb_r {
112
- background-image: url(../images/colorpicker/colorpicker_rgb_r.png);
113
- top: 52px;
114
- left: 212px;
115
- }
116
- .colorpicker_rgb_g {
117
- background-image: url(../images/colorpicker/colorpicker_rgb_g.png);
118
- top: 82px;
119
- left: 212px;
120
- }
121
- .colorpicker_rgb_b {
122
- background-image: url(../images/colorpicker/colorpicker_rgb_b.png);
123
- top: 112px;
124
- left: 212px;
125
- }
126
- .colorpicker_hsb_h {
127
- background-image: url(../images/colorpicker/colorpicker_hsb_h.png);
128
- top: 52px;
129
- left: 282px;
130
- }
131
- .colorpicker_hsb_s {
132
- background-image: url(../images/colorpicker/colorpicker_hsb_s.png);
133
- top: 82px;
134
- left: 282px;
135
- }
136
- .colorpicker_hsb_b {
137
- background-image: url(../images/colorpicker/colorpicker_hsb_b.png);
138
- top: 112px;
139
- left: 282px;
140
- }
141
- .colorpicker_submit {
142
- position: absolute;
143
- width: 22px;
144
- height: 22px;
145
- background: url(../images/colorpicker/colorpicker_submit.png) top;
146
- left: 322px;
147
- top: 142px;
148
- overflow: hidden;
149
- }
150
- .colorpicker_focus {
151
- background-position: center;
152
- }
153
- .colorpicker_hex.colorpicker_focus {
154
- background-position: bottom;
155
- }
156
- .colorpicker_submit.colorpicker_focus {
157
- background-position: bottom;
158
- }
159
- .colorpicker_slider {
160
- background-position: bottom;
161
- }
162
-
163
- .colorSelector {
164
- position: relative;
165
- width: 27px;
166
- height: 27px;
167
- background: url(../images/colorpicker/select.png);
168
- float:left;
169
- }
170
- .colorSelector div {
171
- position: absolute;
172
- top: 4px;
173
- left: 3px;
174
- width: 21px;
175
- height: 19px;
176
- background: url(../images/colorpicker/select.png) center;
177
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
css/optionsframework.css CHANGED
@@ -1,6 +1,4 @@
1
- /*-------------------------------------------------------------------------------------------*/
2
  /* Options Framework Admin Styles */
3
- /*-------------------------------------------------------------------------------------------*/
4
 
5
  .updated {
6
  max-width:764px;
@@ -50,11 +48,7 @@
50
  #optionsframework .section-checkbox .explain {
51
  max-width:94%;
52
  }
53
- #optionsframework .section-color .controls {
54
- min-width:125px;
55
- width:125px
56
- }
57
- #optionsframework .controls input, #optionsframework .controls select, #optionsframework .controls textarea {
58
  margin-bottom:10px;
59
  width:100%;
60
  }
@@ -70,15 +64,16 @@
70
  float:left;
71
  clear:both;
72
  }
73
- #optionsframework .controls .of-color {
74
- float:left;
75
- width: 80px;
76
- margin-left:5px;
77
- margin-right:5px;
 
 
78
  }
79
  #optionsframework .controls .of-typography-size {
80
  width:80px;
81
- margin-left:5px;
82
  float:left
83
  }
84
  #optionsframework .controls .of-typography-unit {
@@ -116,8 +111,8 @@
116
  margin-right:5px;
117
  float:left
118
  }
119
- #optionsframework div.section-background .controls input.upload {
120
- width:47%;
121
  }
122
  #optionsframework .controls .of-radio-img-img {
123
  border:3px solid #f9f9f9;
@@ -173,10 +168,8 @@
173
  }
174
  #optionsframework .controls input.upload_button {
175
  float:right;
176
- width:45px;
177
  border-color:#BBBBBB;
178
  cursor:pointer;
179
- height:16px;
180
  }
181
  #optionsframework .controls input.upload_button:hover {
182
  border-color:#666666;
@@ -234,10 +227,7 @@
234
  #optionsframework .button-primary {
235
  float:right;
236
  }
237
-
238
- /* Bottom Section */
239
-
240
- #optionsframework .section:before, #optionsframework .section:after {
241
  content: "";
242
  display: table;
243
  }
 
1
  /* Options Framework Admin Styles */
 
2
 
3
  .updated {
4
  max-width:764px;
48
  #optionsframework .section-checkbox .explain {
49
  max-width:94%;
50
  }
51
+ #optionsframework .controls select, #optionsframework .controls textarea {
 
 
 
 
52
  margin-bottom:10px;
53
  width:100%;
54
  }
64
  float:left;
65
  clear:both;
66
  }
67
+ #optionsframework .section-typography .controls {
68
+ float:none;
69
+ width:auto;
70
+ }
71
+ #optionsframework .section-typography .explain {
72
+ float:none;
73
+ width:auto;
74
  }
75
  #optionsframework .controls .of-typography-size {
76
  width:80px;
 
77
  float:left
78
  }
79
  #optionsframework .controls .of-typography-unit {
111
  margin-right:5px;
112
  float:left
113
  }
114
+ #optionsframework .section-background .wp-picker-container {
115
+ margin-bottom:10px;
116
  }
117
  #optionsframework .controls .of-radio-img-img {
118
  border:3px solid #f9f9f9;
168
  }
169
  #optionsframework .controls input.upload_button {
170
  float:right;
 
171
  border-color:#BBBBBB;
172
  cursor:pointer;
 
173
  }
174
  #optionsframework .controls input.upload_button:hover {
175
  border-color:#666666;
227
  #optionsframework .button-primary {
228
  float:right;
229
  }
230
+ #optionsframework .section:after {
 
 
 
231
  content: "";
232
  display: table;
233
  }
images/colorpicker/blank.gif DELETED
Binary file
images/colorpicker/colorpicker_background.png DELETED
Binary file
images/colorpicker/colorpicker_hex.png DELETED
Binary file
images/colorpicker/colorpicker_hsb_b.png DELETED
Binary file
images/colorpicker/colorpicker_hsb_h.png DELETED
Binary file
images/colorpicker/colorpicker_hsb_s.png DELETED
Binary file
images/colorpicker/colorpicker_indic.gif DELETED
Binary file
images/colorpicker/colorpicker_overlay.png DELETED
Binary file
images/colorpicker/colorpicker_rgb_b.png DELETED
Binary file
images/colorpicker/colorpicker_rgb_g.png DELETED
Binary file
images/colorpicker/colorpicker_rgb_r.png DELETED
Binary file
images/colorpicker/colorpicker_select.gif DELETED
Binary file
images/colorpicker/colorpicker_submit.png DELETED
Binary file
images/colorpicker/select.png DELETED
Binary file
js/color-picker.min.js ADDED
@@ -0,0 +1 @@
 
1
+ (function(f,e){var a='<a tabindex="0" class="wp-color-result" />',c='<div class="wp-picker-holder" />',b='<div class="wp-picker-container" />',g='<input type="button" class="button button-small hidden" />';var d={options:{defaultColor:false,change:false,clear:false,hide:true,palettes:true},_create:function(){if(f.browser.msie&&parseInt(f.browser.version,10)<8){return}var h=this;var i=h.element;f.extend(h.options,i.data());h.initialValue=i.val();i.addClass("wp-color-picker").hide().wrap(b);h.wrap=i.parent();h.toggler=f(a).insertBefore(i).css({backgroundColor:h.initialValue}).attr("title",wpColorPickerL10n.pick).attr("data-current",wpColorPickerL10n.current);h.pickerContainer=f(c).insertAfter(i);h.button=f(g);if(h.options.defaultColor){h.button.addClass("wp-picker-default").val(wpColorPickerL10n.defaultString)}else{h.button.addClass("wp-picker-clear").val(wpColorPickerL10n.clear)}i.wrap('<span class="wp-picker-input-wrap" />').after(h.button);i.iris({target:h.pickerContainer,hide:true,width:255,mode:"hsv",palettes:h.options.palettes,change:function(j,k){h.toggler.css({backgroundColor:k.color.toString()});if(f.isFunction(h.options.change)){h.options.change.call(this,j,k)}}});i.val(h.initialValue);h._addListeners();if(!h.options.hide){h.toggler.click()}},_addListeners:function(){var h=this;h.toggler.click(function(i){i.stopPropagation();h.element.toggle().iris("toggle");h.button.toggleClass("hidden");h.toggler.toggleClass("wp-picker-open");if(h.toggler.hasClass("wp-picker-open")){f("body").on("click",{wrap:h.wrap,toggler:h.toggler},h._bodyListener)}else{f("body").off("click",h._bodyListener)}});h.element.change(function(j){var i=f(this),k=i.val();if(k===""||k==="#"){h.toggler.css("backgroundColor","");if(f.isFunction(h.options.clear)){h.options.clear.call(this,j)}}});h.toggler.on("keyup",function(i){if(i.keyCode===13||i.keyCode===32){i.preventDefault();h.toggler.trigger("click").next().focus()}});h.button.click(function(j){var i=f(this);if(i.hasClass("wp-picker-clear")){h.element.val("");h.toggler.css("backgroundColor","");if(f.isFunction(h.options.clear)){h.options.clear.call(this,j)}}else{if(i.hasClass("wp-picker-default")){h.element.val(h.options.defaultColor).change()}}})},_bodyListener:function(h){if(!h.data.wrap.find(h.target).length){h.data.toggler.click()}},color:function(h){if(h===e){return this.element.iris("option","color")}this.element.iris("option","color",h)},defaultColor:function(h){if(h===e){return this.options.defaultColor}this.options.defaultColor=h}};f.widget("wp.wpColorPicker",d)}(jQuery));
js/colorpicker.js DELETED
@@ -1,455 +0,0 @@
1
- /**
2
- *
3
- * Color picker
4
- * Author: Stefan Petre www.eyecon.ro
5
- *
6
- * Dependencies: jQuery
7
- *
8
- */
9
- (function ($) {
10
- var ColorPicker = function () {
11
- var
12
- ids = {},
13
- inAction,
14
- charMin = 65,
15
- visible,
16
- tpl = '<div class="colorpicker"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>',
17
- defaults = {
18
- eventName: 'click',
19
- onShow: function () {},
20
- onBeforeShow: function(){},
21
- onHide: function () {},
22
- onChange: function () {},
23
- onSubmit: function () {},
24
- color: 'ff0000',
25
- livePreview: true,
26
- flat: false
27
- },
28
- fillRGBFields = function (hsb, cal) {
29
- var rgb = HSBToRGB(hsb);
30
- $(cal).data('colorpicker').fields
31
- .eq(1).val(rgb.r).end()
32
- .eq(2).val(rgb.g).end()
33
- .eq(3).val(rgb.b).end();
34
- },
35
- fillHSBFields = function (hsb, cal) {
36
- $(cal).data('colorpicker').fields
37
- .eq(4).val(hsb.h).end()
38
- .eq(5).val(hsb.s).end()
39
- .eq(6).val(hsb.b).end();
40
- },
41
- fillHexFields = function (hsb, cal) {
42
- $(cal).data('colorpicker').fields
43
- .eq(0).val(HSBToHex(hsb)).end();
44
- },
45
- setSelector = function (hsb, cal) {
46
- $(cal).data('colorpicker').selector.css('backgroundColor', '#' + HSBToHex({h: hsb.h, s: 100, b: 100}));
47
- $(cal).data('colorpicker').selectorIndic.css({
48
- left: parseInt(150 * hsb.s/100, 10),
49
- top: parseInt(150 * (100-hsb.b)/100, 10)
50
- });
51
- },
52
- setHue = function (hsb, cal) {
53
- $(cal).data('colorpicker').hue.css('top', parseInt(150 - 150 * hsb.h/360, 10));
54
- },
55
- setCurrentColor = function (hsb, cal) {
56
- $(cal).data('colorpicker').currentColor.css('backgroundColor', '#' + HSBToHex(hsb));
57
- },
58
- setNewColor = function (hsb, cal) {
59
- $(cal).data('colorpicker').newColor.css('backgroundColor', '#' + HSBToHex(hsb));
60
- },
61
- keyDown = function (ev) {
62
- var pressedKey = ev.charCode || ev.keyCode || -1;
63
- if ((pressedKey > charMin && pressedKey <= 90) || pressedKey == 32) {
64
- return false;
65
- }
66
- var cal = $(this).parent().parent();
67
- if (cal.data('colorpicker').livePreview === true) {
68
- change.apply(this);
69
- }
70
- },
71
- change = function (ev) {
72
- var cal = $(this).parent().parent(), col;
73
- if (this.parentNode.className.indexOf('_hex') > 0) {
74
- cal.data('colorpicker').color = col = HexToHSB(fixHex(this.value));
75
- } else if (this.parentNode.className.indexOf('_hsb') > 0) {
76
- cal.data('colorpicker').color = col = fixHSB({
77
- h: parseInt(cal.data('colorpicker').fields.eq(4).val(), 10),
78
- s: parseInt(cal.data('colorpicker').fields.eq(5).val(), 10),
79
- b: parseInt(cal.data('colorpicker').fields.eq(6).val(), 10)
80
- });
81
- } else {
82
- cal.data('colorpicker').color = col = RGBToHSB(fixRGB({
83
- r: parseInt(cal.data('colorpicker').fields.eq(1).val(), 10),
84
- g: parseInt(cal.data('colorpicker').fields.eq(2).val(), 10),
85
- b: parseInt(cal.data('colorpicker').fields.eq(3).val(), 10)
86
- }));
87
- }
88
- if (ev) {
89
- fillRGBFields(col, cal.get(0));
90
- fillHexFields(col, cal.get(0));
91
- fillHSBFields(col, cal.get(0));
92
- }
93
- setSelector(col, cal.get(0));
94
- setHue(col, cal.get(0));
95
- setNewColor(col, cal.get(0));
96
- cal.data('colorpicker').onChange.apply(cal, [col, HSBToHex(col), HSBToRGB(col)]);
97
- },
98
- blur = function (ev) {
99
- var cal = $(this).parent().parent();
100
- cal.data('colorpicker').fields.parent().removeClass('colorpicker_focus')
101
- },
102
- focus = function () {
103
- charMin = this.parentNode.className.indexOf('_hex') > 0 ? 70 : 65;
104
- $(this).parent().parent().data('colorpicker').fields.parent().removeClass('colorpicker_focus');
105
- $(this).parent().addClass('colorpicker_focus');
106
- },
107
- downIncrement = function (ev) {
108
- var field = $(this).parent().find('input').focus();
109
- var current = {
110
- el: $(this).parent().addClass('colorpicker_slider'),
111
- max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
112
- y: ev.pageY,
113
- field: field,
114
- val: parseInt(field.val(), 10),
115
- preview: $(this).parent().parent().data('colorpicker').livePreview
116
- };
117
- $(document).bind('mouseup', current, upIncrement);
118
- $(document).bind('mousemove', current, moveIncrement);
119
- },
120
- moveIncrement = function (ev) {
121
- ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val + ev.pageY - ev.data.y, 10))));
122
- if (ev.data.preview) {
123
- change.apply(ev.data.field.get(0), [true]);
124
- }
125
- return false;
126
- },
127
- upIncrement = function (ev) {
128
- change.apply(ev.data.field.get(0), [true]);
129
- ev.data.el.removeClass('colorpicker_slider').find('input').focus();
130
- $(document).unbind('mouseup', upIncrement);
131
- $(document).unbind('mousemove', moveIncrement);
132
- return false;
133
- },
134
- downHue = function (ev) {
135
- var current = {
136
- cal: $(this).parent(),
137
- y: $(this).offset().top
138
- };
139
- current.preview = current.cal.data('colorpicker').livePreview;
140
- $(document).bind('mouseup', current, upHue);
141
- $(document).bind('mousemove', current, moveHue);
142
- },
143
- moveHue = function (ev) {
144
- change.apply(
145
- ev.data.cal.data('colorpicker')
146
- .fields
147
- .eq(4)
148
- .val(parseInt(360*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.y))))/150, 10))
149
- .get(0),
150
- [ev.data.preview]
151
- );
152
- return false;
153
- },
154
- upHue = function (ev) {
155
- fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
156
- fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
157
- $(document).unbind('mouseup', upHue);
158
- $(document).unbind('mousemove', moveHue);
159
- return false;
160
- },
161
- downSelector = function (ev) {
162
- var current = {
163
- cal: $(this).parent(),
164
- pos: $(this).offset()
165
- };
166
- current.preview = current.cal.data('colorpicker').livePreview;
167
- $(document).bind('mouseup', current, upSelector);
168
- $(document).bind('mousemove', current, moveSelector);
169
- },
170
- moveSelector = function (ev) {
171
- change.apply(
172
- ev.data.cal.data('colorpicker')
173
- .fields
174
- .eq(6)
175
- .val(parseInt(100*(150 - Math.max(0,Math.min(150,(ev.pageY - ev.data.pos.top))))/150, 10))
176
- .end()
177
- .eq(5)
178
- .val(parseInt(100*(Math.max(0,Math.min(150,(ev.pageX - ev.data.pos.left))))/150, 10))
179
- .get(0),
180
- [ev.data.preview]
181
- );
182
- return false;
183
- },
184
- upSelector = function (ev) {
185
- fillRGBFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
186
- fillHexFields(ev.data.cal.data('colorpicker').color, ev.data.cal.get(0));
187
- $(document).unbind('mouseup', upSelector);
188
- $(document).unbind('mousemove', moveSelector);
189
- return false;
190
- },
191
- enterSubmit = function (ev) {
192
- $(this).addClass('colorpicker_focus');
193
- },
194
- leaveSubmit = function (ev) {
195
- $(this).removeClass('colorpicker_focus');
196
- },
197
- clickSubmit = function (ev) {
198
- var cal = $(this).parent();
199
- var col = cal.data('colorpicker').color;
200
- cal.data('colorpicker').origColor = col;
201
- setCurrentColor(col, cal.get(0));
202
- cal.data('colorpicker').onSubmit(col, HSBToHex(col), HSBToRGB(col));
203
- cal.hide();
204
- },
205
- show = function (ev) {
206
- var cal = $('#' + $(this).data('colorpickerId'));
207
- cal.data('colorpicker').onBeforeShow.apply(this, [cal.get(0)]);
208
- var pos = $(this).offset();
209
- var viewPort = getViewport();
210
- var top = pos.top + this.offsetHeight;
211
- var left = pos.left;
212
- if (top + 176 > viewPort.t + viewPort.h) {
213
- top -= this.offsetHeight + 176;
214
- } else {
215
- top += 5;
216
- }
217
- if (left + 356 > viewPort.l + viewPort.w) {
218
- left -= 356;
219
- }
220
- cal.css({left: left + 'px', top: top + 'px'});
221
- if (cal.data('colorpicker').onShow.apply(this, [cal.get(0)]) != false) {
222
- cal.show();
223
- }
224
- $(document).bind('mousedown', {cal: cal}, hide);
225
- return false;
226
- },
227
- hide = function (ev) {
228
- if (!isChildOf(ev.data.cal.get(0), ev.target, ev.data.cal.get(0))) {
229
- if (ev.data.cal.data('colorpicker').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
230
- ev.data.cal.hide();
231
- }
232
- $(document).unbind('mousedown', hide);
233
- }
234
- },
235
- isChildOf = function(parentEl, el, container) {
236
- if (parentEl == el) {
237
- return true;
238
- }
239
- if (parentEl.contains) {
240
- return parentEl.contains(el);
241
- }
242
- if ( parentEl.compareDocumentPosition ) {
243
- return !!(parentEl.compareDocumentPosition(el) & 16);
244
- }
245
- var prEl = el.parentNode;
246
- while(prEl && prEl != container) {
247
- if (prEl == parentEl)
248
- return true;
249
- prEl = prEl.parentNode;
250
- }
251
- return false;
252
- },
253
- getViewport = function () {
254
- var m = document.compatMode == 'CSS1Compat';
255
- return {
256
- l : window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
257
- t : window.pageYOffset || (m ? document.documentElement.scrollTop : document.body.scrollTop),
258
- w : window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth),
259
- h : window.innerHeight || (m ? document.documentElement.clientHeight : document.body.clientHeight)
260
- };
261
- },
262
- fixHSB = function (hsb) {
263
- return {
264
- h: Math.min(360, Math.max(0, hsb.h)),
265
- s: Math.min(100, Math.max(0, hsb.s)),
266
- b: Math.min(100, Math.max(0, hsb.b))
267
- };
268
- },
269
- fixRGB = function (rgb) {
270
- return {
271
- r: Math.min(255, Math.max(0, rgb.r)),
272
- g: Math.min(255, Math.max(0, rgb.g)),
273
- b: Math.min(255, Math.max(0, rgb.b))
274
- };
275
- },
276
- fixHex = function (hex) {
277
- var len = 6 - hex.length;
278
- if (len > 0) {
279
- var o = [];
280
- for (var i=0; i<len; i++) {
281
- o.push('0');
282
- }
283
- o.push(hex);
284
- hex = o.join('');
285
- }
286
- return hex;
287
- },
288
- HexToRGB = function (hex) {
289
- var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
290
- return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
291
- },
292
- HexToHSB = function (hex) {
293
- return RGBToHSB(HexToRGB(hex));
294
- },
295
- RGBToHSB = function (rgb) {
296
- var hsb = {};
297
- hsb.b = Math.max(Math.max(rgb.r,rgb.g),rgb.b);
298
- hsb.s = (hsb.b <= 0) ? 0 : Math.round(100*(hsb.b - Math.min(Math.min(rgb.r,rgb.g),rgb.b))/hsb.b);
299
- hsb.b = Math.round((hsb.b /255)*100);
300
- if((rgb.r==rgb.g) && (rgb.g==rgb.b)) hsb.h = 0;
301
- else if(rgb.r>=rgb.g && rgb.g>=rgb.b) hsb.h = 60*(rgb.g-rgb.b)/(rgb.r-rgb.b);
302
- else if(rgb.g>=rgb.r && rgb.r>=rgb.b) hsb.h = 60 + 60*(rgb.g-rgb.r)/(rgb.g-rgb.b);
303
- else if(rgb.g>=rgb.b && rgb.b>=rgb.r) hsb.h = 120 + 60*(rgb.b-rgb.r)/(rgb.g-rgb.r);
304
- else if(rgb.b>=rgb.g && rgb.g>=rgb.r) hsb.h = 180 + 60*(rgb.b-rgb.g)/(rgb.b-rgb.r);
305
- else if(rgb.b>=rgb.r && rgb.r>=rgb.g) hsb.h = 240 + 60*(rgb.r-rgb.g)/(rgb.b-rgb.g);
306
- else if(rgb.r>=rgb.b && rgb.b>=rgb.g) hsb.h = 300 + 60*(rgb.r-rgb.b)/(rgb.r-rgb.g);
307
- else hsb.h = 0;
308
- hsb.h = Math.round(hsb.h);
309
- return hsb;
310
- },
311
- HSBToRGB = function (hsb) {
312
- var rgb = {};
313
- var h = Math.round(hsb.h);
314
- var s = Math.round(hsb.s*255/100);
315
- var v = Math.round(hsb.b*255/100);
316
- if(s == 0) {
317
- rgb.r = rgb.g = rgb.b = v;
318
- } else {
319
- var t1 = v;
320
- var t2 = (255-s)*v/255;
321
- var t3 = (t1-t2)*(h%60)/60;
322
- if(h==360) h = 0;
323
- if(h<60) {rgb.r=t1; rgb.b=t2; rgb.g=t2+t3}
324
- else if(h<120) {rgb.g=t1; rgb.b=t2; rgb.r=t1-t3}
325
- else if(h<180) {rgb.g=t1; rgb.r=t2; rgb.b=t2+t3}
326
- else if(h<240) {rgb.b=t1; rgb.r=t2; rgb.g=t1-t3}
327
- else if(h<300) {rgb.b=t1; rgb.g=t2; rgb.r=t2+t3}
328
- else if(h<360) {rgb.r=t1; rgb.g=t2; rgb.b=t1-t3}
329
- else {rgb.r=0; rgb.g=0; rgb.b=0}
330
- }
331
- return {r:Math.round(rgb.r), g:Math.round(rgb.g), b:Math.round(rgb.b)};
332
- },
333
- RGBToHex = function (rgb) {
334
- var hex = [
335
- rgb.r.toString(16),
336
- rgb.g.toString(16),
337
- rgb.b.toString(16)
338
- ];
339
- $.each(hex, function (nr, val) {
340
- if (val.length == 1) {
341
- hex[nr] = '0' + val;
342
- }
343
- });
344
- return hex.join('');
345
- },
346
- HSBToHex = function (hsb) {
347
- return RGBToHex(HSBToRGB(hsb));
348
- };
349
- return {
350
- init: function (options) {
351
- options = $.extend({}, defaults, options||{});
352
- if (typeof options.color == 'string') {
353
- options.color = HexToHSB(options.color);
354
- } else if (options.color.r != undefined && options.color.g != undefined && options.color.b != undefined) {
355
- options.color = RGBToHSB(options.color);
356
- } else if (options.color.h != undefined && options.color.s != undefined && options.color.b != undefined) {
357
- options.color = fixHSB(options.color);
358
- } else {
359
- return this;
360
- }
361
- options.origColor = options.color;
362
- return this.each(function () {
363
- if (!$(this).data('colorpickerId')) {
364
- var id = 'collorpicker_' + parseInt(Math.random() * 1000);
365
- $(this).data('colorpickerId', id);
366
- var cal = $(tpl).attr('id', id);
367
- if (options.flat) {
368
- cal.appendTo(this).show();
369
- } else {
370
- cal.appendTo(document.body);
371
- }
372
- options.fields = cal
373
- .find('input')
374
- .bind('keydown', keyDown)
375
- .bind('change', change)
376
- .bind('blur', blur)
377
- .bind('focus', focus);
378
- cal.find('span').bind('mousedown', downIncrement);
379
- options.selector = cal.find('div.colorpicker_color').bind('mousedown', downSelector);
380
- options.selectorIndic = options.selector.find('div div');
381
- options.hue = cal.find('div.colorpicker_hue div');
382
- cal.find('div.colorpicker_hue').bind('mousedown', downHue);
383
- options.newColor = cal.find('div.colorpicker_new_color');
384
- options.currentColor = cal.find('div.colorpicker_current_color');
385
- cal.data('colorpicker', options);
386
- cal.find('div.colorpicker_submit')
387
- .bind('mouseenter', enterSubmit)
388
- .bind('mouseleave', leaveSubmit)
389
- .bind('click', clickSubmit);
390
- fillRGBFields(options.color, cal.get(0));
391
- fillHSBFields(options.color, cal.get(0));
392
- fillHexFields(options.color, cal.get(0));
393
- setHue(options.color, cal.get(0));
394
- setSelector(options.color, cal.get(0));
395
- setCurrentColor(options.color, cal.get(0));
396
- setNewColor(options.color, cal.get(0));
397
- if (options.flat) {
398
- cal.css({
399
- position: 'relative',
400
- display: 'block'
401
- });
402
- } else {
403
- $(this).bind(options.eventName, show);
404
- }
405
- }
406
- });
407
- },
408
- showPicker: function() {
409
- return this.each( function () {
410
- if ($(this).data('colorpickerId')) {
411
- show.apply(this);
412
- }
413
- });
414
- },
415
- hidePicker: function() {
416
- return this.each( function () {
417
- if ($(this).data('colorpickerId')) {
418
- $('#' + $(this).data('colorpickerId')).hide();
419
- }
420
- });
421
- },
422
- setColor: function(col) {
423
- if (typeof col == 'string') {
424
- col = HexToHSB(col);
425
- } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
426
- col = RGBToHSB(col);
427
- } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
428
- col = fixHSB(col);
429
- } else {
430
- return this;
431
- }
432
- return this.each(function(){
433
- if ($(this).data('colorpickerId')) {
434
- var cal = $('#' + $(this).data('colorpickerId'));
435
- cal.data('colorpicker').color = col;
436
- cal.data('colorpicker').origColor = col;
437
- fillRGBFields(col, cal.get(0));
438
- fillHSBFields(col, cal.get(0));
439
- fillHexFields(col, cal.get(0));
440
- setHue(col, cal.get(0));
441
- setSelector(col, cal.get(0));
442
- setCurrentColor(col, cal.get(0));
443
- setNewColor(col, cal.get(0));
444
- }
445
- });
446
- }
447
- };
448
- }();
449
- $.fn.extend({
450
- ColorPicker: ColorPicker.init,
451
- ColorPickerHide: ColorPicker.hide,
452
- ColorPickerShow: ColorPicker.show,
453
- ColorPickerSetColor: ColorPicker.setColor
454
- });
455
- })(jQuery)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
js/iris.min.js ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ /*! Iris - v0.9.14 - 2012-11-20
2
+ * https://github.com/Automattic/Iris
3
+ * Copyright (c) 2012 Matt Wiebe; Licensed GPL */
4
+ (function(e,t){function u(){if(r)i="filter";else{var t=e('<div id="iris-gradtest" />'),n="linear-gradient(top,#fff,#000)";e.each(s,function(e,r){t.css("backgroundImage",r+n);if(t.css("backgroundImage").match("gradient"))return i=e,!1}),e.browser.webkit&&i===!1&&(t.css("background","-webkit-gradient(linear,0% 0%,0% 100%,from(#fff),to(#000))"),t.css("backgroundImage").match("gradient")&&(i="webkit")),t.remove()}}function a(t,n){return t=t==="top"?"top":"left",n=e.isArray(n)?n:Array.prototype.slice.call(arguments,1),i==="webkit"?l(t,n):s[i]+"linear-gradient("+t+", "+n.join(", ")+")"}function f(t,n){t=t==="top"?"top":"left",n=e.isArray(n)?n:Array.prototype.slice.call(arguments,1);var r=t==="top"?0:1,i=e(this),s=n.length-1,o=parseInt(e.browser.version,10)>=8?"-ms-filter":"filter";o="filter";var u=r===1?"left":"top",a=r===1?"right":"bottom",f=r===1?"height":"width",l='<div class="iris-ie-gradient-shim" style="position:absolute;'+f+":100%;"+u+":%start%;"+a+":%end%;"+o+':%filter%;" data-color:"%color%"></div>',h="";i.css("position")==="static"&&i.css({position:"relative"}),n=c(n),e.each(n,function(e,t){if(e===s)return!1;var i=n[e+1];if(t.stop===i.stop)return;var o=100-parseFloat(i.stop)+"%";t.octoHex=(new Color(t.color)).toIEOctoHex(),i.octoHex=(new Color(i.color)).toIEOctoHex();var u="progid:DXImageTransform.Microsoft.Gradient(GradientType="+r+", StartColorStr='"+t.octoHex+"', EndColorStr='"+i.octoHex+"')";h+=l.replace("%start%",t.stop).replace("%end%",o).replace("%filter%",u)}),i.find(".iris-ie-gradient-shim").remove(),e(h).prependTo(i)}function l(t,n){var r=[];return t=t==="top"?"0% 0%,0% 100%,":"0% 100%,100% 100%,",n=c(n),e.each(n,function(e,t){r.push("color-stop("+parseFloat(t.stop)/100+", "+t.color+")")}),"-webkit-gradient(linear,"+t+r.join(",")+")"}function c(t){var n=[],r=[],i=[],s=t.length-1;return e.each(t,function(e,t){var i=t,s=!1,o=t.match(/1?[0-9]{1,2}%$/);o&&(i=t.replace(/\s?1?[0-9]{1,2}%$/,""),s=o.shift()),n.push(i),r.push(s)}),r[0]===!1&&(r[0]="0%"),r[s]===!1&&(r[s]="100%"),r=h(r),e.each(r,function(e){i[e]={color:n[e],stop:r[e]}}),i}function h(t){var n=0,r=t.length-1,i=0,s=!1,o,u,a,f;if(t.length<=2||e.inArray(!1,t)<0)return t;while(i<t.length-1)!s&&t[i]===!1?(n=i-1,s=!0):s&&t[i]!==!1&&(r=i,i=t.length),i++;u=r-n,f=parseInt(t[n].replace("%"),10),o=(parseFloat(t[r].replace("%"))-f)/u,i=n+1,a=1;while(i<r)t[i]=f+a*o+"%",a++,i++;return h(t)}var n='<div class="iris-picker"><div class="iris-picker-inner"><div class="iris-square"><a class="iris-square-value" href="#"><span class="iris-square-handle ui-slider-handle"></span></a><div class="iris-square-inner iris-square-horiz"></div><div class="iris-square-inner iris-square-vert"></div></div><div class="iris-slider iris-strip"><div class="iris-slider-offset"></div></div></div></div>',r=!!(e.browser.msie&&parseInt(e.browser.version,10)<10),i=!1,s=["-moz-","-webkit-","-o-","-ms-"],o='.iris-picker{display:block;position:relative}.iris-error{background-color:#ffafaf}.iris-border{border-radius:3px;border:1px solid #aaa;width:200px;background-color:#fff}.iris-picker-inner{position:absolute;top:0;right:0;left:0;bottom:0}.iris-border .iris-picker-inner{top:10px;right:10px;left:10px;bottom:10px}.iris-picker .iris-square-inner{position:absolute;left:0;right:0;top:0;bottom:0}.iris-picker .iris-square,.iris-picker .iris-slider,.iris-picker .iris-square-inner,.iris-picker .iris-palette{border-radius:3px;box-shadow:inset 0 0 5px rgba(0,0,0,0.4);height:100%;width:12.5%;float:left;margin-right:5%}.iris-picker .iris-square{width:76%;margin-right:10%;position:relative}.iris-picker .iris-square-inner{width:auto;margin:0}.iris-ie-9 .iris-square,.iris-ie-9 .iris-slider,.iris-ie-9 .iris-square-inner,.iris-ie-9 .iris-palette{box-shadow:none;border-radius:0}.iris-ie-9 .iris-square,.iris-ie-9 .iris-slider,.iris-ie-9 .iris-palette{outline:1px solid rgba(0,0,0,.1)}.iris-ie-lt9 .iris-square,.iris-ie-lt9 .iris-slider,.iris-ie-lt9 .iris-square-inner,.iris-ie-lt9 .iris-palette{outline:1px solid #aaa}.iris-ie-lt9 .iris-square .ui-slider-handle{outline:1px solid #aaa;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)"}.iris-ie-lt9 .iris-square .iris-square-handle{background:none;border:3px solid #fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)"}.iris-picker .iris-strip{margin-right:0;position:relative}.iris-picker .iris-strip .ui-slider-handle{position:absolute;background:none;right:-3px;left:-3px;border:4px solid #aaa;border-width:4px 3px;width:auto;height:6px;border-radius:4px;box-shadow:0 1px 2px rgba(0,0,0,.2);opacity:.9;z-index:5;cursor:ns-resize}.iris-strip .ui-slider-handle:before{content:" ";position:absolute;left:-2px;right:-2px;top:-3px;bottom:-3px;border:2px solid #fff;border-radius:3px}.iris-picker .iris-slider-offset{position:absolute;top:11px;left:0;right:0;bottom:-3px}.iris-picker .iris-square-handle{background:transparent;border:5px solid #aaa;border-radius:50%;border-color:rgba(128,128,128,.5);box-shadow:none;width:12px;height:12px;position:absolute;left:-10px;top:-10px;cursor:move;opacity:1;z-index:10}.iris-picker .ui-state-focus .iris-square-handle{opacity:.8}.iris-picker .iris-square-handle:hover{border-color:#999}.iris-picker .iris-square-value:focus .iris-square-handle{box-shadow:0 0 2px rgba(0,0,0,.75);opacity:.8}.iris-picker .iris-square-handle:hover::after{border-color:#fff}.iris-picker .iris-square-handle::after{position:absolute;bottom:-4px;right:-4px;left:-4px;top:-4px;border:3px solid #f9f9f9;border-color:rgba(255,255,255,.8);border-radius:50%;content:" "}.iris-picker .iris-square-value{width:8px;height:8px;position:absolute}.iris-ie-lt9 .iris-square-value,.iris-mozilla .iris-square-value{width:1px;height:1px}.iris-palette-container{position:absolute;bottom:0;left:0;margin:0;padding:0}.iris-border .iris-palette-container{left:10px;bottom:10px}.iris-picker .iris-palette{margin:0;cursor:pointer}';if(r&&parseInt(e.browser.version,10)<=7)return e.fn.iris=e.noop;e.fn.gradient=function(t){var n=arguments;return this.each(function(){r?f.apply(this,n):e(this).css("backgroundImage",a.apply(this,n))})},e.fn.raninbowGradient=function(t,n){t=t||"top";var r=e.extend({},{s:100,l:50},n),i="hsl(%h%,"+r.s+"%,"+r.l+"%)",s=0,o=[];while(s<=360)o.push(i.replace("%h%",s)),s+=30;return this.each(function(){e(this).gradient(t,o)})};var p={options:{color:!1,mode:"hsl",controls:{horiz:"s",vert:"l",strip:"h"},hide:!0,border:!0,target:!1,width:200,palettes:!1},_palettes:["#000","#fff","#d33","#d93","#ee2","#81d742","#1e73be","#8224e3"],_inited:!1,_scale:{h:360,s:100,l:100,v:100},_create:function(){var t=this,r=t.element,s=t.options.color||r.val(),o;i===!1&&u(),r.is("input")?(t.options.target?t.picker=e(n).appendTo(t.options.target):t.picker=e(n).insertAfter(r),t._addInputListeners(r)):(r.append(n),t.picker=r.find(".iris-picker"));if(e.browser.mozilla)t.picker.addClass("iris-mozilla");else if(e.browser.msie){var a=parseInt(e.browser.version,10);a===9?t.picker.addClass("iris-ie-9"):a<=8&&t.picker.addClass("iris-ie-lt9")}t.options.palettes&&t._addPalettes(),t.color=(new Color(s)).setHSpace(t.options.mode),t.options.color=t.color.toString(),t.controls={square:t.picker.find(".iris-square"),squareDrag:t.picker.find(".iris-square-value"),horiz:t.picker.find(".iris-square-horiz"),vert:t.picker.find(".iris-square-vert"),strip:t.picker.find(".iris-strip"),stripSlider:t.picker.find(".iris-strip .iris-slider-offset")},t.options.mode==="hsv"&&t.options.controls.vert==="l"&&(t.options.controls={horiz:"h",vert:"v",strip:"s"}),t.hue=t.color.h(),t.options.hide&&t.picker.hide(),t.options.border&&t.picker.addClass("iris-border"),t._initControls(),t.active="external",t._dimensions(),t._change()},_addPalettes:function(){var t=e("<div class='iris-palette-container' />"),n=e("<a class='iris-palette' tabindex='0' />"),r=e.isArray(this.options.palettes)?this.options.palettes:this._palettes;e.each(r,function(e,r){n.clone().data("color",r).css("backgroundColor",r).appendTo(t).height(10).width(10)}),this.picker.append(t)},_paint:function(){var e=this;e._paintDimension("top","strip"),e._paintDimension("top","vert"),e._paintDimension("left","horiz")},_paintDimension:function(e,t){var n=this,r=n.color,i=n.options.mode,s=n._getHSpaceColor(),o=n.controls[t],u=n.options.controls,a;if(t===n.active||n.active==="square"&&t!=="strip")return;switch(u[t]){case"h":if(i==="hsv"){s=r.clone();switch(t){case"horiz":s[u.vert](100);break;case"vert":s[u.horiz](100);break;case"strip":s.setHSpace("hsl")}a=s.toHsl()}else t==="strip"?a={s:s.s,l:s.l}:a={s:100,l:s.l};o.raninbowGradient(e,a);break;case"s":i==="hsv"?t==="vert"?a=[r.clone().a(0).s(0).toCSS("rgba"),r.clone().a(1).s(0).toCSS("rgba")]:t==="strip"?a=[r.clone().s(100).toCSS("hsl"),r.clone().s(0).toCSS("hsl")]:t==="horiz"&&(a=["#fff","hsl("+s.h+",100%,50%)"]):t==="vert"&&n.options.controls.horiz==="h"?a=["hsla(0, 0%, "+s.l+"%, 0)","hsla(0, 0%, "+s.l+"%, 1)"]:a=["hsl("+s.h+",0%,50%)","hsl("+s.h+",100%,50%)"],o.gradient(e,a);break;case"l":t==="strip"?a=["hsl("+s.h+",100%,100%)","hsl("+s.h+", "+s.s+"%,50%)","hsl("+s.h+",100%,0%)"]:a=["#fff","rgba(255,255,255,0) 50%","rgba(0,0,0,0) 50%","rgba(0,0,0,1)"],o.gradient(e,a);break;case"v":t==="strip"?a=[r.clone().v(100).toCSS(),r.clone().v(0).toCSS()]:a=["rgba(0,0,0,0)","#000"],o.gradient(e,a);break;default:}},_getHSpaceColor:function(){return this.options.mode==="hsv"?this.color.toHsv():this.color.toHsl()},_dimensions:function(t){var n=this,r=n.options,i=n.picker.find(".iris-picker-inner"),s=n.controls,o=s.square,u=n.picker.find(".iris-strip"),a="77.5%",f="12%",l=20,c=r.border?r.width-l:r.width,h,p=e.isArray(r.palettes)?r.palettes.length:n._palettes.length,d,v,m;t&&(o.css("width",""),u.css("width",""),n.picker.removeAttr("style")),a=c*(parseFloat(a)/100),f=c*(parseFloat(f)/100),h=r.border?a+l:a,o.width(a).height(a),u.height(a).width(f),n.picker.css({width:r.width,height:h});if(!r.palettes)return;d=a*2/100,m=a-(p-1)*d,v=m/p,n.picker.find(".iris-palette").each(function(t,n){var r=t===0?0:d;e(this).css({width:v,height:v,marginLeft:r})}),n.picker.css("paddingBottom",v+d),u.height(v+d+a)},_addInputListeners:function(e){var t=this,n=100,r=function(n){var r=new Color(e.val()),i=e.val().replace(/^#/,"");e.removeClass("iris-error"),r.error?i!==""&&e.addClass("iris-error"):r.toString()!==t.color.toString()&&(n.type!=="keyup"||!i.match(/^[0-9a-fA-F]{3}$/))&&t._setOption("color",r.toString())};e.on("change",r).on("keyup",t._debounce(r,n))},_initControls:function(){var t=this,n=t.controls,r=n.square,i=t.options.controls,s=t._scale[i.strip];n.stripSlider.slider({orientation:"vertical",max:s,slide:function(e,n){t.active="strip",i.strip==="h"&&(n.value=s-n.value),t.color[i.strip](n.value),t._change.apply(t,arguments)}}),n.squareDrag.draggable({containment:"parent",zIndex:1e3,cursor:"move",drag:function(e,n){t._squareDrag(e,n)},start:function(){r.addClass("iris-dragging"),e(this).addClass("ui-state-focus")},stop:function(){r.removeClass("iris-dragging"),e(this).removeClass("ui-state-focus")}}).on("mousedown mouseup",function(n){n.preventDefault();var r="ui-state-focus";n.type==="mousedown"?(t.picker.find("."+r).removeClass(r).blur(),e(this).addClass(r).focus()):e(this).removeClass(r)}).on("keydown",function(e){var r=n.square,i=n.squareDrag,s=i.position(),o=t.options.width/100;e.altKey&&(o*=10);switch(e.keyCode){case 37:s.left-=o;break;case 38:s.top-=o;break;case 39:s.left+=o;break;case 40:s.top+=o;break;default:return!0}s.left=Math.max(0,Math.min(s.left,r.width())),s.top=Math.max(0,Math.min(s.top,r.height())),i.css(s),t._squareDrag(e,{position:s}),e.preventDefault()}),r.mousedown(function(n){if(n.which!==1)return;if(!e(n.target).is("div"))return;var r=t.controls.square.offset(),i={top:n.pageY-r.top,left:n.pageX-r.left};n.preventDefault(),t._squareDrag(n,{position:i}),n.target=t.controls.squareDrag.get(0),t.controls.squareDrag.css(i).trigger(n)}),t.options.palettes&&t.picker.find(".iris-palette-container").on("click",".iris-palette",function(n){t.color.fromCSS(e(this).data("color")),t.active="external",t._change()}).on("keydown",".iris-palette",function(t){if(t.keyCode!==13&&t.keyCode!==32)return!0;t.stopPropagation(),e(this).click()})},_squareDrag:function(e,t){var n=this,r=n.options.controls,i=n._squareDimensions(),s=Math.round((i.h-t.position.top)/i.h*n._scale[r.vert]),o=n._scale[r.horiz]-Math.round((i.w-t.position.left)/i.w*n._scale[r.horiz]);n.color[r.horiz](o)[r.vert](s),n.active="square",n._change.apply(n,arguments)},_setOption:function(e,t){var n=this.options[e];if(e==="color"){t=""+t;var r=t.replace(/^#/,""),i=(new Color(t)).setHSpace(this.options.mode);i.error||(this.color=i,this.options.color=this.options[e]=this.color.toString(),this.active="external",this._change())}},_squareDimensions:function(e){var n=this.controls.square,r,i;return e!==t&&n.data("dimensions")?n.data("dimensions"):(i=this.controls.squareDrag,r={w:n.width(),h:n.height()},n.data("dimensions",r),r)},_isNonHueControl:function(e,t){return e==="square"&&this.options.controls.strip==="h"?!0:t==="external"||t==="h"&&e==="strip"?!1:!0},_change:function(t,n){var r=this,i=r.controls,s=r._getHSpaceColor(),o=r.color.toString(),u=["square","strip"],a=r.options.controls,f=a[r.active]||"external",l=r.hue;r.active==="strip"?u=[]:r.active!=="external"&&u.pop(),e.each(u,function(e,t){var n;if(t!==r.active)switch(t){case"strip":n=a.strip==="h"?r._scale[a.strip]-s[a.strip]:s[a.strip],i.stripSlider.slider("value",n);break;case"square":var o=r._squareDimensions(),u={left:s[a.horiz]/r._scale[a.horiz]*o.w,top:o.h-s[a.vert]/r._scale[a.vert]*o.h};r.controls.squareDrag.css(u)}}),s.h!==l&&r._isNonHueControl(r.active,f)&&r.color.h(l),r.hue=r.color.h(),r.options.color=r.color.toString(),r._inited&&r._trigger("change",{type:r.active},{color:r.color}),r.element.is(":input")&&!r.color.error&&(r.element.removeClass("iris-error"),r.element.val()!==r.color.toString()&&r.element.val(r.color.toString())),r._paint(),r._inited=!0,r.active=!1},_debounce:function(e,t,n){var r,i;return function(){var s=this,o=arguments,u=function(){r=null,n||(i=e.apply(s,o))},a=n&&!r;return clearTimeout(r),r=setTimeout(u,t),a&&(i=e.apply(s,o)),i}},show:function(){this.picker.show()},hide:function(){this.picker.hide()},toggle:function(){this.picker.toggle()}};e.widget("a8c.iris",p),e('<style id="iris-css">'+o+"</style>").appendTo("head")})(jQuery),function(e,t){var n=function(e,t){return this instanceof n?this._init(e,t):new n(e,t)};n.fn=n.prototype={_color:0,_alpha:1,error:!1,_hsl:{h:0,s:0,l:0},_hsv:{h:0,s:0,v:0},_hSpace:"hsl",_init:function(e){var n="noop";switch(typeof e){case"object":return e.a!==t&&this.a(e.a),n=e.r!==t?"fromRgb":e.l!==t?"fromHsl":e.v!==t?"fromHsv":n,this[n](e);case"string":return this.fromCSS(e);case"number":return this.fromInt(parseInt(e,10))}return this},_error:function(){return this.error=!0,this},clone:function(){var e=new n(this.toInt()),t=["_alpha","_hSpace","_hsl","_hsv","error"];for(var r=t.length-1;r>=0;r--)e[t[r]]=this[t[r]];return e},setHSpace:function(e){return this._hSpace=e==="hsv"?e:"hsl",this},noop:function(){return this},fromCSS:function(e){var t,n,r=/^(rgb|hs(l|v))a?\(/;this.error=!1,e=e.replace(/^\s+/,"").replace(/\s+$/,"").replace(/;$/,"");if(e.match(r)&&e.match(/\)$/)){n=e.replace(/(\s|%)/g,"").replace(r,"").replace(/,?\);?$/,"").split(",");if(n.length<3)return this._error();if(n.length===4){this.a(parseFloat(n.pop()));if(this.error)return this}for(var i=n.length-1;i>=0;i--){n[i]=parseInt(n[i],10);if(isNaN(n[i]))return this._error()}return e.match(/^rgb/)?this.fromRgb({r:n[0],g:n[1],b:n[2]}):e.match(/^hsv/)?this.fromHsv({h:n[0],s:n[1],v:n[2]}):this.fromHsl({h:n[0],s:n[1],l:n[2]})}return this.fromHex(e)},fromRgb:function(e,n){return typeof e!="object"||e.r===t||e.g===t||e.b===t?this._error():(this.error=!1,this.fromInt(parseInt((e.r<<16)+(e.g<<8)+e.b,10),n))},fromHex:function(e){return e=e.replace(/^#/,"").replace(/^0x/,""),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),this.error=!/^[0-9A-F]{6}$/i.test(e),this.fromInt(parseInt(e,16))},fromHsl:function(e){var n,r,i,s,o,u,a,f;return typeof e!="object"||e.h===t||e.s===t||e.l===t?this._error():(this._hsl=e,this._hSpace="hsl",u=e.h/360,a=e.s/100,f=e.l/100,a===0?n=r=i=f:(s=f<.5?f*(1+a):f+a-f*a,o=2*f-s,n=this.hue2rgb(o,s,u+1/3),r=this.hue2rgb(o,s,u),i=this.hue2rgb(o,s,u-1/3)),this.fromRgb({r:n*255,g:r*255,b:i*255},!0))},fromHsv:function(e){var n,r,i,s,o,u,a,f,l,c,h;if(typeof e!="object"||e.h===t||e.s===t||e.v===t)return this._error();this._hsv=e,this._hSpace="hsv",n=e.h/360,r=e.s/100,i=e.v/100,a=Math.floor(n*6),f=n*6-a,l=i*(1-r),c=i*(1-f*r),h=i*(1-(1-f)*r);switch(a%6){case 0:s=i,o=h,u=l;break;case 1:s=c,o=i,u=l;break;case 2:s=l,o=i,u=h;break;case 3:s=l,o=c,u=i;break;case 4:s=h,o=l,u=i;break;case 5:s=i,o=l,u=c}return this.fromRgb({r:s*255,g:o*255,b:u*255},!0)},fromInt:function(e,n){return this._color=parseInt(e,10),isNaN(this._color)&&(this._color=0),this._color>16777215?this._color=16777215:this._color<0&&(this._color=0),n===t&&(this._hsv.h=this._hsv.s=this._hsl.h=this._hsl.s=0),this},hue2rgb:function(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<.5?t:n<2/3?e+(t-e)*(2/3-n)*6:e},toString:function(){var e=parseInt(this._color,10).toString(16);if(this.error)return"";if(e.length<6)for(var t=6-e.length-1;t>=0;t--)e="0"+e;return"#"+e},toCSS:function(e,t){e=e||"hex",t=parseFloat(t||this._alpha);switch(e){case"rgb":case"rgba":var n=this.toRgb();return t<1?"rgba( "+n.r+", "+n.g+", "+n.b+", "+t+" )":"rgb( "+n.r+", "+n.g+", "+n.b+" )";case"hsl":case"hsla":var r=this.toHsl();return t<1?"hsla( "+r.h+", "+r.s+"%, "+r.l+"%, "+t+" )":"hsl( "+r.h+", "+r.s+"%, "+r.l+"% )";default:return this.toString()}},toRgb:function(){return{r:255&this._color>>16,g:255&this._color>>8,b:255&this._color}},toHsl:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),s=Math.min(t,n,r),o,u,a=(i+s)/2;if(i===s)o=u=0;else{var f=i-s;u=a>.5?f/(2-i-s):f/(i+s);switch(i){case t:o=(n-r)/f+(n<r?6:0);break;case n:o=(r-t)/f+2;break;case r:o=(t-n)/f+4}o/=6}return o=Math.round(o*360),o===0&&this._hsl.h!==o&&(o=this._hsl.h),u=Math.round(u*100),u===0&&this._hsl.s&&(u=this._hsl.s),{h:o,s:u,l:Math.round(a*100)}},toHsv:function(){var e=this.toRgb(),t=e.r/255,n=e.g/255,r=e.b/255,i=Math.max(t,n,r),s=Math.min(t,n,r),o,u,a=i,f=i-s;u=i===0?0:f/i;if(i===s)o=u=0;else{switch(i){case t:o=(n-r)/f+(n<r?6:0);break;case n:o=(r-t)/f+2;break;case r:o=(t-n)/f+4}o/=6}return o=Math.round(o*360),o===0&&this._hsv.h!==o&&(o=this._hsv.h),u=Math.round(u*100),u===0&&this._hsv.s&&(u=this._hsv.s),{h:o,s:u,v:Math.round(a*100)}},toInt:function(){return this._color},toIEOctoHex:function(){var e=this.toString(),t=parseInt(255*this._alpha,10).toString(16);return t.length===1&&(t="0"+t),"#"+t+e.replace(/^#/,"")},toLuminosity:function(){var e=this.toRgb();return.2126*Math.pow(e.r/255,2.2)+.7152*Math.pow(e.g/255,2.2)+.0722*Math.pow(e.b/255,2.2)},getDistanceLuminosityFrom:function(e){if(e instanceof n){var t=this.toLuminosity(),r=e.toLuminosity();return t>r?(t+.05)/(r+.05):(r+.05)/(t+.05)}throw"getDistanceLuminosityFrom requires a Color object"},getMaxContrastColor:function(){var e=this.toLuminosity(),t=e>=.5?"000000":"ffffff";return new n(t)},getGrayscaleContrastingColor:function(e){if(!e)return this.getMaxContrastColor();var t=e<5?5:e,n=this.getMaxContrastColor();e=n.getDistanceLuminosityFrom(this);if(e<=t)return n;var r=0===n.toInt()?1:-1;while(e>t)n=n.incrementLightness(r),e=n.getDistanceLuminosityFrom(this);return n},getReadableContrastingColor:function(e,r){if(!e instanceof n)return this;var i=r===t?5:r,s=e.getDistanceLuminosityFrom(this),o=e.getMaxContrastColor(),u=o.getDistanceLuminosityFrom(e);if(u<=i)return o;if(s>=i)return this;var a=0===o.toInt()?-1:1;while(s<i){this.incrementLightness(a),s=this.getDistanceLuminosityFrom(e);if(this._color===0||this._color===16777215)break}return this},a:function(e){if(e===t)return this._alpha;var n=parseFloat(e);return isNaN(n)?this._error():(this._alpha=n,this)},darken:function(e){return e=e||5,this.l(-e,!0)},lighten:function(e){return e=e||5,this.l(e,!0)},saturate:function(e){return e=e||15,this.s(e,!0)},desaturate:function(e){return e=e||15,this.s(-e,!0)},toGrayscale:function(){return this.setHSpace("hsl").s(0)},getComplement:function(){return this.h(180,!0)},getSplitComplement:function(e){e=e||1;var t=180+e*30;return this.h(t,!0)},getAnalog:function(e){e=e||1;var t=e*30;return this.h(t,!0)},getTetrad:function(e){e=e||1;var t=e*60;return this.h(t,!0)},getTriad:function(e){e=e||1;var t=e*120;return this.h(t,!0)},_partial:function(e){var n=r[e];return function(r,i){var s=this._spaceFunc("to",n.space);return r===t?s[e]:(i===!0&&(r=s[e]+r),n.mod&&(r%=n.mod),n.range&&(r=r<n.range[0]?n.range[0]:r>n.range[1]?n.range[1]:r),s[e]=r,this._spaceFunc("from",n.space,s))}},_spaceFunc:function(e,t,n){var r=t||this._hSpace,i=e+r.charAt(0).toUpperCase()+r.substr(1);return this[i](n)}};var r={h:{mod:360},s:{range:[0,100]},l:{space:"hsl",range:[0,100]},v:{space:"hsv",range:[0,100]},r:{space:"rgb",range:[0,255]},g:{space:"rgb",range:[0,255]},b:{space:"rgb",range:[0,255]}};for(var i in r)r.hasOwnProperty(i)&&(n.fn[i]=n.fn._partial(i));e.Color=n}(typeof exports=="object"&&exports||this);
js/options-custom.js CHANGED
@@ -8,26 +8,7 @@ jQuery(document).ready(function($) {
8
  // Fade out the save message
9
  $('.fade').delay(1000).fadeOut(1000);
10
 
11
- // Color Picker
12
- $('.colorSelector').each(function(){
13
- var Othis = this; //cache a copy of the this variable for use inside nested function
14
- var initialColor = $(Othis).next('input').attr('value');
15
- $(this).ColorPicker({
16
- color: initialColor,
17
- onShow: function (colpkr) {
18
- $(colpkr).fadeIn(500);
19
- return false;
20
- },
21
- onHide: function (colpkr) {
22
- $(colpkr).fadeOut(500);
23
- return false;
24
- },
25
- onChange: function (hsb, hex, rgb) {
26
- $(Othis).children('div').css('backgroundColor', '#' + hex);
27
- $(Othis).next('input').attr('value','#' + hex);
28
- }
29
- });
30
- }); //end color picker
31
 
32
  // Switches option sections
33
  $('.group').hide();
8
  // Fade out the save message
9
  $('.fade').delay(1000).fadeOut(1000);
10
 
11
+ $('.of-color').wpColorPicker();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  // Switches option sections
14
  $('.group').hide();
lang/optionsframework-fa_IR.mo ADDED
Binary file
lang/optionsframework-fa_IR.po ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: \n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2012-04-22 15:51-0300\n"
6
+ "PO-Revision-Date: 2012-09-10 07:03+0330\n"
7
+ "Last-Translator: va <vahid@vahidd.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Poedit-KeywordsList: _;gettext;gettext_noop;__;_e;esc_attr_e\n"
13
+ "X-Poedit-Basepath: /Users/weslly/Desktop/options-framework-plugin\n"
14
+ "X-Poedit-SearchPath-0: .\n"
15
+
16
+ #: options-framework.php:71
17
+ #, php-format
18
+ msgid "Your current theme does not have support for the Options Framework plugin. <a href=\"%1$s\" target=\"_blank\">Learn More</a> | <a href=\"%2$s\">Hide Notice</a>"
19
+ msgstr "قالب فعلی شما با پلاگین فریم ورک قالب سازگار نیست. <a href=\"%1$s\" target=\"_blank\">بیشتر یاد بگیرید</a> | <a href=\"%2$s\">مخفی کردن این نکته</a>"
20
+
21
+ #: options-framework.php:254
22
+ #: options-framework.php:456
23
+ msgid "Theme Options"
24
+ msgstr "تنظیمات قالب"
25
+
26
+ #: options-framework.php:323
27
+ msgid "Save Options"
28
+ msgstr "ذخیره تنظیمات"
29
+
30
+ #: options-framework.php:324
31
+ msgid "Restore Defaults"
32
+ msgstr "بازگرداندن به پیش‌فرض"
33
+
34
+ #: options-framework.php:324
35
+ msgid "Click OK to reset. Any theme settings will be lost!"
36
+ msgstr ""
37
+
38
+ #: options-framework.php:358
39
+ msgid "Default options restored."
40
+ msgstr ""
41
+
42
+ #: options-framework.php:400
43
+ msgid "Options saved."
44
+ msgstr "تنظیمات ذخیره شدند."
45
+
46
+ #: options-medialibrary-uploader.php:26
47
+ msgid "Options Framework Internal Container"
48
+ msgstr ""
49
+
50
+ #: options-medialibrary-uploader.php:128
51
+ msgid "Upload"
52
+ msgstr "آپلود"
53
+
54
+ #: options-medialibrary-uploader.php:151
55
+ msgid "View File"
56
+ msgstr "مشاهده فایل"
57
+
58
+ #: options-medialibrary-uploader.php:288
59
+ msgid "Gallery"
60
+ msgstr "گالری"
61
+
62
+ #: options-medialibrary-uploader.php:288
63
+ msgid "Previously Uploaded"
64
+ msgstr ""
65
+
66
+ #: options-sanitize.php:232
67
+ msgid "No Repeat"
68
+ msgstr ""
69
+
70
+ #: options-sanitize.php:233
71
+ msgid "Repeat Horizontally"
72
+ msgstr ""
73
+
74
+ #: options-sanitize.php:234
75
+ msgid "Repeat Vertically"
76
+ msgstr ""
77
+
78
+ #: options-sanitize.php:235
79
+ msgid "Repeat All"
80
+ msgstr ""
81
+
82
+ #: options-sanitize.php:248
83
+ msgid "Top Left"
84
+ msgstr "بالا چپ"
85
+
86
+ #: options-sanitize.php:249
87
+ msgid "Top Center"
88
+ msgstr "بالا وسط"
89
+
90
+ #: options-sanitize.php:250
91
+ msgid "Top Right"
92
+ msgstr "بالا راست"
93
+
94
+ #: options-sanitize.php:251
95
+ msgid "Middle Left"
96
+ msgstr "وسط چپ"
97
+
98
+ #: options-sanitize.php:252
99
+ msgid "Middle Center"
100
+ msgstr "وسط وسط"
101
+
102
+ #: options-sanitize.php:253
103
+ msgid "Middle Right"
104
+ msgstr "وسط راست"
105
+
106
+ #: options-sanitize.php:254
107
+ msgid "Bottom Left"
108
+ msgstr "پایین چپ "
109
+
110
+ #: options-sanitize.php:255
111
+ msgid "Bottom Center"
112
+ msgstr "پایین وسط"
113
+
114
+ #: options-sanitize.php:256
115
+ msgid "Bottom Right"
116
+ msgstr "پایین راست"
117
+
118
+ #: options-sanitize.php:269
119
+ msgid "Scroll Normally"
120
+ msgstr ""
121
+
122
+ #: options-sanitize.php:270
123
+ msgid "Fixed in Place"
124
+ msgstr ""
125
+
126
+ #: options-sanitize.php:344
127
+ msgid "Normal"
128
+ msgstr "عادی"
129
+
130
+ #: options-sanitize.php:345
131
+ msgid "Italic"
132
+ msgstr ""
133
+
134
+ #: options-sanitize.php:346
135
+ msgid "Bold"
136
+ msgstr ""
137
+
138
+ #: options-sanitize.php:347
139
+ msgid "Bold Italic"
140
+ msgstr ""
141
+
options-framework.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Options Framework
4
  Plugin URI: http://www.wptheming.com
5
  Description: A framework for building theme options.
6
- Version: 1.3
7
  Author: Devin Price
8
  Author URI: http://www.wptheming.com
9
  License: GPLv2
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
 
28
  /* Basic plugin definitions */
29
 
30
- define('OPTIONS_FRAMEWORK_VERSION', '1.3');
31
  define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
32
 
33
  load_plugin_textdomain( 'optionsframework', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
@@ -194,7 +194,6 @@ function optionsframework_page_capability( $capability ) {
194
  return 'edit_theme_options';
195
  }
196
 
197
-
198
  /*
199
  * Adds default options to the database if they aren't already present.
200
  * May update this later to load only on plugin activation, or theme
@@ -262,7 +261,10 @@ if ( !function_exists( 'optionsframework_add_page' ) ) {
262
 
263
  function optionsframework_load_styles() {
264
  wp_enqueue_style('optionsframework', OPTIONS_FRAMEWORK_URL.'css/optionsframework.css');
265
- wp_enqueue_style('color-picker', OPTIONS_FRAMEWORK_URL.'css/colorpicker.css');
 
 
 
266
  }
267
 
268
  /* Loads the javascript */
@@ -272,17 +274,28 @@ function optionsframework_load_scripts($hook) {
272
  if ( 'appearance_page_options-framework' != $hook )
273
  return;
274
 
275
- // Enqueued scripts
276
- wp_enqueue_script('jquery-ui-core');
277
- wp_enqueue_script('color-picker', OPTIONS_FRAMEWORK_URL .'js/colorpicker.js', array('jquery'));
278
- wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_URL .'js/options-custom.js', array('jquery'));
 
 
 
 
 
 
 
 
 
 
 
 
279
 
280
  // Inline scripts from options-interface.php
281
- add_action('admin_head', 'of_admin_head');
282
  }
283
 
284
  function of_admin_head() {
285
-
286
  // Hook to add custom scripts
287
  do_action( 'optionsframework_custom_scripts' );
288
  }
@@ -299,10 +312,9 @@ function of_admin_head() {
299
  *
300
  */
301
 
302
- if ( !function_exists( 'optionsframework_page' ) ) {
303
- function optionsframework_page() {
304
- settings_errors();
305
- ?>
306
 
307
  <div id="optionsframework-wrap" class="wrap">
308
  <?php screen_icon( 'themes' ); ?>
@@ -327,8 +339,8 @@ if ( !function_exists( 'optionsframework_page' ) ) {
327
  </div> <!-- / .wrap -->
328
 
329
  <?php
330
- }
331
  }
 
332
 
333
  /**
334
  * Validate Options.
@@ -391,13 +403,23 @@ function optionsframework_validate( $input ) {
391
  $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option );
392
  }
393
  }
394
-
395
- add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'optionsframework' ), 'updated fade' );
 
396
 
397
  return $clean;
 
398
 
 
 
 
 
 
 
399
  }
400
 
 
 
401
  /**
402
  * Format Configuration Array.
403
  *
@@ -448,7 +470,7 @@ function optionsframework_adminbar() {
448
  ));
449
  }
450
 
451
- if ( ! function_exists( 'of_get_option' ) ) {
452
 
453
  /**
454
  * Get Option.
@@ -473,7 +495,7 @@ if ( ! function_exists( 'of_get_option' ) ) {
473
 
474
  return $default;
475
  }
476
- }
477
 
478
  /**
479
  * Wrapper for optionsframework_options()
3
  Plugin Name: Options Framework
4
  Plugin URI: http://www.wptheming.com
5
  Description: A framework for building theme options.
6
+ Version: 1.4
7
  Author: Devin Price
8
  Author URI: http://www.wptheming.com
9
  License: GPLv2
27
 
28
  /* Basic plugin definitions */
29
 
30
+ define('OPTIONS_FRAMEWORK_VERSION', '1.4');
31
  define('OPTIONS_FRAMEWORK_URL', plugin_dir_url( __FILE__ ));
32
 
33
  load_plugin_textdomain( 'optionsframework', false, dirname( plugin_basename( __FILE__ ) ) . '/lang/' );
194
  return 'edit_theme_options';
195
  }
196
 
 
197
  /*
198
  * Adds default options to the database if they aren't already present.
199
  * May update this later to load only on plugin activation, or theme
261
 
262
  function optionsframework_load_styles() {
263
  wp_enqueue_style('optionsframework', OPTIONS_FRAMEWORK_URL.'css/optionsframework.css');
264
+ if ( !wp_style_is( 'wp-color-picker','registered' ) ) {
265
+ wp_register_style('wp-color-picker', OPTIONS_FRAMEWORK_URL.'css/color-picker.min.css');
266
+ }
267
+ wp_enqueue_style( 'wp-color-picker' );
268
  }
269
 
270
  /* Loads the javascript */
274
  if ( 'appearance_page_options-framework' != $hook )
275
  return;
276
 
277
+ // Enqueue colorpicker scripts for versions below 3.5
278
+ // for compatibility
279
+
280
+ if ( !wp_script_is( 'wp-color-picker', 'registered' ) ) {
281
+ wp_register_script( 'iris', OPTIONS_FRAMEWORK_URL . 'js/iris.min.js', array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false, 1 );
282
+ wp_register_script( 'wp-color-picker', OPTIONS_FRAMEWORK_URL . 'js/color-picker.min.js', array( 'jquery', 'iris' ) );
283
+ $colorpicker_l10n = array(
284
+ 'clear' => __( 'Clear' ),
285
+ 'defaultString' => __( 'Default' ),
286
+ 'pick' => __( 'Select Color' )
287
+ );
288
+ wp_localize_script( 'wp-color-picker', 'wpColorPickerL10n', $colorpicker_l10n );
289
+ }
290
+
291
+ // Enqueue custom option panel JS
292
+ wp_enqueue_script( 'options-custom', OPTIONS_FRAMEWORK_URL . 'js/options-custom.js', array( 'jquery','wp-color-picker' ) );
293
 
294
  // Inline scripts from options-interface.php
295
+ add_action( 'admin_head', 'of_admin_head' );
296
  }
297
 
298
  function of_admin_head() {
 
299
  // Hook to add custom scripts
300
  do_action( 'optionsframework_custom_scripts' );
301
  }
312
  *
313
  */
314
 
315
+ if ( !function_exists( 'optionsframework_page' ) ) :
316
+ function optionsframework_page() {
317
+ settings_errors(); ?>
 
318
 
319
  <div id="optionsframework-wrap" class="wrap">
320
  <?php screen_icon( 'themes' ); ?>
339
  </div> <!-- / .wrap -->
340
 
341
  <?php
 
342
  }
343
+ endif;
344
 
345
  /**
346
  * Validate Options.
403
  $clean[$id] = apply_filters( 'of_sanitize_' . $option['type'], $input[$id], $option );
404
  }
405
  }
406
+
407
+ // Hook to run after validation
408
+ do_action( 'optionsframework_after_validate', $clean );
409
 
410
  return $clean;
411
+ }
412
 
413
+ /**
414
+ * Display message when options have been saved
415
+ */
416
+
417
+ function optionsframework_save_options_notice() {
418
+ add_settings_error( 'options-framework', 'save_options', __( 'Options saved.', 'optionsframework' ), 'updated fade' );
419
  }
420
 
421
+ add_action( 'optionsframework_after_validate', 'optionsframework_save_options_notice' );
422
+
423
  /**
424
  * Format Configuration Array.
425
  *
470
  ));
471
  }
472
 
473
+ if ( ! function_exists( 'of_get_option' ) ) :
474
 
475
  /**
476
  * Get Option.
495
 
496
  return $default;
497
  }
498
+ endif;
499
 
500
  /**
501
  * Wrapper for optionsframework_options()
options-interface.php CHANGED
@@ -5,16 +5,18 @@
5
  */
6
 
7
  function optionsframework_tabs() {
8
-
9
  $optionsframework_settings = get_option('optionsframework');
10
  $options =& _optionsframework_options();
11
  $menu = '';
12
 
13
  foreach ($options as $value) {
 
14
  // Heading for Navigation
15
  if ($value['type'] == "heading") {
16
- $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['name']) );
17
- $jquery_click_hook = "of-option-" . $jquery_click_hook;
 
18
  $menu .= '<a id="'. esc_attr( $jquery_click_hook ) . '-tab" class="nav-tab" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '">' . esc_html( $value['name'] ) . '</a>';
19
  }
20
  }
@@ -110,6 +112,11 @@ function optionsframework_fields() {
110
  $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
111
  break;
112
 
 
 
 
 
 
113
  // Textarea
114
  case 'textarea':
115
  $rows = '8';
@@ -126,7 +133,7 @@ function optionsframework_fields() {
126
  break;
127
 
128
  // Select Box
129
- case ($value['type'] == 'select'):
130
  $output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
131
 
132
  foreach ($value['options'] as $key => $option ) {
@@ -193,8 +200,13 @@ function optionsframework_fields() {
193
 
194
  // Color picker
195
  case "color":
196
- $output .= '<div id="' . esc_attr( $value['id'] . '_picker' ) . '" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $val ) . '"></div></div>';
197
- $output .= '<input class="of-color" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" type="text" value="' . esc_attr( $val ) . '" />';
 
 
 
 
 
198
  break;
199
 
200
  // Uploader
@@ -260,8 +272,12 @@ function optionsframework_fields() {
260
 
261
  // Font Color
262
  if ( $typography_options['color'] ) {
263
- $font_color = '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $typography_stored['color'] ) . '"></div></div>';
264
- $font_color .= '<input class="of-color of-typography of-typography-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $typography_stored['color'] ) . '" />';
 
 
 
 
265
  }
266
 
267
  // Allow modification/injection of typography fields
@@ -277,8 +293,12 @@ function optionsframework_fields() {
277
  $background = $val;
278
 
279
  // Background Color
280
- $output .= '<div id="' . esc_attr( $value['id'] ) . '_color_picker" class="colorSelector"><div style="' . esc_attr( 'background-color:' . $background['color'] ) . '"></div></div>';
281
- $output .= '<input class="of-color of-background of-background-color" name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" type="text" value="' . esc_attr( $background['color'] ) . '" />';
 
 
 
 
282
 
283
  // Background Image - New AJAX Uploader using Media Library
284
  if (!isset($background['image'])) {
@@ -371,7 +391,7 @@ function optionsframework_fields() {
371
  $output .= '</div>'."\n";
372
  }
373
  $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['name']) );
374
- $jquery_click_hook = "of-option-" . $jquery_click_hook;
375
  $menu .= '<a id="'. esc_attr( $jquery_click_hook ) . '-tab" class="nav-tab" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '">' . esc_html( $value['name'] ) . '</a>';
376
  $output .= '<div class="group" id="' . esc_attr( $jquery_click_hook ) . '">';
377
  $output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
5
  */
6
 
7
  function optionsframework_tabs() {
8
+ $counter = 0;
9
  $optionsframework_settings = get_option('optionsframework');
10
  $options =& _optionsframework_options();
11
  $menu = '';
12
 
13
  foreach ($options as $value) {
14
+ $counter++;
15
  // Heading for Navigation
16
  if ($value['type'] == "heading") {
17
+ $id = ! empty( $value['id'] ) ? $value['id'] : $value['name'];
18
+ $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($id) );
19
+ $jquery_click_hook = "of-option-" . $jquery_click_hook . $counter;
20
  $menu .= '<a id="'. esc_attr( $jquery_click_hook ) . '-tab" class="nav-tab" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '">' . esc_html( $value['name'] ) . '</a>';
21
  }
22
  }
112
  $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="text" value="' . esc_attr( $val ) . '" />';
113
  break;
114
 
115
+ // Password input
116
+ case 'password':
117
+ $output .= '<input id="' . esc_attr( $value['id'] ) . '" class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" type="password" value="' . esc_attr( $val ) . '" />';
118
+ break;
119
+
120
  // Textarea
121
  case 'textarea':
122
  $rows = '8';
133
  break;
134
 
135
  // Select Box
136
+ case 'select':
137
  $output .= '<select class="of-input" name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '">';
138
 
139
  foreach ($value['options'] as $key => $option ) {
200
 
201
  // Color picker
202
  case "color":
203
+ $default_color = '';
204
+ if ( isset($value['std']) ) {
205
+ if ( $val != $value['std'] )
206
+ $default_color = ' data-default-color="' .$value['std'] . '" ';
207
+ }
208
+ $output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . ']' ) . '" id="' . esc_attr( $value['id'] ) . '" class="of-color" type="text" value="' . esc_attr( $val ) . '"' . $default_color .' />';
209
+
210
  break;
211
 
212
  // Uploader
272
 
273
  // Font Color
274
  if ( $typography_options['color'] ) {
275
+ $default_color = '';
276
+ if ( isset($value['std']['color']) ) {
277
+ if ( $val != $value['std']['color'] )
278
+ $default_color = ' data-default-color="' .$value['std']['color'] . '" ';
279
+ }
280
+ $font_color = '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-typography-color type="text" value="' . esc_attr( $typography_stored['color'] ) . '"' . $default_color .' />';
281
  }
282
 
283
  // Allow modification/injection of typography fields
293
  $background = $val;
294
 
295
  // Background Color
296
+ $default_color = '';
297
+ if ( isset($value['std']['color']) ) {
298
+ if ( $val != $value['std']['color'] )
299
+ $default_color = ' data-default-color="' .$value['std']['color'] . '" ';
300
+ }
301
+ $output .= '<input name="' . esc_attr( $option_name . '[' . $value['id'] . '][color]' ) . '" id="' . esc_attr( $value['id'] . '_color' ) . '" class="of-color of-background-color" type="text" value="' . esc_attr( $background['color'] ) . '"' . $default_color .' />';
302
 
303
  // Background Image - New AJAX Uploader using Media Library
304
  if (!isset($background['image'])) {
391
  $output .= '</div>'."\n";
392
  }
393
  $jquery_click_hook = preg_replace('/[^a-zA-Z0-9._\-]/', '', strtolower($value['name']) );
394
+ $jquery_click_hook = "of-option-" . $jquery_click_hook . $counter;
395
  $menu .= '<a id="'. esc_attr( $jquery_click_hook ) . '-tab" class="nav-tab" title="' . esc_attr( $value['name'] ) . '" href="' . esc_attr( '#'. $jquery_click_hook ) . '">' . esc_html( $value['name'] ) . '</a>';
396
  $output .= '<div class="group" id="' . esc_attr( $jquery_click_hook ) . '">';
397
  $output .= '<h3>' . esc_html( $value['name'] ) . '</h3>' . "\n";
options-medialibrary-uploader.php CHANGED
@@ -7,7 +7,6 @@
7
  */
8
 
9
  if ( is_admin() ) {
10
-
11
  // Load additional css and js for image uploads on the Options Framework page
12
  $of_page= 'appearance_page_options-framework';
13
  add_action( "admin_print_styles-$of_page", 'optionsframework_mlu_css', 0 );
@@ -19,65 +18,63 @@ if ( is_admin() ) {
19
  * individual galleries for different uploaders.
20
  */
21
 
22
- if ( ! function_exists( 'optionsframework_mlu_init' ) ) {
23
- function optionsframework_mlu_init () {
24
- register_post_type( 'optionsframework', array(
25
- 'labels' => array(
26
- 'name' => __( 'Theme Options Media', 'optionsframework' ),
27
- ),
28
- 'public' => true,
29
- 'show_ui' => false,
30
- 'capability_type' => 'post',
31
- 'hierarchical' => false,
32
- 'rewrite' => false,
33
- 'supports' => array( 'title', 'editor' ),
34
- 'query_var' => false,
35
- 'can_export' => true,
36
- 'show_in_nav_menus' => false,
37
- 'public' => false
38
- ) );
39
- }
40
  }
41
 
 
 
42
  /**
43
  * Adds the Thickbox CSS file and specific loading and button images to the header
44
  * on the pages where this function is called.
45
  */
46
 
47
- if ( ! function_exists( 'optionsframework_mlu_css' ) ) {
48
-
49
- function optionsframework_mlu_css () {
50
-
51
- $_html = '';
52
- $_html .= '<link rel="stylesheet" href="' . site_url() . '/' . WPINC . '/js/thickbox/thickbox.css" type="text/css" media="screen" />' . "\n";
53
- $_html .= '<script type="text/javascript">
54
- var tb_pathToImage = "' . site_url() . '/' . WPINC . '/js/thickbox/loadingAnimation.gif";
55
- var tb_closeImage = "' . site_url() . '/' . WPINC . '/js/thickbox/tb-close.png";
56
- </script>' . "\n";
57
-
58
- echo $_html;
59
-
60
- }
61
 
 
 
 
 
 
 
 
 
62
  }
63
 
 
 
64
  /**
65
  * Registers and enqueues (loads) the necessary JavaScript file for working with the
66
  * Media Library-driven AJAX File Uploader Module.
67
  */
68
 
69
- if ( ! function_exists( 'optionsframework_mlu_js' ) ) {
70
-
71
- function optionsframework_mlu_js () {
72
-
73
- // Registers custom scripts for the Media Library AJAX uploader.
74
- wp_register_script( 'of-medialibrary-uploader', OPTIONS_FRAMEWORK_URL .'js/of-medialibrary-uploader.js', array( 'jquery', 'thickbox' ) );
75
- wp_enqueue_script( 'of-medialibrary-uploader' );
76
- wp_enqueue_script( 'media-upload' );
77
- }
78
 
 
 
 
 
 
79
  }
80
 
 
 
81
  /**
82
  * Media Uploader Using the WordPress Media Library.
83
  *
@@ -92,72 +89,73 @@ if ( ! function_exists( 'optionsframework_mlu_js' ) ) {
92
  * - optionsframework_mlu_get_silentpost()
93
  */
94
 
95
- if ( ! function_exists( 'optionsframework_medialibrary_uploader' ) ) {
 
 
96
 
97
- function optionsframework_medialibrary_uploader( $_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0, $_name = '') {
98
 
99
- $optionsframework_settings = get_option('optionsframework');
100
-
101
- // Gets the unique option id
102
- $option_name = $optionsframework_settings['id'];
 
 
 
 
 
103
 
104
- $output = '';
105
- $id = '';
106
- $class = '';
107
- $int = '';
108
- $value = '';
109
- $name = '';
110
-
111
- $id = strip_tags( strtolower( $_id ) );
112
- // Change for each field, using a "silent" post. If no post is present, one will be created.
113
- $int = optionsframework_mlu_get_silentpost( $id );
114
-
115
- // If a value is passed and we don't have a stored value, use the value that's passed through.
116
- if ( $_value != '' && $value == '' ) {
117
- $value = $_value;
118
- }
119
-
120
- if ($_name != '') {
121
- $name = $option_name.'['.$id.']['.$_name.']';
122
- }
123
- else {
124
- $name = $option_name.'['.$id.']';
125
- }
126
-
127
- if ( $value ) { $class = ' has-file'; }
128
- $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$name.'" value="' . $value . '" />' . "\n";
129
- $output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . __( 'Upload', 'optionsframework' ) . '" rel="' . $int . '" />' . "\n";
130
-
131
- if ( $_desc != '' ) {
132
- $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n";
133
- }
134
-
135
- $output .= '<div class="screenshot" id="' . $id . '_image">' . "\n";
 
 
 
 
 
 
 
136
 
137
- if ( $value != '' ) {
138
- $remove = '<a href="javascript:(void);" class="mlu_remove button">Remove</a>';
139
- $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value );
140
- if ( $image ) {
141
- $output .= '<img src="' . $value . '" alt="" />'.$remove.'';
142
- } else {
143
- $parts = explode( "/", $value );
144
- for( $i = 0; $i < sizeof( $parts ); ++$i ) {
145
- $title = $parts[$i];
146
- }
147
-
148
- // No output preview if it's not an image.
149
- $output .= '';
150
-
151
- // Standard generic output if it's not an image.
152
- $title = __( 'View File', 'optionsframework' );
153
- $output .= '<div class="no_image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">'.$title.'</a></span>' . $remove . '</div>';
154
- }
155
- }
156
- $output .= '</div>' . "\n";
157
- return $output;
158
- }
159
  }
160
 
 
 
161
  /**
162
  * Uses "silent" posts in the database to store relationships for images.
163
  * This also creates the facility to collect galleries of, for example, logo images.
@@ -171,81 +169,79 @@ if ( ! function_exists( 'optionsframework_medialibrary_uploader' ) ) {
171
  * optionsframework_mlu_get_silentpost ( 'of_logo' );
172
  */
173
 
174
- if ( ! function_exists( 'optionsframework_mlu_get_silentpost' ) ) {
175
 
176
- function optionsframework_mlu_get_silentpost ( $_token ) {
 
 
 
 
 
 
 
177
 
178
- global $wpdb;
179
- $_id = 0;
180
 
181
- // Check if the token is valid against a whitelist.
182
- // $_whitelist = array( 'of_logo', 'of_custom_favicon', 'of_ad_top_image' );
183
- // Sanitise the token.
 
 
 
184
 
185
- $_token = strtolower( str_replace( ' ', '_', $_token ) );
 
 
 
 
186
 
187
- // if ( in_array( $_token, $_whitelist ) ) {
188
- if ( $_token ) {
189
-
190
- // Tell the function what to look for in a post.
191
-
192
- $_args = array( 'post_type' => 'optionsframework', 'post_name' => 'of-' . $_token, 'post_status' => 'draft', 'comment_status' => 'closed', 'ping_status' => 'closed' );
193
-
194
- // Look in the database for a "silent" post that meets our criteria.
195
- $query = 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_parent = 0';
196
- foreach ( $_args as $k => $v ) {
197
- $query .= ' AND ' . $k . ' = "' . $v . '"';
198
- } // End FOREACH Loop
199
-
200
- $query .= ' LIMIT 1';
201
- $_posts = $wpdb->get_row( $query );
202
-
203
- // If we've got a post, loop through and get it's ID.
204
- if ( count( $_posts ) ) {
205
- $_id = $_posts->ID;
206
- } else {
207
-
208
- // If no post is present, insert one.
209
- // Prepare some additional data to go with the post insertion.
210
- $_words = explode( '_', $_token );
211
- $_title = join( ' ', $_words );
212
- $_title = ucwords( $_title );
213
- $_post_data = array( 'post_title' => $_title );
214
- $_post_data = array_merge( $_post_data, $_args );
215
- $_id = wp_insert_post( $_post_data );
216
- }
217
- }
218
- return $_id;
219
  }
 
220
  }
 
221
 
222
  /**
223
  * Trigger code inside the Media Library popup.
224
  */
225
 
226
- if ( ! function_exists( 'optionsframework_mlu_insidepopup' ) ) {
227
-
228
- function optionsframework_mlu_insidepopup () {
229
 
230
- if ( isset( $_REQUEST['is_optionsframework'] ) && $_REQUEST['is_optionsframework'] == 'yes' ) {
231
-
232
- add_action( 'admin_head', 'optionsframework_mlu_js_popup' );
233
- add_filter( 'media_upload_tabs', 'optionsframework_mlu_modify_tabs' );
234
- }
235
  }
236
  }
237
 
238
- if ( ! function_exists( 'optionsframework_mlu_js_popup' ) ) {
 
 
239
 
240
- function optionsframework_mlu_js_popup () {
241
 
242
- $_of_title = $_REQUEST['of_title'];
243
- if ( ! $_of_title ) { $_of_title = 'file'; } // End IF Statement
244
- ?>
245
  <script type="text/javascript">
246
- <!--
247
  jQuery(function($) {
248
-
249
  jQuery.noConflict();
250
 
251
  // Change the title of each tab to use the custom title text instead of "Media File".
@@ -264,29 +260,27 @@ if ( ! function_exists( 'optionsframework_mlu_js_popup' ) ) {
264
 
265
  // Preserve the "is_optionsframework" parameter on the "delete" confirmation button.
266
  $( '.savesend a.del-link' ).click ( function () {
267
-
268
  var continueButton = $( this ).next( '.del-attachment' ).children( 'a.button[id*="del"]' );
269
  var continueHref = continueButton.attr( 'href' );
270
  continueHref = continueHref + '&is_optionsframework=yes';
271
  continueButton.attr( 'href', continueHref );
272
-
273
- } );
274
-
275
  });
276
- -->
277
  </script>
278
  <?php
279
- }
280
  }
281
 
 
 
282
  /**
283
  * Triggered inside the Media Library popup to modify the title of the "Gallery" tab.
284
  */
285
 
286
- if ( ! function_exists( 'optionsframework_mlu_modify_tabs' ) ) {
287
 
288
- function optionsframework_mlu_modify_tabs ( $tabs ) {
289
- $tabs['gallery'] = str_replace( __( 'Gallery', 'optionsframework' ), __( 'Previously Uploaded', 'optionsframework' ), $tabs['gallery'] );
290
- return $tabs;
291
- }
292
- }
 
7
  */
8
 
9
  if ( is_admin() ) {
 
10
  // Load additional css and js for image uploads on the Options Framework page
11
  $of_page= 'appearance_page_options-framework';
12
  add_action( "admin_print_styles-$of_page", 'optionsframework_mlu_css', 0 );
18
  * individual galleries for different uploaders.
19
  */
20
 
21
+ if ( ! function_exists( 'optionsframework_mlu_init' ) ) :
22
+
23
+ function optionsframework_mlu_init () {
24
+ register_post_type( 'optionsframework', array(
25
+ 'labels' => array(
26
+ 'name' => __( 'Theme Options Media', 'optionsframework' ),
27
+ ),
28
+ 'public' => true,
29
+ 'show_ui' => false,
30
+ 'capability_type' => 'post',
31
+ 'hierarchical' => false,
32
+ 'rewrite' => false,
33
+ 'supports' => array( 'title', 'editor' ),
34
+ 'query_var' => false,
35
+ 'can_export' => true,
36
+ 'show_in_nav_menus' => false,
37
+ 'public' => false
38
+ ) );
39
  }
40
 
41
+ endif;
42
+
43
  /**
44
  * Adds the Thickbox CSS file and specific loading and button images to the header
45
  * on the pages where this function is called.
46
  */
47
 
48
+ if ( ! function_exists( 'optionsframework_mlu_css' ) ) :
 
 
 
 
 
 
 
 
 
 
 
 
 
49
 
50
+ function optionsframework_mlu_css () {
51
+ $_html = '';
52
+ $_html .= '<link rel="stylesheet" href="' . site_url() . '/' . WPINC . '/js/thickbox/thickbox.css" type="text/css" media="screen" />' . "\n";
53
+ $_html .= '<script type="text/javascript">
54
+ var tb_pathToImage = "' . site_url() . '/' . WPINC . '/js/thickbox/loadingAnimation.gif";
55
+ var tb_closeImage = "' . site_url() . '/' . WPINC . '/js/thickbox/tb-close.png";
56
+ </script>' . "\n";
57
+ echo $_html;
58
  }
59
 
60
+ endif;
61
+
62
  /**
63
  * Registers and enqueues (loads) the necessary JavaScript file for working with the
64
  * Media Library-driven AJAX File Uploader Module.
65
  */
66
 
67
+ if ( ! function_exists( 'optionsframework_mlu_js' ) ) :
 
 
 
 
 
 
 
 
68
 
69
+ function optionsframework_mlu_js () {
70
+ // Registers custom scripts for the Media Library AJAX uploader.
71
+ wp_register_script( 'of-medialibrary-uploader', OPTIONS_FRAMEWORK_URL .'js/of-medialibrary-uploader.js', array( 'jquery', 'thickbox' ) );
72
+ wp_enqueue_script( 'of-medialibrary-uploader' );
73
+ wp_enqueue_script( 'media-upload' );
74
  }
75
 
76
+ endif;
77
+
78
  /**
79
  * Media Uploader Using the WordPress Media Library.
80
  *
89
  * - optionsframework_mlu_get_silentpost()
90
  */
91
 
92
+ if ( ! function_exists( 'optionsframework_medialibrary_uploader' ) ) :
93
+
94
+ function optionsframework_medialibrary_uploader( $_id, $_value, $_mode = 'full', $_desc = '', $_postid = 0, $_name = '') {
95
 
96
+ $optionsframework_settings = get_option('optionsframework');
97
 
98
+ // Gets the unique option id
99
+ $option_name = $optionsframework_settings['id'];
100
+
101
+ $output = '';
102
+ $id = '';
103
+ $class = '';
104
+ $int = '';
105
+ $value = '';
106
+ $name = '';
107
 
108
+ $id = strip_tags( strtolower( $_id ) );
109
+ // Change for each field, using a "silent" post. If no post is present, one will be created.
110
+ $int = optionsframework_mlu_get_silentpost( $id );
111
+
112
+ // If a value is passed and we don't have a stored value, use the value that's passed through.
113
+ if ( $_value != '' && $value == '' ) {
114
+ $value = $_value;
115
+ }
116
+
117
+ if ($_name != '') {
118
+ $name = $option_name.'['.$id.']['.$_name.']';
119
+ }
120
+ else {
121
+ $name = $option_name.'['.$id.']';
122
+ }
123
+
124
+ if ( $value ) { $class = ' has-file'; }
125
+ $output .= '<input id="' . $id . '" class="upload' . $class . '" type="text" name="'.$name.'" value="' . $value . '" />' . "\n";
126
+ $output .= '<input id="upload_' . $id . '" class="upload_button button" type="button" value="' . __( 'Upload', 'optionsframework' ) . '" rel="' . $int . '" />' . "\n";
127
+
128
+ if ( $_desc != '' ) {
129
+ $output .= '<span class="of_metabox_desc">' . $_desc . '</span>' . "\n";
130
+ }
131
+
132
+ $output .= '<div class="screenshot" id="' . $id . '_image">' . "\n";
133
+
134
+ if ( $value != '' ) {
135
+ $remove = '<a href="javascript:(void);" class="mlu_remove button">Remove</a>';
136
+ $image = preg_match( '/(^.*\.jpg|jpeg|png|gif|ico*)/i', $value );
137
+ if ( $image ) {
138
+ $output .= '<img src="' . $value . '" alt="" />'.$remove.'';
139
+ } else {
140
+ $parts = explode( "/", $value );
141
+ for( $i = 0; $i < sizeof( $parts ); ++$i ) {
142
+ $title = $parts[$i];
143
+ }
144
+
145
+ // No output preview if it's not an image.
146
+ $output .= '';
147
 
148
+ // Standard generic output if it's not an image.
149
+ $title = __( 'View File', 'optionsframework' );
150
+ $output .= '<div class="no_image"><span class="file_link"><a href="' . $value . '" target="_blank" rel="external">'.$title.'</a></span>' . $remove . '</div>';
151
+ }
152
+ }
153
+ $output .= '</div>' . "\n";
154
+ return $output;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  }
156
 
157
+ endif;
158
+
159
  /**
160
  * Uses "silent" posts in the database to store relationships for images.
161
  * This also creates the facility to collect galleries of, for example, logo images.
169
  * optionsframework_mlu_get_silentpost ( 'of_logo' );
170
  */
171
 
172
+ if ( ! function_exists( 'optionsframework_mlu_get_silentpost' ) ) :
173
 
174
+ function optionsframework_mlu_get_silentpost ( $_token ) {
175
+
176
+ global $wpdb;
177
+ $_id = 0;
178
+
179
+ // Check if the token is valid against a whitelist.
180
+ // $_whitelist = array( 'of_logo', 'of_custom_favicon', 'of_ad_top_image' );
181
+ // Sanitise the token.
182
 
183
+ $_token = strtolower( str_replace( ' ', '_', $_token ) );
 
184
 
185
+ // if ( in_array( $_token, $_whitelist ) ) {
186
+ if ( $_token ) {
187
+
188
+ // Tell the function what to look for in a post.
189
+
190
+ $_args = array( 'post_type' => 'optionsframework', 'post_name' => 'of-' . $_token, 'post_status' => 'draft', 'comment_status' => 'closed', 'ping_status' => 'closed' );
191
 
192
+ // Look in the database for a "silent" post that meets our criteria.
193
+ $query = 'SELECT ID FROM ' . $wpdb->posts . ' WHERE post_parent = 0';
194
+ foreach ( $_args as $k => $v ) {
195
+ $query .= ' AND ' . $k . ' = "' . $v . '"';
196
+ } // End FOREACH Loop
197
 
198
+ $query .= ' LIMIT 1';
199
+ $_posts = $wpdb->get_row( $query );
200
+
201
+ // If we've got a post, loop through and get it's ID.
202
+ if ( count( $_posts ) ) {
203
+ $_id = $_posts->ID;
204
+ } else {
205
+
206
+ // If no post is present, insert one.
207
+ // Prepare some additional data to go with the post insertion.
208
+ $_words = explode( '_', $_token );
209
+ $_title = join( ' ', $_words );
210
+ $_title = ucwords( $_title );
211
+ $_post_data = array( 'post_title' => $_title );
212
+ $_post_data = array_merge( $_post_data, $_args );
213
+ $_id = wp_insert_post( $_post_data );
214
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
215
  }
216
+ return $_id;
217
  }
218
+ endif;
219
 
220
  /**
221
  * Trigger code inside the Media Library popup.
222
  */
223
 
224
+ if ( ! function_exists( 'optionsframework_mlu_insidepopup' ) ) :
225
+ function optionsframework_mlu_insidepopup () {
226
+ if ( isset( $_REQUEST['is_optionsframework'] ) && $_REQUEST['is_optionsframework'] == 'yes' ) {
227
 
228
+ add_action( 'admin_head', 'optionsframework_mlu_js_popup' );
229
+ add_filter( 'media_upload_tabs', 'optionsframework_mlu_modify_tabs' );
 
 
 
230
  }
231
  }
232
 
233
+ endif;
234
+
235
+ if ( ! function_exists( 'optionsframework_mlu_js_popup' ) ) :
236
 
237
+ function optionsframework_mlu_js_popup () {
238
 
239
+ $_of_title = $_REQUEST['of_title'];
240
+ if ( ! $_of_title ) { $_of_title = 'file'; } // End IF Statement
241
+ ?>
242
  <script type="text/javascript">
 
243
  jQuery(function($) {
244
+
245
  jQuery.noConflict();
246
 
247
  // Change the title of each tab to use the custom title text instead of "Media File".
260
 
261
  // Preserve the "is_optionsframework" parameter on the "delete" confirmation button.
262
  $( '.savesend a.del-link' ).click ( function () {
 
263
  var continueButton = $( this ).next( '.del-attachment' ).children( 'a.button[id*="del"]' );
264
  var continueHref = continueButton.attr( 'href' );
265
  continueHref = continueHref + '&is_optionsframework=yes';
266
  continueButton.attr( 'href', continueHref );
267
+ });
 
 
268
  });
 
269
  </script>
270
  <?php
 
271
  }
272
 
273
+ endif;
274
+
275
  /**
276
  * Triggered inside the Media Library popup to modify the title of the "Gallery" tab.
277
  */
278
 
279
+ if ( ! function_exists( 'optionsframework_mlu_modify_tabs' ) ) :
280
 
281
+ function optionsframework_mlu_modify_tabs ( $tabs ) {
282
+ $tabs['gallery'] = str_replace( __( 'Gallery', 'optionsframework' ), __( 'Previously Uploaded', 'optionsframework' ), $tabs['gallery'] );
283
+ return $tabs;
284
+ }
285
+
286
+ endif;
options-sanitize.php CHANGED
@@ -4,6 +4,10 @@
4
 
5
  add_filter( 'of_sanitize_text', 'sanitize_text_field' );
6
 
 
 
 
 
7
  /* Textarea */
8
 
9
  function of_sanitize_textarea($input) {
@@ -186,7 +190,7 @@ function of_sanitize_typography( $input, $option ) {
186
 
187
  $output['size'] = apply_filters( 'of_font_size', $output['size'] );
188
  $output['style'] = apply_filters( 'of_font_style', $output['style'] );
189
- $output['color'] = apply_filters( 'of_color', $output['color'] );
190
  return $output;
191
  }
192
  add_filter( 'of_sanitize_typography', 'of_sanitize_typography', 10, 2 );
4
 
5
  add_filter( 'of_sanitize_text', 'sanitize_text_field' );
6
 
7
+ /* Password */
8
+
9
+ add_filter( 'of_sanitize_password', 'sanitize_text_field' );
10
+
11
  /* Textarea */
12
 
13
  function of_sanitize_textarea($input) {
190
 
191
  $output['size'] = apply_filters( 'of_font_size', $output['size'] );
192
  $output['style'] = apply_filters( 'of_font_style', $output['style'] );
193
+ $output['color'] = apply_filters( 'of_sanitize_color', $output['color'] );
194
  return $output;
195
  }
196
  add_filter( 'of_sanitize_typography', 'of_sanitize_typography', 10, 2 );
readme.txt CHANGED
@@ -4,8 +4,8 @@ Contributors: Devin Price
4
  Tags: options, theme options
5
  Donate link: http://bit.ly/options-donate
6
  Requires at least: 3.3
7
- Tested up to: 3.4.1
8
- Stable tag: 1.3
9
  License: GPLv2
10
 
11
  == Description ==
@@ -67,6 +67,15 @@ You can also watch the video screencast I have at [http://wptheming.com/options-
67
 
68
  == Changelog ==
69
 
 
 
 
 
 
 
 
 
 
70
  = 1.3 =
71
 
72
  * Allow options to save when set by theme customizer
4
  Tags: options, theme options
5
  Donate link: http://bit.ly/options-donate
6
  Requires at least: 3.3
7
+ Tested up to: 3.5
8
+ Stable tag: 1.4
9
  License: GPLv2
10
 
11
  == Description ==
67
 
68
  == Changelog ==
69
 
70
+ = 1.4 =
71
+
72
+ * Add missing sanitization to typography color (@weplantmedia)
73
+ * New colorpicker (props @mattweibe for getting this in WordPress core)
74
+ * Farsi translations (@vahidd.com)
75
+ * Added password option type (props @neojp)
76
+ * Allow ids to passed to tabs (props @themeblvd)
77
+ * Added optionsframework_after_validate hook (h/t @vanpop and @pryley)
78
+
79
  = 1.3 =
80
 
81
  * Allow options to save when set by theme customizer
screenshot-1.png CHANGED
Binary file