first commit

master
zhy 2 years ago
commit bf5123bc1d

@ -0,0 +1,2 @@
(function($,window,document,undefined){$.fn.exopiteSofFieldACEEditor=function(){return this.each(function(index){if(typeof ace!=='undefined'){var $this=$(this),$textarea=$this.find('.exopite-sof-ace-editor-textarea'),options=JSON.parse($this.find('.exopite-sof-ace-editor-options').val()),plugin=this,editor=ace.edit($this.find('.exopite-sof-ace-editor').attr('id'));editor.getSession().setValue($textarea.val());editor.setOptions(options);editor.on('change',function(e){$textarea.val(editor.getSession().getValue()).trigger('change')});$('.exopite-sof-group').on('exopite-sof-field-group-item-added-before',function(event,$cloned,$group){if($cloned.find('.exopite-sof-ace-editor').length!==0){plugin.musterID=$group.find('.exopite-sof-cloneable__muster .exopite-sof-ace-editor').first().attr('id')+'-';var count=parseInt($group.find('.exopite-sof-ace-editor').filter(function(){return($(this).parents().not('.exopite-sof-cloneable__muster'))}).length);$cloned.find('.exopite-sof-ace-editor').each(function(index,el){$(el).attr('id',plugin.musterID+(count+index))})}});$('.exopite-sof-group').on('exopite-sof-field-group-item-added-after',function(event,$cloned){$cloned.find('.exopite-sof-field-ace_editor').exopiteSofFieldACEEditor()})}})};$(document).ready(function(){if(typeof ace!=='undefined'){var musterID='';$('.exopite-sof-field-group').find('.exopite-sof-field-ace_editor').each(function(index,el){if(!$(this).parents('.exopite-sof-cloneable__muster').length){var $thisEditor=$(this).find('.exopite-sof-ace-editor');var thisId=$thisEditor.attr('id');$thisEditor.attr('id',thisId+'-'+index)}})}
$('.exopite-sof-field-ace_editor').exopiteSofFieldACEEditor()})})(jQuery,window,document)

@ -0,0 +1,76 @@
;(function ( $, window, document, undefined ) {
$.fn.exopiteSofFieldACEEditor = function() {
return this.each(function(index) {
if( typeof ace !== 'undefined' ) {
var $this = $(this),
$textarea = $this.find('.exopite-sof-ace-editor-textarea'),
options = JSON.parse( $this.find( '.exopite-sof-ace-editor-options' ).val() ),
plugin = this,
editor = ace.edit($this.find('.exopite-sof-ace-editor').attr('id'));
// global settings of ace editor
editor.getSession().setValue($textarea.val());
editor.setOptions( options );
editor.on( 'change', function( e ) {
$textarea.val( editor.getSession().getValue() ).trigger('change');
});
$( '.exopite-sof-group' ).on('exopite-sof-field-group-item-added-before', function( event, $cloned, $group ) {
if( $cloned.find( '.exopite-sof-ace-editor' ).length !== 0 ) {
plugin.musterID = $group.find( '.exopite-sof-cloneable__muster .exopite-sof-ace-editor' ).first().attr( 'id' ) + '-';
var count = parseInt( $group.find( '.exopite-sof-ace-editor' ).filter(function () {
return ( $(this).parents().not( '.exopite-sof-cloneable__muster' ) );
}).length );
$cloned.find( '.exopite-sof-ace-editor' ).each(function(index, el) {
$( el ).attr( 'id', plugin.musterID + ( count + index ) );
});
}
});
$( '.exopite-sof-group' ).on('exopite-sof-field-group-item-added-after', function( event, $cloned ) {
$cloned.find( '.exopite-sof-field-ace_editor' ).exopiteSofFieldACEEditor();
});
}
});
};
$( document ).ready(function() {
if( typeof ace !== 'undefined' ) {
var musterID = '';
$( '.exopite-sof-field-group' ).find( '.exopite-sof-field-ace_editor' ).each(function(index, el) {
if ( ! $(this).parents( '.exopite-sof-cloneable__muster' ).length ) {
var $thisEditor = $(this).find('.exopite-sof-ace-editor');
var thisId = $thisEditor.attr('id');
$thisEditor.attr( 'id', thisId + '-' + index );
}
});
}
$( '.exopite-sof-field-ace_editor' ).exopiteSofFieldACEEditor();
});
})( jQuery, window, document );

@ -0,0 +1,578 @@
// jQuery finderSelect: a jQuery plugin that activates selecting elements
// within a parent with Ctrl+Click, Command+Click and Shift+Click.
//
// Copyright 2013 Mike Angell
//
// Please see:
//
// https://github.com/evulse/finderselect
//
// For complete documentation.
(function( $ ) {
var d = $(document);
var b = $('body');
var commands = {
highlight: highlight,
unHighlight: unHighlight,
highlightAll: highlightAll,
unHighlightAll: unHighlightAll,
selected: selected,
children: children,
update: update,
addHook: addHook
};
var hooks = {};
var o = {};
var f = $.fn.finderSelect = function() {
if (typeof arguments[0] === 'string') {
var args = Array.prototype.slice.call(arguments);
args.splice(0, 1);
return commands[arguments[0]].apply(this, args);
}
else {
finderSelect.apply(this, arguments);
return this;
}
};
function finderSelect(opt) {
var p = $(this);
var options = {
selectClass: "selected",
unSelectClass: "un-selected",
currentClass: "selected-current",
lastClass: "selected-last",
shiftClass: "selected-shift",
ctrlClass: "selected-ctrl",
triggerUpdate: "finderSelectUpdate",
children: false,
event: "mousedown",
cursor: "pointer",
dragEvent: "mouseenter",
enableClickDrag: true,
enableShiftClick: true,
enableCtrlClick: true,
enableSingleClick: true,
enableSelectAll: true,
enableDisableSelection: true,
enableTouchCtrlDefault: true,
enableDesktopCtrlDefault: false,
totalSelector: false,
menuSelector: false,
menuXOffset: 0,
menuYOffset: 0
};
$.extend(options, opt);
o = options;
if(!o.children) {
o.children = f.detect.children(p);
}
f.h.off(f.get.siblings(p,o), o);
if(o.cursor) {
f.set.cursor(p,o);
}
if(o.enableDisableSelection) {
f.core.disableSelection(p,o);
}
if(o.enableClickDrag) {
f.core.clickDrag(p,o);
}
if(o.enableSelectAll) {
f.core.selectAll(p,o);
}
if(o.enableShiftClick || o.enableCtrlClick || o.enableSingleClick) {
f.core.click(p,o);
}
if(o.totalSelector) {
f.core.totalUpdate(p,o);
}
if(o.menuSelector) {
f.core.loadMenu(p,o);
}
};
function highlight(el) {
f.h.on(el, o);
return this;
}
function unHighlight(el) {
f.h.off(el, o);
return this;
}
function highlightAll() {
var p = $(this);
f.h.on(p.find(o.children), o);
return this;
}
function unHighlightAll() {
var p = $(this);
f.h.off(p.find(o.children), o);
return this;
}
function selected() {
var p = $(this);
return p.find(o.children+'.'+o.selectClass);
}
function children() {
var p = $(this);
return p.find(o.children);
}
function update() {
var p = $(this);
f.t.update(p, o);
return this;
}
function addHook(hookName, fn) {
if(typeof hookName == "object"){
var i;
for(i=0; i<hookName.length; i++){
var theHook = hookName[i];
if(!hooks[theHook]){
hooks[theHook] = [];
}
hooks[theHook].push(fn);
}
} else {
if(!hooks[hookName]){
hooks[hookName] = [];
}
hooks[hookName].push(fn);
}
return this;
}
f.core = {
clickDrag: function(p,o) {
f.set.mouseDown(false);
b.mousedown(function(e) {
if(f.detect.leftMouse(e)) { f.set.mouseDown(true);}
});
b.mouseup(function(e) {
if(f.detect.leftMouse(e)) { f.set.mouseDown(false);}
});
p.on(o.dragEvent, o.children, function(e){
var c = f.get.clicks(p,o,$(this));
if (f.get.mouseDown() && f.detect.ctrl(e)) {
f.t.deleteSelection(o);
f.t.toggleDrag(p,c,o);
}
});
return p;
},
click: function(p,o) {
p.on(o.event, o.children, function(e){
if(f.detect.leftMouse(e)) {
var c = f.get.clicks(p,o,$(this));
if (!(f.detect.ctrl(e) && o.enableCtrlClick) && (f.detect.shift(e) && o.enableShiftClick)) {
f.t.deleteSelection(o);
f.t.shiftClick(p,c,o);
}
if (((f.detect.ctrl(e) && o.enableCtrlClick) || (f.detect.touch() && o.enableTouchCtrlDefault) || o.enableDesktopCtrlDefault) && !(f.detect.shift(e) && o.enableShiftClick)) {
f.t.toggleClick(p,c,o);
}
if (!(f.detect.ctrl(e) && o.enableCtrlClick) && !(f.detect.shift(e) && o.enableShiftClick) && o.enableSingleClick && !o.enableDesktopCtrlDefault) {
f.t.singleClick(p,c,o);
}
}
});
},
selectAll: function(p,o) {
p.on('mouseover', function(){
d.on("keydown", turnOff);
});
p.on('mouseout', function(){
d.off("keydown", turnOff);
});
function turnOff(e) {
if (f.detect.ctrl(e)) {
if (e.keyCode == 65) {
e.preventDefault();
if(f.detect.alt(e)) {
f.t.unHAll(p, o);
} else {
f.t.hAll(p,o);
}
}
}
console.log(e.keyCode);
if (e.keyCode == 38) {
var last = f.get.click(p, o.shiftClass);
if(last.length == 0) {
last = f.get.click(p, o.lastClass);
}
var cur = f.get.prev(last,o);
if(last.length == 0) {
cur = p.find(o.children).last();
}
if(f.detect.alt(e)) {
cur = p.find(o.children).first();
}
e.preventDefault();
if(cur.length != 0) {
if(f.detect.shift(e) && o.enableShiftClick) {
var c = f.get.clicks(p,o,cur);
f.t.shiftClick(p,c,o);
} else {
var c = f.get.clicks(p,o,cur);
f.t.singleClick(p,c,o);
}
}
}
if (e.keyCode == 40) {
var last = f.get.click(p, o.shiftClass);
if(last.length == 0) {
last = f.get.click(p, o.lastClass);
}
var cur = f.get.next(last,o);
if(last.length == 0) {
cur = p.find(o.children).first();
}
if(f.detect.alt(e)) {
cur = p.find(o.children).last();
}
e.preventDefault();
if(cur.length != 0) {
if(f.detect.shift(e) && o.enableShiftClick) {
var c = f.get.clicks(p,o,cur);
f.t.shiftClick(p,c,o);
} else {
var c = f.get.clicks(p,o,cur);
f.t.singleClick(p,c,o);
}
}
}
}
},
totalUpdate: function(p,o) {
p.on(o.triggerUpdate, function(){
$(o.totalSelector).html($(this).find(o.children).filter('.'+o.selectClass).length)
});
},
loadMenu: function(p, o) {
p.bind("contextmenu",function(e){
$(o.menuSelector).css({left:(e.pageX+o.menuXOffset),top:(e.pageY+o.menuYOffset)}).show();
return false;
}).bind("mousedown",function(){
$(o.menuSelector).hide();
});
$(o.menuSelector).bind("click",function(){
$(this).hide();
});
},
disableSelection: function(p, o) {
d.on('keydown', function(){
p.on("selectstart", turnOffSelection);
}).on('keyup', function(){
p.off("selectstart", turnOffSelection);
});
function turnOffSelection(e) {
e.preventDefault();
}
}
};
f.h = {
on: function(el, o) {
f.get.hook('highlight:before', [el, o]);
el.removeClass(o.unSelectClass);
el.addClass(o.selectClass);
f.get.hook('highlight:after', [el, o]);
},
off: function(el,o) {
f.get.hook('unHighlight:before', [el, o]);
el.removeClass(o.selectClass);
el.addClass(o.unSelectClass);
f.get.hook('unHighlight:after', [el, o]);
},
tog: function(el,o) {
el.each(function () {
var child = $(this);
if(f.detect.h(child, o)) {
f.h.off(child, o);
} else {
f.h.on(child, o);
}
});
},
reset: function(el,o) {
el.each(function () {
var child = $(this);
if(f.detect.lastH(child, o)) {
f.h.on(child, o);
} else {
f.h.off(child, o);
}
});
},
state: function(el,o) {
el.each(function () {
var child = $(this);
if(f.detect.h(child, o)) {
child.removeClass('stateUnSelected');
child.addClass('stateSelected');
} else {
child.removeClass('stateSelected');
child.addClass('stateUnSelected');
}
});
}
};
f.detect = {
leftMouse: function(e) {
return (e.which == 1);
},
shift: function(e) {
return e.shiftKey;
},
alt: function(e) {
return e.altKey;
},
ctrl: function(e) {
return (e.ctrlKey || e.metaKey);
},
h: function(el,o) {
return el.hasClass(o.selectClass);
},
lastH: function(el,o) {
return el.hasClass('stateSelected');
},
touch: function() {
return !!('ontouchstart' in window) // works on most browsers
|| !!('onmsgesturechange' in window); // works on ie10
},
children: function(el) {
return el.children().get(0).tagName;
}
};
f.set = {
clicks: function(curr, shif, ctrl, p, o) {
f.set.click(p, false, o.currentClass);
f.set.click(p, curr, o.lastClass);
f.set.click(p, shif,o.shiftClass);
f.set.click(p, ctrl,o.ctrlClass);
f.t.update(p, o);
},
click: function(p,el,c) {
f.get.click(p,c).removeClass(c);
if(el) { el.addClass(c); }
},
mouseDown: function(bool) {
return b.data('down', bool);
},
cursor: function(p,o) {
var s = f.get.siblings(p,o);
return s.css('cursor', o.cursor);
}
};
f.get = {
clicks: function(p, o, curr) {
var c = {};
f.set.click(p, curr, o.currentClass);
c.current = {v:curr,c: o.currentClass};
c.hard = {v:f.get.click(p, o.lastClass),c:o.lastClass};
c.shift = {v:f.get.click(p, o.shiftClass),c:o.shiftClass};
c.ctrl = {v:f.get.click(p, o.ctrlClass),c:o.ctrlClass};
return c;
},
click: function(p,c) {
return p.find('.'+c);
},
mouseDown: function() {
return b.data('down');
},
siblings: function(p, o) {
return p.find(o.children);
},
between: function(s,y, z) {
if(s.index(y.v) < s.index(z.v)) {
return f.get.elem(true, y.v, false, z.c);
} else {
return f.get.elem(false, y.v, false, z.c);
}
},
elem: function(d, el, s, u) {
var $els = [], $el = (d) ? el.next() : el.prev();
while( $el.length ) {
if(typeof u === 'undefined' || !u || !$el.hasClass(u)) {
if(typeof s === 'undefined' || !s || $el.hasClass(s)) {
$els.push($el[0]);
}
$el = (d) ? $el.next() : $el.prev();
} else {
$el = {};
}
}
return $($els)
},
next: function(p, o) {
return p.next(o.children);
},
prev: function(p, o) {
return p.prev(o.children);
},
hook: function(hookName, data){
var hooked = hooks[hookName]
if(hooked){
for(i=0; i<hooked.length; i++){
hooked[i].apply(undefined, data);
}
}
}
};
f.t = {
update: function(el, o) {
return el.trigger(o.triggerUpdate);
},
deleteSelection: function(o) {
if(o.enableDisableSelection) {
if(document.getSelection) {
var sel = document.getSelection();
if(sel.removeAllRanges) {
sel.removeAllRanges();
}
}
}
},
singleClick: function(p,c,o) {
var s = f.get.siblings(p,o);
f.h.off(s, o);
f.h.on(c.current.v, o);
f.set.clicks(c.current.v, null, null, p, o);
},
toggleClick: function(p,c,o) {
var s = f.get.siblings(p,o);
f.h.tog(c.current.v, o);
f.h.state(s,o);
f.set.clicks(c.current.v, null, null, p, o);
},
toggleClick: function(p,c,o) {
var s = f.get.siblings(p,o);
f.h.tog(c.current.v, o);
f.h.state(s,o);
f.set.clicks(c.current.v, null, null, p, o);
},
toggleDrag: function(p,c,o) {
var s = f.get.siblings(p,o);
f.h.reset(s,o);
if(s.index(c.current.v) != s.index(c.hard.v)) {
f.h.tog(f.get.between(s, c.current, c.hard), o);
f.h.tog(c.current.v, o);
}
f.set.clicks(c.hard.v, null, null, p, o);
},
shiftClick: function(p, c, o) {
var s = f.get.siblings(p,o);
var z = s.index(c.current.v);
var x = s.index(c.hard.v);
if(c.hard.v.length != 0 && !f.detect.h(c.hard.v, o)) {
var start = f.get.elem(true, c.hard.v, o.selectClass);
if(start.length > 0) {
c.hard.v = $(start[0]);
f.set.click(p, c.hard.v, o.lastClass);
} else {
var start = f.get.elem(z < x, c.hard.v, o.selectClass);
if(start.length > 0) {
start = (z > x ) ? $(start[0]) : $(start[start.length-1]);
c.hard.v = start;
f.set.click(p, c.hard.v, o.lastClass);
} else {
c.hard.v = s.first();
f.set.click(p, c.hard.v, o.lastClass);
f.t.singleClick(s,{current:{v:s.first()}},o);
}
}
}
var x = s.index(c.hard.v);
var y = s.index(c.shift.v);
var z = s.index(c.current.v);
if(c.hard.v.length == 0){
f.t.singleClick(s,{current:{v:s.first()}},o);
}
if(c.shift.v.length != 0) {
if((x < y && x < z && z < y) || (x > y && x > z && z > y)) {
f.h.off(f.get.between(s, c.shift, c.current), o);
}
if((x < y && x > z && z < y) || (x > y && x < z && z > y)) {
f.h.off(f.get.between(s, c.shift, c.hard), o);
f.h.on(f.get.between(s, c.current, c.hard), o);
}
if((x > y && x > z && z < y) || (x < y && x < z && z > y) || (x == y)) {
f.h.on(f.get.between(s, c.shift, c.current), o);
} else {
f.h.off(c.shift.v, o);
f.t.unHExist(z>y, c.shift.v,o);
}
} else {
f.t.unHExist(z>x,c.hard.v,o);
f.h.on(f.get.between(s, c.current, c.hard), o);
}
f.h.on(c.current.v, o);
f.set.clicks(c.hard.v, c.current.v, null, p, o);
},
unHAll: function(p,o) {
f.h.off(p.find(o.children), o);
f.t.update(p, o);
},
hAll: function(p,o) {
f.h.on(p.find(o.children), o);
f.t.update(p, o);
},
unHExist: function(bool,el,o) {
if(bool) {
f.h.off(f.get.elem(false, el, false, o.unSelectClass), o);
} else {
f.h.off(f.get.elem(true, el, false, o.unSelectClass), o);
}
}
};
})(window.jQuery || window.Zepto);

@ -0,0 +1,617 @@
/**
* jQuery Interdependencies library
*
* http://miohtama.github.com/jquery-interdependencies/
*
* Copyright 2012-2013 Mikko Ohtamaa, others
*/
/*global console, window*/
(function($) {
"use strict";
/**
* Microsoft safe helper to spit out our little diagnostics information
*
* @ignore
*/
function log(msg) {
if(window.console && window.console.log) {
console.log(msg);
}
}
/**
* jQuery.find() workaround for IE7
*
* If your selector is an pure tag id (#foo) IE7 finds nothing
* if you do jQuery.find() in a specific jQuery context.
*
* This workaround makes a (false) assumptions
* ids are always unique across the page.
*
* @ignore
*
* @param {jQuery} context jQuery context where we look child elements
* @param {String} selector selector as a string
* @return {jQuery} context.find() result
*/
function safeFind(context, selector) {
if(selector[0] == "#") {
// Pseudo-check that this is a simple id selector
// and not a complex jQuery selector
if(selector.indexOf(" ") < 0) {
return $(selector);
}
}
return context.find(selector);
}
/**
* Sample configuration object which can be passed to {@link jQuery.deps#enable}
*
* @class Configuration
*/
var configExample = {
/**
* @cfg show Callback function show(elem) for showing elements
* @type {Function}
*/
show : null,
/**
* @cfg hide Callback function hide(elem) for hiding elements
* @type {Function}
*/
hide : null,
/**
* @cfg log Write console.log() output of rule applying
* @type {Boolean}
*/
log : false,
/**
* @cfg checkTargets When ruleset is enabled, check that all controllers and controls referred by ruleset exist on the page.
*
* @default true
*
* @type {Boolean}
*/
checkTargets : true
};
/**
* Define one field inter-dependency rule.
*
* When condition is true then this input and all
* its children rules' inputs are visible.
*
* Possible condition strings:
*
* * **==** Widget value must be equal to given value
*
* * **any** Widget value must be any of the values in the given value array
*
* * **non-any** Widget value must not be any of the values in the given value array
*
* * **!=** Widget value must not be qual to given value
*
* * **()** Call value as a function(context, controller, ourWidgetValue) and if it's true then the condition is true
*
* * **null** This input does not have any sub-conditions
*
*
*
*/
function Rule(controller, condition, value) {
this.init(controller, condition, value);
}
$.extend(Rule.prototype, {
/**
* @method constructor
*
* @param {String} controller jQuery expression to match the `<input>` source
*
* @param {String} condition What input value must be that {@link Rule the rule takes effective}.
*
* @param value Matching value of **controller** when widgets become visible
*
*/
init : function(controller, condition, value) {
this.controller = controller;
this.condition = condition;
this.value = value;
// Child rules
this.rules = [];
// Controls shown/hidden by this rule
this.controls = [];
},
/**
* Evaluation engine
*
* @param {String} condition Any of given conditions in Rule class description
* @param {Object} val1 The base value we compare against
* @param {Object} val2 Something we got out of input
* @return {Boolean} true or false
*/
evalCondition : function(context, control, condition, val1, val2) {
/**
*
* Codestar Framework
* Added new condition for Codestar Framework
*
* @since 1.0.0
* @version 1.0.0
*
*/
if(condition == "==" || condition == "OR") {
return this.checkBoolean(val1) == this.checkBoolean(val2);
} else if(condition == "!=") {
return this.checkBoolean(val1) != this.checkBoolean(val2);
} else if(condition == ">=") {
return Number(val2) >= Number(val1);
} else if(condition == "<=") {
return Number(val2) <= Number(val1);
} else if(condition == ">") {
return Number(val2) > Number(val1);
} else if(condition == "<") {
return Number(val2) < Number(val1);
} else if(condition == "()") {
return window[val1](context, control, val2); // FIXED: function method
} else if(condition == "any") {
return $.inArray(val2, val1.split(',')) > -1;
} else if(condition == "not-any") {
return $.inArray(val2, val1.split(',')) == -1;
} else {
throw new Error("Unknown condition:" + condition);
}
},
/**
*
* Codestar Framework
* Added Boolean value type checker
*
* @since 1.0.0
* @version 1.0.0
*
*/
checkBoolean: function(value) {
switch(value) {
case true:
case 'true':
case 1:
case '1':
//case 'on':
//case 'yes':
value = true;
break;
case false:
case 'false':
case 0:
case '0':
//case 'off':
//case 'no':
value = false;
break;
}
return value;
},
/**
* Evaluate the condition of this rule in given jQuery context.
*
* The widget value is extracted using getControlValue()
*
* @param {jQuery} context The jQuery selection in which this rule is evaluated.
*
*/
checkCondition : function(context, cfg) {
// We do not have condition set, we are always true
if(!this.condition) {
return true;
}
var control = context.find(this.controller);
if(control.size() === 0 && cfg.log) {
log("Evaling condition: Could not find controller input " + this.controller);
}
var val = this.getControlValue(context, control);
if(cfg.log && val === undefined) {
log("Evaling condition: Could not exctract value from input " + this.controller);
}
if(val === undefined) {
return false;
}
val = this.normalizeValue(control, this.value, val);
return this.evalCondition(context, control, this.condition, this.value, val);
},
/**
* Make sure that what we read from input field is comparable against Javascript primitives
*
*/
normalizeValue : function(control, baseValue, val) {
if(typeof baseValue == "number") {
// Make sure we compare numbers against numbers
return parseFloat(val);
}
return val;
},
/**
* Read value from a diffent HTML controls.
*
* Handle, text, checkbox, radio, select.
*
*/
getControlValue : function(context, control) {
/**
*
* Codestar Framework
* Added multiple checkbox value control
*
* @since 1.0.0
* @version 1.0.0
*
*/
if( ( control.attr("type") == "radio" || control.attr("type") == "checkbox" ) && control.size() > 1 ) {
return control.filter(":checked").val();
}
// Handle individual checkboxes & radio
if ( control.attr("type") == "checkbox" || control.attr("type") == "radio" ) {
return control.is(":checked");
}
return control.val();
},
/**
* Create a sub-rule.
*
* Example:
*
* var masterSwitch = ruleset.createRule("#mechanicalThrombectomyDevice")
* var twoAttempts = masterSwitch.createRule("#numberOfAttempts", "==", 2);
*
* @return Rule instance
*/
createRule : function(controller, condition, value) {
var rule = new Rule(controller, condition, value);
this.rules.push(rule);
return rule;
},
/**
* Include a control in this rule.
*
* @param {String} input jQuery expression to match the input within ruleset context
*/
include : function(input) {
if(!input) {
throw new Error("Must give an input selector");
}
this.controls.push(input);
},
/**
* Apply this rule to all controls in the given context
*
* @param {jQuery} context jQuery selection within we operate
* @param {Object} cfg {@link Configuration} object or undefined
* @param {Object} enforced Recursive rule enforcer: undefined to evaluate condition, true show always, false hide always
*
*/
applyRule : function(context, cfg, enforced) {
var result;
if(enforced === undefined) {
result = this.checkCondition(context, cfg);
} else {
result = enforced;
}
if(cfg.log) {
log("Applying rule on " + this.controller + "==" + this.value + " enforced:" + enforced + " result:" + result);
}
if(cfg.log && !this.controls.length) {
log("Zero length controls slipped through");
}
// Get show/hide callback functions
var show = cfg.show || function(control) {
control.show();
};
var hide = cfg.hide || function(control) {
control.hide();
};
// Resolve controls from ids to jQuery selections
// we are controlling in this context
var controls = $.map(this.controls, function(elem, idx) {
var control = context.find(elem);
if(cfg.log && control.size() === 0) {
log("Could not find element:" + elem);
}
return control;
});
if(result) {
$(controls).each(function() {
// Some friendly debug info
if(cfg.log && $(this).size() === 0) {
log("Control selection is empty when showing");
log(this);
}
show(this);
});
// Evaluate all child rules
$(this.rules).each(function() {
if(this.condition !== "OR"){
this.applyRule(context, cfg);
}
});
} else {
$(controls).each(function() {
// Some friendly debug info
if(cfg.log && $(this).size() === 0) {
log("Control selection is empty when hiding:");
log(this);
}
hide(this);
});
// Supress all child rules
$(this.rules).each(function() {
if(this.condition !== "OR"){
this.applyRule(context, cfg, false);
} else {
this.applyRule(context, cfg);
}
});
}
}
});
/**
* A class which manages interdependenice rules.
*/
function Ruleset() {
// Hold a tree of rules
this.rules = [];
}
$.extend(Ruleset.prototype, {
/**
* Add a new rule into this ruletset.
*
* See {@link Rule} about the contstruction parameters.
* @return {Rule}
*/
createRule : function(controller, condition, value) {
var rule = new Rule(controller, condition, value);
this.rules.push(rule);
return rule;
},
/**
* Apply these rules on an element.
*
* @param {jQuery} context Selection we are dealing with
*
* @param cfg {@link Configuration} object or undefined.
*/
applyRules: function(context, cfg) {
var i;
cfg = cfg || {};
if(cfg.log) {
log("Starting evaluation ruleset of " + this.rules.length + " rules");
}
for(i=0; i<this.rules.length; i++) {
this.rules[i].applyRule(context, cfg);
}
},
/**
* Walk all rules and sub-rules in this ruleset
* @param {Function} callback(rule)
*
* @return {Array} Rules as depth-first searched
*/
walk : function() {
var rules = [];
function descent(rule) {
rules.push(rule);
$(rule.children).each(function() {
descent(this);
});
}
$(this.rules).each(function() {
descent(this);
});
return rules;
},
/**
* Check that all controllers and controls referred in ruleset exist.
*
* Throws an Error if any of them are missing.
*
* @param {jQuery} context jQuery selection of items
*
* @param {Configuration} cfg
*/
checkTargets : function(context, cfg) {
var controls = 0;
var rules = this.walk();
$(rules).each(function() {
if(context.find(this.controller).size() === 0) {
throw new Error("Rule's controller does not exist:" + this.controller);
}
if(this.controls.length === 0) {
throw new Error("Rule has no controls:" + this);
}
$(this.controls).each(function() {
if(safeFind(context, this) === 0) {
throw new Error("Rule's target control " + this + " does not exist in context " + context.get(0));
}
controls++;
});
});
if(cfg.log) {
log("Controller check ok, rules count " + rules.length + " controls count " + controls);
}
},
/**
* Make this ruleset effective on the whole page.
*
* Set event handler on **window.document** to catch all input events
* and apply those events to defined rules.
*
* @param {Configuration} cfg {@link Configuration} object or undefined
*
*/
install : function(cfg) {
$.deps.enable($(document.body), this, cfg);
}
});
/**
* jQuery interdependencie plug-in
*
* @class jQuery.deps
*
*/
var deps = {
/**
* Create a new Ruleset instance.
*
* Example:
*
* $(document).ready(function() {
* // Start creating a new ruleset
* var ruleset = $.deps.createRuleset();
*
*
* @return {Ruleset}
*/
createRuleset : function() {
return new Ruleset();
},
/**
* Enable ruleset on a specific jQuery selection.
*
* Checks the existince of all ruleset controllers and controls
* by default (see config).
*
* See possible IE event bubbling problems: http://stackoverflow.com/q/265074/315168
*
* @param {Object} selection jQuery selection in where we monitor all change events. All controls and controllers must exist within this selection.
* @param {Ruleset} ruleset
* @param {Configuration} cfg
*/
enable : function(selection, ruleset, cfg) {
cfg = cfg || {};
if(cfg.checkTargets || cfg.checkTargets === undefined) {
ruleset.checkTargets(selection, cfg);
}
var self = this;
if(cfg.log) {
log("Enabling dependency change monitoring on " + selection.get(0));
}
// Namespace our handler to avoid conflicts
//
var handler = function() { ruleset.applyRules(selection, cfg); };
var val = selection.on ? selection.on("change.deps", null, null, handler) : selection.live("change.deps", handler);
ruleset.applyRules(selection, cfg);
return val;
}
};
$.deps = deps;
})(jQuery);

@ -0,0 +1,432 @@
.minicolors {
position: relative;
}
.minicolors-sprite {
background-image: url(jquery.minicolors.png);
}
.minicolors-swatch {
position: absolute;
vertical-align: middle;
background-position: -80px 0;
border: solid 1px #ccc;
cursor: text;
padding: 0;
margin: 0;
display: inline-block;
}
.minicolors-swatch-color {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.minicolors input[type=hidden] + .minicolors-swatch {
width: 28px;
position: static;
cursor: pointer;
}
.minicolors input[type=hidden][disabled] + .minicolors-swatch {
cursor: default;
}
/* Panel */
.minicolors-panel {
position: absolute;
width: 173px;
background: white;
border: solid 1px #CCC;
box-shadow: 0 0 20px rgba(0, 0, 0, .2);
z-index: 99999;
box-sizing: content-box;
display: none;
}
.minicolors-panel.minicolors-visible {
display: block;
}
/* Panel positioning */
.minicolors-position-top .minicolors-panel {
top: -154px;
}
.minicolors-position-right .minicolors-panel {
right: 0;
}
.minicolors-position-bottom .minicolors-panel {
top: auto;
}
.minicolors-position-left .minicolors-panel {
left: 0;
}
.minicolors-with-opacity .minicolors-panel {
width: 194px;
}
.minicolors .minicolors-grid {
position: relative;
top: 1px;
left: 1px; /* LTR */
width: 150px;
height: 150px;
margin-bottom: 2px;
background-position: -120px 0;
cursor: crosshair;
}
[dir=rtl] .minicolors .minicolors-grid {
right: 1px;
}
.minicolors .minicolors-grid-inner {
position: absolute;
top: 0;
left: 0;
width: 150px;
height: 150px;
}
.minicolors-slider-saturation .minicolors-grid {
background-position: -420px 0;
}
.minicolors-slider-saturation .minicolors-grid-inner {
background-position: -270px 0;
background-image: inherit;
}
.minicolors-slider-brightness .minicolors-grid {
background-position: -570px 0;
}
.minicolors-slider-brightness .minicolors-grid-inner {
background-color: black;
}
.minicolors-slider-wheel .minicolors-grid {
background-position: -720px 0;
}
.minicolors-slider,
.minicolors-opacity-slider {
position: absolute;
top: 1px;
left: 152px; /* LTR */
width: 20px;
height: 150px;
background-color: white;
background-position: 0 0;
cursor: row-resize;
}
[dir=rtl] .minicolors-slider,
[dir=rtl] .minicolors-opacity-slider {
right: 152px;
}
.minicolors-slider-saturation .minicolors-slider {
background-position: -60px 0;
}
.minicolors-slider-brightness .minicolors-slider {
background-position: -20px 0;
}
.minicolors-slider-wheel .minicolors-slider {
background-position: -20px 0;
}
.minicolors-opacity-slider {
left: 173px; /* LTR */
background-position: -40px 0;
display: none;
}
[dir=rtl] .minicolors-opacity-slider {
right: 173px;
}
.minicolors-with-opacity .minicolors-opacity-slider {
display: block;
}
/* Pickers */
.minicolors-grid .minicolors-picker {
position: absolute;
top: 70px;
left: 70px;
width: 12px;
height: 12px;
border: solid 1px black;
border-radius: 10px;
margin-top: -6px;
margin-left: -6px;
background: none;
}
.minicolors-grid .minicolors-picker > div {
position: absolute;
top: 0;
left: 0;
width: 8px;
height: 8px;
border-radius: 8px;
border: solid 2px white;
box-sizing: content-box;
}
.minicolors-picker {
position: absolute;
top: 0;
left: 0;
width: 18px;
height: 2px;
background: white;
border: solid 1px black;
margin-top: -2px;
box-sizing: content-box;
}
/* Swatches */
.minicolors-swatches,
.minicolors-swatches li {
margin: 5px 0 3px 5px; /* LTR */
padding: 0;
list-style: none;
overflow: hidden;
}
[dir=rtl] .minicolors-swatches,
[dir=rtl] .minicolors-swatches li {
margin: 5px 5px 3px 0;
}
.minicolors-swatches .minicolors-swatch {
position: relative;
float: left; /* LTR */
cursor: pointer;
margin:0 4px 0 0; /* LTR */
}
[dir=rtl] .minicolors-swatches .minicolors-swatch {
float: right;
margin:0 0 0 4px;
}
.minicolors-with-opacity .minicolors-swatches .minicolors-swatch {
margin-right: 7px; /* LTR */
}
[dir=rtl] .minicolors-with-opacity .minicolors-swatches .minicolors-swatch {
margin-right: 0;
margin-left: 7px;
}
.minicolors-swatch.selected {
border-color: #000;
}
/* Inline controls */
.minicolors-inline {
display: inline-block;
}
.minicolors-inline .minicolors-input {
display: none !important;
}
.minicolors-inline .minicolors-panel {
position: relative;
top: auto;
left: auto; /* LTR */
box-shadow: none;
z-index: auto;
display: inline-block;
}
[dir=rtl] .minicolors-inline .minicolors-panel {
right: auto;
}
/* Default theme */
.minicolors-theme-default .minicolors-swatch {
top: 5px;
left: 5px; /* LTR */
width: 18px;
height: 18px;
}
[dir=rtl] .minicolors-theme-default .minicolors-swatch {
right: 5px;
}
.minicolors-theme-default .minicolors-swatches .minicolors-swatch {
margin-bottom: 2px;
top: 0;
left: 0; /* LTR */
width: 18px;
height: 18px;
}
[dir=rtl] .minicolors-theme-default .minicolors-swatches .minicolors-swatch {
right: 0;
}
.minicolors-theme-default.minicolors-position-right .minicolors-swatch {
left: auto; /* LTR */
right: 5px; /* LTR */
}
[dir=rtl] .minicolors-theme-default.minicolors-position-left .minicolors-swatch {
right: auto;
left: 5px;
}
.minicolors-theme-default.minicolors {
width: auto;
display: inline-block;
}
.minicolors-theme-default .minicolors-input {
height: 20px;
width: auto;
display: inline-block;
padding-left: 26px; /* LTR */
}
[dir=rtl] .minicolors-theme-default .minicolors-input {
text-align: right;
unicode-bidi: plaintext;
padding-left: 1px;
padding-right: 26px;
}
.minicolors-theme-default.minicolors-position-right .minicolors-input {
padding-right: 26px; /* LTR */
padding-left: inherit; /* LTR */
}
[dir=rtl] .minicolors-theme-default.minicolors-position-left .minicolors-input {
padding-right: inherit;
padding-left: 26px;
}
/* Bootstrap theme */
.minicolors-theme-bootstrap .minicolors-swatch {
z-index: 2;
top: 3px;
left: 3px; /* LTR */
width: 28px;
height: 28px;
border-radius: 3px;
}
[dir=rtl] .minicolors-theme-bootstrap .minicolors-swatch {
right: 3px;
}
.minicolors-theme-bootstrap .minicolors-swatches .minicolors-swatch {
margin-bottom: 2px;
top: 0;
left: 0; /* LTR */
width: 20px;
height: 20px;
}
[dir=rtl] .minicolors-theme-bootstrap .minicolors-swatches .minicolors-swatch {
right: 0;
}
.minicolors-theme-bootstrap .minicolors-swatch-color {
border-radius: inherit;
}
.minicolors-theme-bootstrap.minicolors-position-right > .minicolors-swatch {
left: auto; /* LTR */
right: 3px; /* LTR */
}
[dir=rtl] .minicolors-theme-bootstrap.minicolors-position-left > .minicolors-swatch {
right: auto;
left: 3px;
}
.minicolors-theme-bootstrap .minicolors-input {
float: none;
padding-left: 44px; /* LTR */
}
[dir=rtl] .minicolors-theme-bootstrap .minicolors-input {
text-align: right;
unicode-bidi: plaintext;
padding-left: 12px;
padding-right: 44px;
}
.minicolors-theme-bootstrap.minicolors-position-right .minicolors-input {
padding-right: 44px; /* LTR */
padding-left: 12px; /* LTR */
}
[dir=rtl] .minicolors-theme-bootstrap.minicolors-position-left .minicolors-input {
padding-right: 12px;
padding-left: 44px;
}
.minicolors-theme-bootstrap .minicolors-input.input-lg + .minicolors-swatch {
top: 4px;
left: 4px; /* LTR */
width: 37px;
height: 37px;
border-radius: 5px;
}
[dir=rtl] .minicolors-theme-bootstrap .minicolors-input.input-lg + .minicolors-swatch {
right: 4px;
}
.minicolors-theme-bootstrap .minicolors-input.input-sm + .minicolors-swatch {
width: 24px;
height: 24px;
}
.minicolors-theme-bootstrap .minicolors-input.input-xs + .minicolors-swatch {
width: 18px;
height: 18px;
}
.input-group .minicolors-theme-bootstrap:not(:first-child) .minicolors-input {
border-top-left-radius: 0; /* LTR */
border-bottom-left-radius: 0; /* LTR */
}
[dir=rtl] .input-group .minicolors-theme-bootstrap .minicolors-input {
border-radius: 4px;
}
[dir=rtl] .input-group .minicolors-theme-bootstrap:not(:first-child) .minicolors-input {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
[dir=rtl] .input-group .minicolors-theme-bootstrap:not(:last-child) .minicolors-input {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
}
/* bootstrap input-group rtl override */
[dir=rtl] .input-group .form-control,
[dir=rtl] .input-group-addon,
[dir=rtl] .input-group-btn > .btn,
[dir=rtl] .input-group-btn > .btn-group > .btn,
[dir=rtl] .input-group-btn > .dropdown-toggle {
border: 1px solid #ccc;
border-radius: 4px;
}
[dir=rtl] .input-group .form-control:first-child,
[dir=rtl] .input-group-addon:first-child,
[dir=rtl] .input-group-btn:first-child > .btn,
[dir=rtl] .input-group-btn:first-child > .btn-group > .btn,
[dir=rtl] .input-group-btn:first-child > .dropdown-toggle,
[dir=rtl] .input-group-btn:last-child > .btn:not(:last-child):not(.dropdown-toggle),
[dir=rtl] .input-group-btn:last-child > .btn-group:not(:last-child) > .btn {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left: 0;
}
[dir=rtl] .input-group .form-control:last-child,
[dir=rtl] .input-group-addon:last-child,
[dir=rtl] .input-group-btn:last-child > .btn,
[dir=rtl] .input-group-btn:last-child > .btn-group > .btn,
[dir=rtl] .input-group-btn:last-child > .dropdown-toggle,
[dir=rtl] .input-group-btn:first-child > .btn:not(:first-child),
[dir=rtl] .input-group-btn:first-child > .btn-group:not(:first-child) > .btn {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
}
/* Semantic Ui theme */
.minicolors-theme-semanticui .minicolors-swatch {
top: 0;
left: 0; /* LTR */
padding: 18px;
}
[dir=rtl] .minicolors-theme-semanticui .minicolors-swatch {
right: 0;
}
.minicolors-theme-semanticui input {
text-indent: 30px;
}

@ -0,0 +1,95 @@
/**
* Exopite Simple Options Framework Trumbowyg
*/
; (function ($, window, document, undefined) {
var pluginName = "exopiteSOFColorpicker";
// The actual plugin constructor
function Plugin(element, options) {
this.element = element;
this._name = pluginName;
this.$element = $(element);
this.init();
}
Plugin.prototype = {
init: function () {
var plugin = this;
plugin.$element.find('.colorpicker').each(function (index, el) {
if ($(el).closest('.exopite-sof-cloneable__item').hasClass('exopite-sof-cloneable__muster')) return;
if ($(el).hasClass('disabled')) return;
$(el).wpColorPicker({
/**
* @param {Event} event - standard jQuery event, produced by whichever
* control was changed.
* @param {Object} ui - standard jQuery UI object, with a color member
* containing a Color.js object.
*/
change: function (event, ui) {
plugin.change(event, ui, $(this));
},
});
});
plugin.$element.closest('.exopite-sof-wrapper').on('exopite-sof-field-group-item-added-after', function (event, $cloned) {
$cloned.find('.colorpicker').each(function (index, el) {
if ($(el).closest('.exopite-sof-cloneable__item').hasClass('exopite-sof-cloneable__muster')) return;
if ($(el).hasClass('disabled')) return;
$(el).wpColorPicker({
change: function (event, ui) {
plugin.change(event, ui, $(this));
},
});
});
console.log('color picker clone');
});
},
change: function (event, ui, $this) {
var color = ui.color.toString();
if ($this.hasClass('font-color-js')) {
console.log('has font-color');
$this.parents('.exopite-sof-font-field').find('.exopite-sof-font-preview').css({ 'color': color });
}
},
};
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName,
new Plugin(this, options));
}
});
};
})(jQuery, window, document);
; (function ($) {
"use strict";
$(document).ready(function () {
$('.exopite-sof-field').exopiteSOFColorpicker();
});
}(jQuery));

@ -0,0 +1,80 @@
/**
* Exopite Simple Options Framework Trumbowyg
*/
; (function ($, window, document, undefined) {
var pluginName = "exopiteSOFDatepicker";
// The actual plugin constructor
function Plugin(element, options) {
this.element = element;
this._name = pluginName;
this.$element = $(element);
this.init();
}
Plugin.prototype = {
init: function () {
var plugin = this;
plugin.$element.find('.datepicker').each(function (index, el) {
if ($(el).parents('.exopite-sof-cloneable__muster').length) return;
if ($(el).hasClass('.disabled')) return;
var dateFormat = $(el).data('format');
$(el).datepicker({ 'dateFormat': dateFormat });
});
plugin.$element.closest('.exopite-sof-wrapper').on('exopite-sof-field-group-item-added-after', function (event, $cloned) {
$cloned.find('.datepicker').each(function (index, el) {
/**
* For some reason, datepicker will be attached to muster.
* Check if exist before added, if yes, firs tremove it.
*/
if ($(el).closest('.exopite-sof-cloneable__item').hasClass('exopite-sof-cloneable__muster')) return;
if ($(el).hasClass('disabled')) return;
if ($(el).hasClass('hasDatepicker')) {
$(el).datepicker("destroy");
$(el).removeClass("hasDatepicker").removeAttr('id');
}
var dateFormat = $(el).data('format');
$(el).datepicker({ 'dateFormat': dateFormat });
});
});
},
};
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName,
new Plugin(this, options));
}
});
};
})(jQuery, window, document);
; (function ($) {
"use strict";
$(document).ready(function () {
$('.exopite-sof-field-date').exopiteSOFDatepicker();
});
}(jQuery));

@ -0,0 +1,104 @@
;(function ( $, window, document, undefined ) {
/*
* A jQuery Plugin Boilerplate
*
* https://github.com/johndugan/jquery-plugin-boilerplate/blob/master/jquery.plugin-boilerplate.js
* https://john-dugan.com/jquery-plugin-boilerplate-explained/
*/
var pluginName = "exopiteFineUploader";
// The actual plugin constructor
function Plugin( element, options ) {
this.element = element;
this._name = pluginName;
this.$element = $( element );
this.init();
}
Plugin.prototype = {
init: function() {
// console.log( 'maxsize: ' + this.$element.data('maxsize') );
// console.log( 'allowedExtensions: ' + this.$element.data('mimetypes') );
var ajaxUrl = this.$element.data('ajaxurl');
this.$element.fineUploader({
template: 'qq-template-manual-trigger',
request: {
endpoint: ajaxUrl,
// Admin AJAX Param
params: {
action: 'exopite-sof-file_uploader',
postId: this.$element.data('postid')
},
paramsInBody: true
},
deleteFile: {
/**
* Delete file on AJAX request with qquuid
*
* @link https://docs.fineuploader.com/features/delete.html
* @link https://docs.fineuploader.com/branch/master/api/options.html#deleteFile
*/
method: 'POST',
endpoint: ajaxUrl,
params: {
action: 'exopite-sof-file_uploader',
},
enabled : this.$element.data('delete-enabled'),
forceConfirm : this.$element.data('delete-force-confirm')
},
retry: {
enableAuto : this.$element.data('retry-enable-auto'),
maxAutoAttempts : this.$element.data('retry-max-auto-attempts'),
autoAttemptDelay : this.$element.data('retry-auto-attempt-delay'),
},
validation: {
allowedExtensions: this.$element.data('mimetypes').split(','),
sizeLimit: this.$element.data('maxsize'),
itemLimit: this.$element.data('filecount')
},
autoUpload: this.$element.data('auto-upload'),
debug: true
});
this.bindEvents();
},
// Bind events that trigger methods
bindEvents: function() {
var plugin = this;
plugin.$element.find( '.trigger-upload' ).on( 'click'+'.'+plugin._name, function() {
plugin.$element.fineUploader('uploadStoredFiles');
});
},
};
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName,
new Plugin( this, options ));
}
});
};
$( document ).ready(function() {
$('.qq-template').exopiteFineUploader();
});
})( jQuery, window, document );

@ -0,0 +1,16 @@
;(function( $ ) {
"use strict";
$( document ).ready(function() {
$( '.exopite-sof-field-select ').find( 'select.chosen' ).each(function(index, el) {
$( el ).chosen({
disable_search_threshold: 15,
width: '375px',
allow_single_deselect: true
});
});
});
}(jQuery));

@ -0,0 +1,124 @@
;(function ( $, window, document, undefined ) {
/*
* A jQuery Plugin Boilerplate
*
* https://github.com/johndugan/jquery-plugin-boilerplate/blob/master/jquery.plugin-boilerplate.js
* https://john-dugan.com/jquery-plugin-boilerplate-explained/
*/
var pluginName = "exopiteAttachmentRemover";
// The actual plugin constructor
function Plugin( element, options ) {
this.element = element;
this._name = pluginName;
this.$element = $( element );
this.init();
}
Plugin.prototype = {
init: function() {
this.bindEvents();
},
// Bind events that trigger methods
bindEvents: function() {
var plugin = this;
plugin.$element.find( '.exopite-sof-attachment-media-js' ).on( 'click'+'.'+plugin._name, function( event ) {
plugin.toggleSelect.call( plugin, $( this ), event );
});
},
toggleSelect: function( $this, event ) {
if ( event.ctrlKey ) {
$this.toggleClass( 'selected' );
} else {
var already_selected = $this.hasClass( 'selected' );
this.$element.find( '.exopite-sof-attachment-media-js' ).removeClass( 'selected' );
if ( ! already_selected ) {
$this.addClass( 'selected' );
}
}
},
};
$.fn[pluginName] = function ( options ) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName,
new Plugin( this, options ));
}
});
};
$( document ).ready(function() {
// $( '.exopite-sof-attachment-container' ).exopiteAttachmentRemover();
var finderSelect = $( '.exopite-sof-attachment-container' ).finderSelect({children:".exopite-sof-attachment-media-js"});
finderSelect.on( "mousedown",".exopite-sof-attachment-media-delete-js", function(e){
e.stopPropagation();
});
$( '.exopite-sof-attachment-media-delete-js' ).on('click', function(event) {
var $attachmentContainer = $( this ).closest( '.exopite-sof-attachment-container' );
var ajaxUrl = $attachmentContainer.data('ajaxurl');
var attachmentIDs = new Array();
$attachmentContainer.find( '.selected' ).each(function(index, el) {
attachmentIDs.push( $( el ).data( 'media-id' ) );
});
var confirmDelete = confirm( "Are you sure, you want to delete the selected " + attachmentIDs.length + " media?" );
if ( confirmDelete == true ) {
var dataJSON = {
'action': 'exopite-sof-file-batch-delete',
'media-ids': attachmentIDs
};
$.ajax({
cache: false,
type: "POST",
url: ajaxUrl,
data: dataJSON,
success: function( response ){
var ids = jQuery.parseJSON( response );
$.each( ids, function(index, item) {
$attachmentContainer.find("[data-media-id='" + item + "']").remove();
});
},
error: function( xhr, status, error ) {
console.log( 'Status: ' + xhr.status );
console.log( 'Error: ' + xhr.responseText );
}
});
}
});
});
})( jQuery, window, document );

@ -0,0 +1,86 @@
/**
* Exopite Simple Options Framework Trumbowyg
*/
; (function ($, window, document, undefined) {
var pluginName = "exopiteSOFTrumbowyg";
// The actual plugin constructor
function Plugin(element, options) {
this.element = element;
this._name = pluginName;
this.$element = $(element);
this.init();
}
Plugin.prototype = {
init: function () {
var plugin = this;
plugin.trumbowygOptions = new Object();
plugin.trumbowygOptions.svgPath = plugin.$element.find('.trumbowyg-js').data('icon-path');
plugin.trumbowygOptions.btnsDef = {
// Customizables dropdowns
image: {
dropdown: ['insertImage', 'base64'],
ico: 'insertImage',
}
};
plugin.trumbowygOptions.btns = [
['viewHTML'],
['undo', 'redo'],
['formatting'],
['strong', 'em'],
['link'],
['image'],
['unorderedList', 'orderedList'],
['foreColor', 'backColor'],
['preformatted'],
['fullscreen']
];
// plugin.$element.find('.trumbowyg-js').not('.disabled').trumbowyg(plugin.trumbowygOptions);
plugin.$element.find('.trumbowyg-js').not(':disabled').trumbowyg(plugin.trumbowygOptions);
var $group = plugin.$element.closest('.exopite-sof-group');
// $group.on('exopite-sof-field-group-item-added-after', function (event, $cloned) {
plugin.$element.on('exopite-sof-field-group-item-added-after', function (event, $cloned) {
console.log('test exopite-sof-field-group-item-added-after');
$cloned.find('.trumbowyg-js').not(':disabled').trumbowyg(plugin.trumbowygOptions);
});
},
};
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName,
new Plugin(this, options));
}
});
};
})(jQuery, window, document);
; (function ($) {
"use strict";
$(document).ready(function () {
$('.exopite-sof-wrapper').exopiteSOFTrumbowyg();
});
}(jQuery));

@ -0,0 +1,114 @@
/**
* Exopite Simple Options Framework Color Picker
*
* https://tovic.github.io/color-picker/#section:extend
* https://bgrins.github.io/spectrum/
* https://www.jqueryscript.net/other/Color-Picker-Plugin-jQuery-MiniColors.html
* - https://www.jqueryscript.net/demo/Color-Picker-Plugin-jQuery-MiniColors/
* https://www.jqueryscript.net/other/Color-Picker-Plugin-jQuery-ChromoSelector.html
*/
; (function ($, window, document, undefined) {
var pluginName = "exopiteSOFMinicolors";
// The actual plugin constructor
function Plugin(element, options) {
this.element = element;
this._name = pluginName;
this.$element = $(element);
this.init();
}
Plugin.prototype = {
init: function () {
var plugin = this;
plugin.minicolorOptions = {
theme: 'default',
swatches: '#000|#fff|#f00|#dd9933|#eeee22|#81d742|#1e73be|#8224e3|#2196f3|#4caf50|#ffeb3b|#ff9800|#795548|rgba(0, 0, 0, 0)'.split('|'),
change: function(value, opacity) {
plugin.change(value, opacity, $(this));
if( !value ) return;
},
hide : function() {
let color = $(this).val();
$(this).val( plugin.rgb2hex(color) );
}
};
plugin.$element.find('.minicolor').each(function (index, el) {
if ($(el).closest('.exopite-sof-cloneable__item').hasClass('exopite-sof-cloneable__muster')) return;
if ($(el).hasClass('disabled')) return;
plugin.minicolorOptions.opacity = $(el).attr('data-opacity') || false;
plugin.minicolorOptions.control = $(el).attr('data-control') || 'saturation';
plugin.minicolorOptions.format = $(el).attr('data-format') || 'rgb';
$(el).minicolors(plugin.minicolorOptions);
});
plugin.$element.closest('.exopite-sof-wrapper').on('exopite-sof-field-group-item-added-after', function (event, $cloned) {
$cloned.find('.minicolor').each(function (index, el) {
if ($(el).closest('.exopite-sof-cloneable__item').hasClass('exopite-sof-cloneable__muster')) return;
if ($(el).hasClass('disabled')) return;
$(el).minicolors(plugin.minicolorOptions);
});
});
},
rgb2hex: function (rgb){
var plugin = this;
rgba = rgb.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?1[\s+]?\)/i);
console.log('rgba: ' + rgba);
if (rgba === null) return rgb;
return (rgba && rgba.length === 4) ? "#" +
("0" + parseInt(rgba[1],10).toString(16)).slice(-2) +
("0" + parseInt(rgba[2],10).toString(16)).slice(-2) +
("0" + parseInt(rgba[3],10).toString(16)).slice(-2) : '';
},
change: function (value, opacity, $this) {
var plugin = this;
var color = value;
if ($this.hasClass('font-color-js')) {
console.log('has font-color');
$this.parents('.exopite-sof-font-field').find('.exopite-sof-font-preview').css({ 'color': color });
}
$this.val( plugin.rgb2hex(color) );
},
};
$.fn[pluginName] = function (options) {
return this.each(function () {
if (!$.data(this, "plugin_" + pluginName)) {
$.data(this, "plugin_" + pluginName,
new Plugin(this, options));
}
});
};
})(jQuery, window, document);
; (function ($) {
"use strict";
$(document).ready(function () {
$('.exopite-sof-field').exopiteSOFMinicolors();
});
}(jQuery));

@ -0,0 +1,496 @@
/**!
* wp-color-picker-alpha
*
* Overwrite Automattic Iris for enabled Alpha Channel in wpColorPicker
* Only run in input and is defined data alpha in true
*
* Version: 2.1.3
* https://github.com/kallookoo/wp-color-picker-alpha
* Licensed under the GPLv2 license.
*/
( function( $ ) {
// Prevent double-init.
if ( $.wp.wpColorPicker.prototype._hasAlpha ) {
return;
}
// Variable for some backgrounds ( grid )
var image = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAAHnlligAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAHJJREFUeNpi+P///4EDBxiAGMgCCCAGFB5AADGCRBgYDh48CCRZIJS9vT2QBAggFBkmBiSAogxFBiCAoHogAKIKAlBUYTELAiAmEtABEECk20G6BOmuIl0CIMBQ/IEMkO0myiSSraaaBhZcbkUOs0HuBwDplz5uFJ3Z4gAAAABJRU5ErkJggg==',
// html stuff for wpColorPicker copy of the original color-picker.js
_after = '<div class="wp-picker-holder" />',
_wrap = '<div class="wp-picker-container" />',
_button = '<input type="button" class="button button-small" />',
// Prevent CSS issues in < WordPress 4.9
_deprecated = ( wpColorPickerL10n.current !== undefined );
// Declare some global variables when is deprecated or not
if ( _deprecated ) {
var _before = '<a tabindex="0" class="wp-color-result" />';
} else {
var _before = '<button type="button" class="button wp-color-result" aria-expanded="false"><span class="wp-color-result-text"></span></button>',
_wrappingLabel = '<label></label>',
_wrappingLabelText = '<span class="screen-reader-text"></span>';
}
/**
* Overwrite Color
* for enable support rbga
*/
Color.fn.toString = function() {
if ( this._alpha < 1 )
return this.toCSS( 'rgba', this._alpha ).replace( /\s+/g, '' );
var hex = parseInt( this._color, 10 ).toString( 16 );
if ( this.error )
return '';
if ( hex.length < 6 )
hex = ( '00000' + hex ).substr( -6 );
return '#' + hex;
};
/**
* Overwrite wpColorPicker
*/
$.widget( 'wp.wpColorPicker', $.wp.wpColorPicker, {
_hasAlpha: true,
/**
* @summary Creates the color picker.
*
* Creates the color picker, sets default values, css classes and wraps it all in HTML.
*
* @since 3.5.0
*
* @access private
*
* @returns {void}
*/
_create: function() {
// Return early if Iris support is missing.
if ( ! $.support.iris ) {
return;
}
var self = this,
el = self.element;
// Override default options with options bound to the element.
$.extend( self.options, el.data() );
// Create a color picker which only allows adjustments to the hue.
if ( self.options.type === 'hue' ) {
return self._createHueOnly();
}
// Bind the close event.
self.close = $.proxy( self.close, self );
self.initialValue = el.val();
// Add a CSS class to the input field.
el.addClass( 'wp-color-picker' );
if ( _deprecated ) {
el.hide().wrap( _wrap );
self.wrap = el.parent();
self.toggler = $( _before )
.insertBefore( el )
.css( { backgroundColor : self.initialValue } )
.attr( 'title', wpColorPickerL10n.pick )
.attr( 'data-current', wpColorPickerL10n.current );
self.pickerContainer = $( _after ).insertAfter( el );
self.button = $( _button ).addClass('hidden');
} else {
/*
* Check if there's already a wrapping label, e.g. in the Customizer.
* If there's no label, add a default one to match the Customizer template.
*/
if ( ! el.parent( 'label' ).length ) {
// Wrap the input field in the default label.
el.wrap( _wrappingLabel );
// Insert the default label text.
self.wrappingLabelText = $( _wrappingLabelText )
.insertBefore( el )
.text( wpColorPickerL10n.defaultLabel );
}
/*
* At this point, either it's the standalone version or the Customizer
* one, we have a wrapping label to use as hook in the DOM, let's store it.
*/
self.wrappingLabel = el.parent();
// Wrap the label in the main wrapper.
self.wrappingLabel.wrap( _wrap );
// Store a reference to the main wrapper.
self.wrap = self.wrappingLabel.parent();
// Set up the toggle button and insert it before the wrapping label.
self.toggler = $( _before )
.insertBefore( self.wrappingLabel )
.css( { backgroundColor: self.initialValue } );
// Set the toggle button span element text.
self.toggler.find( '.wp-color-result-text' ).text( wpColorPickerL10n.pick );
// Set up the Iris container and insert it after the wrapping label.
self.pickerContainer = $( _after ).insertAfter( self.wrappingLabel );
// Store a reference to the Clear/Default button.
self.button = $( _button );
}
// Set up the Clear/Default button.
if ( self.options.defaultColor ) {
self.button.addClass( 'wp-picker-default' ).val( wpColorPickerL10n.defaultString );
if ( ! _deprecated ) {
self.button.attr( 'aria-label', wpColorPickerL10n.defaultAriaLabel );
}
} else {
self.button.addClass( 'wp-picker-clear' ).val( wpColorPickerL10n.clear );
if ( ! _deprecated ) {
self.button.attr( 'aria-label', wpColorPickerL10n.clearAriaLabel );
}
}
if ( _deprecated ) {
el.wrap( '<span class="wp-picker-input-wrap" />' ).after( self.button );
} else {
// Wrap the wrapping label in its wrapper and append the Clear/Default button.
self.wrappingLabel
.wrap( '<span class="wp-picker-input-wrap hidden" />' )
.after( self.button );
/*
* The input wrapper now contains the label+input+Clear/Default button.
* Store a reference to the input wrapper: we'll use this to toggle
* the controls visibility.
*/
self.inputWrapper = el.closest( '.wp-picker-input-wrap' );
}
el.iris( {
target: self.pickerContainer,
hide: self.options.hide,
width: self.options.width,
mode: self.options.mode,
palettes: self.options.palettes,
/**
* @summary Handles the onChange event if one has been defined in the options.
*
* Handles the onChange event if one has been defined in the options and additionally
* sets the background color for the toggler element.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
* @param {HTMLElement} ui The HTMLElement containing the color picker.
*
* @returns {void}
*/
change: function( event, ui ) {
if ( self.options.alpha ) {
self.toggler.css( { 'background-image' : 'url(' + image + ')' } );
if ( _deprecated ) {
self.toggler.html( '<span class="color-alpha" />' );
} else {
self.toggler.css( {
'position' : 'relative'
} );
if ( self.toggler.find('span.color-alpha').length == 0 ) {
self.toggler.append('<span class="color-alpha" />');
}
}
self.toggler.find( 'span.color-alpha' ).css( {
'width' : '30px',
'height' : '24px',
'position' : 'absolute',
'top' : 0,
'left' : 0,
'border-top-left-radius' : '2px',
'border-bottom-left-radius' : '2px',
'background' : ui.color.toString()
} );
} else {
self.toggler.css( { backgroundColor : ui.color.toString() } );
}
if ( $.isFunction( self.options.change ) ) {
self.options.change.call( this, event, ui );
}
}
} );
el.val( self.initialValue );
self._addListeners();
// Force the color picker to always be closed on initial load.
if ( ! self.options.hide ) {
self.toggler.click();
}
},
/**
* @summary Binds event listeners to the color picker.
*
* @since 3.5.0
*
* @access private
*
* @returns {void}
*/
_addListeners: function() {
var self = this;
/**
* @summary Prevent any clicks inside this widget from leaking to the top and closing it.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returs {void}
*/
self.wrap.on( 'click.wpcolorpicker', function( event ) {
event.stopPropagation();
});
/**
* @summary Open or close the color picker depending on the class.
*
* @since 3.5
*/
self.toggler.click( function(){
if ( self.toggler.hasClass( 'wp-picker-open' ) ) {
self.close();
} else {
self.open();
}
});
/**
* @summary Checks if value is empty when changing the color in the color picker.
*
* Checks if value is empty when changing the color in the color picker.
* If so, the background color is cleared.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returns {void}
*/
self.element.on( 'change', function( event ) {
// Empty or Error = clear
if ( $( this ).val() === '' || self.element.hasClass( 'iris-error' ) ) {
if ( self.options.alpha ) {
if ( _deprecated ) {
self.toggler.removeAttr( 'style' );
}
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
} else {
self.toggler.css( 'backgroundColor', '' );
}
// fire clear callback if we have one
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
}
} );
/**
* @summary Enables the user to clear or revert the color in the color picker.
*
* Enables the user to either clear the color in the color picker or revert back to the default color.
*
* @since 3.5.0
*
* @param {Event} event The event that's being called.
*
* @returns {void}
*/
self.button.on( 'click', function( event ) {
if ( $( this ).hasClass( 'wp-picker-clear' ) ) {
self.element.val( '' );
if ( self.options.alpha ) {
if ( _deprecated ) {
self.toggler.removeAttr( 'style' );
}
self.toggler.find( 'span.color-alpha' ).css( 'backgroundColor', '' );
} else {
self.toggler.css( 'backgroundColor', '' );
}
if ( $.isFunction( self.options.clear ) )
self.options.clear.call( this, event );
} else if ( $( this ).hasClass( 'wp-picker-default' ) ) {
self.element.val( self.options.defaultColor ).change();
}
});
},
});
/**
* Overwrite iris
*/
$.widget( 'a8c.iris', $.a8c.iris, {
_create: function() {
this._super();
// Global option for check is mode rbga is enabled
this.options.alpha = this.element.data( 'alpha' ) || false;
// Is not input disabled
if ( ! this.element.is( ':input' ) )
this.options.alpha = false;
if ( typeof this.options.alpha !== 'undefined' && this.options.alpha ) {
var self = this,
el = self.element,
_html = '<div class="iris-strip iris-slider iris-alpha-slider"><div class="iris-slider-offset iris-slider-offset-alpha"></div></div>',
aContainer = $( _html ).appendTo( self.picker.find( '.iris-picker-inner' ) ),
aSlider = aContainer.find( '.iris-slider-offset-alpha' ),
controls = {
aContainer : aContainer,
aSlider : aSlider
};
if ( typeof el.data( 'custom-width' ) !== 'undefined' ) {
self.options.customWidth = parseInt( el.data( 'custom-width' ) ) || 0;
} else {
self.options.customWidth = 100;
}
// Set default width for input reset
self.options.defaultWidth = el.width();
// Update width for input
if ( self._color._alpha < 1 || self._color.toString().indexOf('rgb') != -1 )
el.width( parseInt( self.options.defaultWidth + self.options.customWidth ) );
// Push new controls
$.each( controls, function( k, v ) {
self.controls[k] = v;
} );
// Change size strip and add margin for sliders
self.controls.square.css( { 'margin-right': '0' } );
var emptyWidth = ( self.picker.width() - self.controls.square.width() - 20 ),
stripsMargin = ( emptyWidth / 6 ),
stripsWidth = ( ( emptyWidth / 2 ) - stripsMargin );
$.each( [ 'aContainer', 'strip' ], function( k, v ) {
self.controls[v].width( stripsWidth ).css( { 'margin-left' : stripsMargin + 'px' } );
} );
// Add new slider
self._initControls();
// For updated widget
self._change();
}
},
_initControls: function() {
this._super();
if ( this.options.alpha ) {
var self = this,
controls = self.controls;
controls.aSlider.slider({
orientation : 'vertical',
min : 0,
max : 100,
step : 1,
value : parseInt( self._color._alpha * 100 ),
slide : function( event, ui ) {
// Update alpha value
self._color._alpha = parseFloat( ui.value / 100 );
self._change.apply( self, arguments );
}
});
}
},
_change: function() {
this._super();
var self = this,
el = self.element;
if ( this.options.alpha ) {
var controls = self.controls,
alpha = parseInt( self._color._alpha * 100 ),
color = self._color.toRgb(),
gradient = [
'rgb(' + color.r + ',' + color.g + ',' + color.b + ') 0%',
'rgba(' + color.r + ',' + color.g + ',' + color.b + ', 0) 100%'
],
defaultWidth = self.options.defaultWidth,
customWidth = self.options.customWidth,
target = self.picker.closest( '.wp-picker-container' ).find( '.wp-color-result' );
// Generate background slider alpha, only for CSS3 old browser fuck!! :)
controls.aContainer.css( { 'background' : 'linear-gradient(to bottom, ' + gradient.join( ', ' ) + '), url(' + image + ')' } );
if ( target.hasClass( 'wp-picker-open' ) ) {
// Update alpha value
controls.aSlider.slider( 'value', alpha );
/**
* Disabled change opacity in default slider Saturation ( only is alpha enabled )
* and change input width for view all value
*/
if ( self._color._alpha < 1 ) {
controls.strip.attr( 'style', controls.strip.attr( 'style' ).replace( /rgba\(([0-9]+,)(\s+)?([0-9]+,)(\s+)?([0-9]+)(,(\s+)?[0-9\.]+)\)/g, 'rgb($1$3$5)' ) );
el.width( parseInt( defaultWidth + customWidth ) );
} else {
el.width( defaultWidth );
}
}
}
var reset = el.data( 'reset-alpha' ) || false;
if ( reset ) {
self.picker.find( '.iris-palette-container' ).on( 'click.palette', '.iris-palette', function() {
self._color._alpha = 1;
self.active = 'external';
self._change();
} );
}
},
_addInputListeners: function( input ) {
var self = this,
debounceTimeout = 100,
callback = function( event ) {
var color = new Color( input.val() ),
val = input.val();
input.removeClass( 'iris-error' );
// we gave a bad color
if ( color.error ) {
// don't error on an empty input
if ( val !== '' )
input.addClass( 'iris-error' );
} else {
if ( color.toString() !== self._color.toString() ) {
// let's not do this on keyup for hex shortcodes
if ( ! ( event.type === 'keyup' && val.match( /^[0-9a-fA-F]{3}$/ ) ) )
self._setOption( 'color', color.toString() );
}
}
};
input.on( 'change', callback ).on( 'keyup', self._debounce( callback, debounceTimeout ) );
// If we initialized hidden, show on first focus. The rest is up to you.
if ( self.options.hide ) {
input.on( 'focus', function() {
self.show();
} );
}
}
} );
}( jQuery ) );
// Auto Call plugin is class is color-picker
jQuery( document ).ready( function( $ ) {
$( '.color-picker' ).wpColorPicker();
} );

@ -0,0 +1,9 @@
/**
* jQuery Interdependencies library
*
* http://miohtama.github.com/jquery-interdependencies/
* https://github.com/miohtama/jquery-interdependencies
*
* Copyright 2012-2013 Mikko Ohtamaa, others
*/
!function(t){"use strict";function n(t){window.console&&window.console.log&&console.log(t)}function e(n,e){return"#"==e[0]&&e.indexOf(" ")<0?t(e):n.find(e)}function o(t,n,e){this.init(t,n,e)}function i(){this.rules=[]}t.extend(o.prototype,{init:function(t,n,e){this.controller=t,this.condition=n,this.value=e,this.rules=[],this.controls=[]},evalCondition:function(n,e,o,i,r){if("=="==o||"OR"==o)return this.checkBoolean(i)==this.checkBoolean(r);if("!="==o)return this.checkBoolean(i)!=this.checkBoolean(r);if(">="==o)return Number(r)>=Number(i);if("<="==o)return Number(r)<=Number(i);if(">"==o)return Number(r)>Number(i);if("<"==o)return Number(r)<Number(i);if("()"==o)return window[i](n,e,r);if("any"==o)return t.inArray(r,i.split(","))>-1;if("not-any"==o)return-1==t.inArray(r,i.split(","));throw new Error("Unknown condition:"+o)},checkBoolean:function(t){switch(t){case!0:case"true":case 1:case"1":t=!0;break;case!1:case"false":case 0:case"0":t=!1}return t},checkCondition:function(t,e){if(!this.condition)return!0;var o=t.find(this.controller);0===o.size()&&e.log&&n("Evaling condition: Could not find controller input "+this.controller);var i=this.getControlValue(t,o);return e.log&&void 0===i&&n("Evaling condition: Could not exctract value from input "+this.controller),void 0!==i&&(i=this.normalizeValue(o,this.value,i),this.evalCondition(t,o,this.condition,this.value,i))},normalizeValue:function(t,n,e){return"number"==typeof n?parseFloat(e):e},getControlValue:function(t,n){return("radio"==n.attr("type")||"checkbox"==n.attr("type"))&&n.size()>1?n.filter(":checked").val():"checkbox"==n.attr("type")||"radio"==n.attr("type")?n.is(":checked"):n.val()},createRule:function(t,n,e){var i=new o(t,n,e);return this.rules.push(i),i},include:function(t){if(!t)throw new Error("Must give an input selector");this.controls.push(t)},applyRule:function(e,o,i){var r;r=void 0===i?this.checkCondition(e,o):i,o.log&&n("Applying rule on "+this.controller+"=="+this.value+" enforced:"+i+" result:"+r),o.log&&!this.controls.length&&n("Zero length controls slipped through");var l=o.show||function(t){t.show()},s=o.hide||function(t){t.hide()},c=t.map(this.controls,function(t,i){var r=e.find(t);return o.log&&0===r.size()&&n("Could not find element:"+t),r});r?(t(c).each(function(){o.log&&0===t(this).size()&&(n("Control selection is empty when showing"),n(this)),l(this)}),t(this.rules).each(function(){"OR"!==this.condition&&this.applyRule(e,o)})):(t(c).each(function(){o.log&&0===t(this).size()&&(n("Control selection is empty when hiding:"),n(this)),s(this)}),t(this.rules).each(function(){"OR"!==this.condition?this.applyRule(e,o,!1):this.applyRule(e,o)}))}}),t.extend(i.prototype,{createRule:function(t,n,e){var i=new o(t,n,e);return this.rules.push(i),i},applyRules:function(t,e){var o;for((e=e||{}).log&&n("Starting evaluation ruleset of "+this.rules.length+" rules"),o=0;o<this.rules.length;o++)this.rules[o].applyRule(t,e)},walk:function(){function n(o){e.push(o),t(o.children).each(function(){n(this)})}var e=[];return t(this.rules).each(function(){n(this)}),e},checkTargets:function(o,i){var r=0,l=this.walk();t(l).each(function(){if(0===o.find(this.controller).size())throw new Error("Rule's controller does not exist:"+this.controller);if(0===this.controls.length)throw new Error("Rule has no controls:"+this);t(this.controls).each(function(){if(0===e(o,this))throw new Error("Rule's target control "+this+" does not exist in context "+o.get(0));r++})}),i.log&&n("Controller check ok, rules count "+l.length+" controls count "+r)},install:function(n){t.deps.enable(t(document.body),this,n)}});var r={createRuleset:function(){return new i},enable:function(t,e,o){((o=o||{}).checkTargets||void 0===o.checkTargets)&&e.checkTargets(t,o);o.log&&n("Enabling dependency change monitoring on "+t.get(0));var i=function(){e.applyRules(t,o)},r=t.on?t.on("change.deps",null,null,i):t.live("change.deps",i);return e.applyRules(t,o),r}};t.deps=r}(jQuery);

@ -0,0 +1 @@
!function(e,o,t,i){var n="exopiteSOFColorpicker";function s(o,t){this.element=o,this._name=n,this.$element=e(o),this.init()}s.prototype={init:function(){var o=this;o.$element.find(".colorpicker").each(function(t,i){e(i).closest(".exopite-sof-cloneable__item").hasClass("exopite-sof-cloneable__muster")||e(i).hasClass("disabled")||e(i).wpColorPicker({change:function(t,i){o.change(t,i,e(this))}})}),o.$element.closest(".exopite-sof-wrapper").on("exopite-sof-field-group-item-added-after",function(t,i){i.find(".colorpicker").each(function(t,i){e(i).closest(".exopite-sof-cloneable__item").hasClass("exopite-sof-cloneable__muster")||e(i).hasClass("disabled")||e(i).wpColorPicker({change:function(t,i){o.change(t,i,e(this))}})}),console.log("color picker clone")})},change:function(e,o,t){var i=o.color.toString();t.hasClass("font-color-js")&&(console.log("has font-color"),t.parents(".exopite-sof-font-field").find(".exopite-sof-font-preview").css({color:i}))}},e.fn[n]=function(o){return this.each(function(){e.data(this,"plugin_"+n)||e.data(this,"plugin_"+n,new s(this,o))})}}(jQuery,window,document),function(e){"use strict";e(document).ready(function(){e(".exopite-sof-field").exopiteSOFColorpicker()})}(jQuery);

@ -0,0 +1 @@
!function(e,t,i,a){var s="exopiteSOFDatepicker";function n(t,i){this.element=t,this._name=s,this.$element=e(t),this.init()}n.prototype={init:function(){this.$element.find(".datepicker").each(function(t,i){if(!e(i).parents(".exopite-sof-cloneable__muster").length&&!e(i).hasClass(".disabled")){var a=e(i).data("format");e(i).datepicker({dateFormat:a})}}),this.$element.closest(".exopite-sof-wrapper").on("exopite-sof-field-group-item-added-after",function(t,i){i.find(".datepicker").each(function(t,i){if(!e(i).closest(".exopite-sof-cloneable__item").hasClass("exopite-sof-cloneable__muster")&&!e(i).hasClass("disabled")){e(i).hasClass("hasDatepicker")&&(e(i).datepicker("destroy"),e(i).removeClass("hasDatepicker").removeAttr("id"));var a=e(i).data("format");e(i).datepicker({dateFormat:a})}})})}},e.fn[s]=function(t){return this.each(function(){e.data(this,"plugin_"+s)||e.data(this,"plugin_"+s,new n(this,t))})}}(jQuery,window,document),function(e){"use strict";e(document).ready(function(){e(".exopite-sof-field-date").exopiteSOFDatepicker()})}(jQuery);

@ -0,0 +1 @@
!function(e,t,a,i){function n(t,a){this.element=t,this._name=o,this.$element=e(t),this.init()}var o="exopiteFineUploader";n.prototype={init:function(){var e=this.$element.data("ajaxurl");this.$element.fineUploader({template:"qq-template-manual-trigger",request:{endpoint:e,params:{action:"exopite-sof-file_uploader",postId:this.$element.data("postid")},paramsInBody:!0},deleteFile:{method:"POST",endpoint:e,params:{action:"exopite-sof-file_uploader"},enabled:this.$element.data("delete-enabled"),forceConfirm:this.$element.data("delete-force-confirm")},retry:{enableAuto:this.$element.data("retry-enable-auto"),maxAutoAttempts:this.$element.data("retry-max-auto-attempts"),autoAttemptDelay:this.$element.data("retry-auto-attempt-delay")},validation:{allowedExtensions:this.$element.data("mimetypes").split(","),sizeLimit:this.$element.data("maxsize"),itemLimit:this.$element.data("filecount")},autoUpload:this.$element.data("auto-upload"),debug:!0}),this.bindEvents()},bindEvents:function(){var e=this;e.$element.find(".trigger-upload").on("click."+e._name,function(){e.$element.fineUploader("uploadStoredFiles")})}},e.fn[o]=function(t){return this.each(function(){e.data(this,"plugin_"+o)||e.data(this,"plugin_"+o,new n(this,t))})},e(a).ready(function(){e(".qq-template").exopiteFineUploader()})}(jQuery,window,document);

@ -0,0 +1 @@
!function(n){"use strict";n(document).ready(function(){n(".exopite-sof-field").find("select.chosen").each(function(e,c){n(c).chosen({disable_search_threshold:15,width:"375px",allow_single_deselect:!0})})})}(jQuery);

@ -0,0 +1 @@
!function(e,t,n,i){function a(t,n){this.element=t,this._name=o,this.$element=e(t),this.init()}var o="exopiteAttachmentRemover";a.prototype={init:function(){this.bindEvents()},bindEvents:function(){var t=this;t.$element.find(".exopite-sof-attachment-media-js").on("click."+t._name,function(n){t.toggleSelect.call(t,e(this),n)})},toggleSelect:function(e,t){if(t.ctrlKey)e.toggleClass("selected");else{var n=e.hasClass("selected");this.$element.find(".exopite-sof-attachment-media-js").removeClass("selected"),n||e.addClass("selected")}}},e.fn[o]=function(t){return this.each(function(){e.data(this,"plugin_"+o)||e.data(this,"plugin_"+o,new a(this,t))})},e(n).ready(function(){e(".exopite-sof-attachment-container").finderSelect({children:".exopite-sof-attachment-media-js"}).on("mousedown",".exopite-sof-attachment-media-delete-js",function(e){e.stopPropagation()}),e(".exopite-sof-attachment-media-delete-js").on("click",function(t){var n=e(this).closest(".exopite-sof-attachment-container"),i=n.data("ajaxurl"),a=new Array;if(n.find(".selected").each(function(t,n){a.push(e(n).data("media-id"))}),1==confirm("Are you sure, you want to delete the selected "+a.length+" media?")){var o={action:"exopite-sof-file-batch-delete","media-ids":a};e.ajax({cache:!1,type:"POST",url:i,data:o,success:function(t){var i=jQuery.parseJSON(t);e.each(i,function(e,t){n.find("[data-media-id='"+t+"']").remove()})},error:function(e,t,n){console.log("Status: "+e.status),console.log("Error: "+e.responseText)}})}})})}(jQuery,window,document);

@ -0,0 +1 @@
!function(t,e,o,n){var i="exopiteSOFTrumbowyg";function r(e,o){this.element=e,this._name=i,this.$element=t(e),this.init()}r.prototype={init:function(){var t=this;t.trumbowygOptions=new Object,t.trumbowygOptions.svgPath=t.$element.find(".trumbowyg-js").data("icon-path"),t.trumbowygOptions.btnsDef={image:{dropdown:["insertImage","base64"],ico:"insertImage"}},t.trumbowygOptions.btns=[["viewHTML"],["undo","redo"],["formatting"],["strong","em"],["link"],["image"],["unorderedList","orderedList"],["foreColor","backColor"],["preformatted"],["fullscreen"]],t.$element.find(".trumbowyg-js").not(":disabled").trumbowyg(t.trumbowygOptions);t.$element.closest(".exopite-sof-group");t.$element.on("exopite-sof-field-group-item-added-after",function(e,o){console.log("test exopite-sof-field-group-item-added-after"),o.find(".trumbowyg-js").not(":disabled").trumbowyg(t.trumbowygOptions)})}},t.fn[i]=function(e){return this.each(function(){t.data(this,"plugin_"+i)||t.data(this,"plugin_"+i,new r(this,e))})}}(jQuery,window,document),function(t){"use strict";t(document).ready(function(){t(".exopite-sof-wrapper").exopiteSOFTrumbowyg()})}(jQuery);

@ -0,0 +1 @@
!function(t,o,e,i){var n="exopiteSOFMinicolors";function s(o,e){this.element=o,this._name=n,this.$element=t(o),this.init()}s.prototype={init:function(){var o=this;o.minicolorOptions={theme:"default",swatches:"#000|#fff|#f00|#dd9933|#eeee22|#81d742|#1e73be|#8224e3|#2196f3|#4caf50|#ffeb3b|#ff9800|#795548|rgba(0, 0, 0, 0)".split("|"),change:function(e,i){o.change(e,i,t(this))},hide:function(){let e=t(this).val();t(this).val(o.rgb2hex(e))}},o.$element.find(".minicolor").each(function(e,i){t(i).closest(".exopite-sof-cloneable__item").hasClass("exopite-sof-cloneable__muster")||t(i).hasClass("disabled")||(o.minicolorOptions.opacity=t(i).attr("data-opacity")||!1,o.minicolorOptions.control=t(i).attr("data-control")||"saturation",o.minicolorOptions.format=t(i).attr("data-format")||"rgb",t(i).minicolors(o.minicolorOptions))}),o.$element.closest(".exopite-sof-wrapper").on("exopite-sof-field-group-item-added-after",function(e,i){i.find(".minicolor").each(function(e,i){t(i).closest(".exopite-sof-cloneable__item").hasClass("exopite-sof-cloneable__muster")||t(i).hasClass("disabled")||t(i).minicolors(o.minicolorOptions)})})},rgb2hex:function(t){return rgba=t.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?1[\s+]?\)/i),console.log("rgba: "+rgba),null===rgba?t:rgba&&4===rgba.length?"#"+("0"+parseInt(rgba[1],10).toString(16)).slice(-2)+("0"+parseInt(rgba[2],10).toString(16)).slice(-2)+("0"+parseInt(rgba[3],10).toString(16)).slice(-2):""},change:function(t,o,e){var i=t;e.hasClass("font-color-js")&&(console.log("has font-color"),e.parents(".exopite-sof-font-field").find(".exopite-sof-font-preview").css({color:i})),e.val(this.rgb2hex(i))}},t.fn[n]=function(o){return this.each(function(){t.data(this,"plugin_"+n)||t.data(this,"plugin_"+n,new s(this,o))})}}(jQuery,window,document),function(t){"use strict";t(document).ready(function(){t(".exopite-sof-field").exopiteSOFMinicolors()})}(jQuery);

@ -0,0 +1 @@
!function(){var a={},b=function(b){for(var c=a[b],e=c.deps,f=c.defn,g=e.length,h=new Array(g),i=0;i<g;++i)h[i]=d(e[i]);var j=f.apply(null,h);if(void 0===j)throw"module ["+b+"] returned undefined";c.instance=j},c=function(b,c,d){if("string"!=typeof b)throw"module id must be a string";if(void 0===c)throw"no dependencies for "+b;if(void 0===d)throw"no definition function for "+b;a[b]={deps:c,defn:d,instance:void 0}},d=function(c){var d=a[c];if(void 0===d)throw"module ["+c+"] was undefined";return void 0===d.instance&&b(c),d.instance},e=function(a,b){for(var c=a.length,e=new Array(c),f=0;f<c;++f)e.push(d(a[f]));b.apply(null,b)},f={};f.bolt={module:{api:{define:c,require:e,demand:d}}};var g=c,h=function(a,b){g(a,[],function(){return b})};h("3",tinymce.util.Tools.resolve),g("1",["3"],function(a){return a("tinymce.dom.DOMUtils")}),g("2",["3"],function(a){return a("tinymce.PluginManager")}),g("0",["1","2"],function(a,b){return b.add("code",function(b){function c(){var c=b.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:b.getParam("code_dialog_width",600),minHeight:b.getParam("code_dialog_height",Math.min(a.DOM.getViewPort().h-200,500)),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(a){b.focus(),b.undoManager.transact(function(){b.setContent(a.data.code)}),b.selection.setCursorLocation(),b.nodeChanged()}});c.find("#code").value(b.getContent({source_view:!0}))}b.addCommand("mceCodeEditor",c),b.addButton("code",{icon:"code",tooltip:"Source code",onclick:c}),b.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:c})}),function(){}}),d("0")()}();

@ -0,0 +1,320 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Options Class
*
* @since 1.0.0
* @version 1.0.0
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Fields' ) ) {
abstract class Exopite_Simple_Options_Framework_Fields {
public $field;
public $value;
public $org_value;
public $unique;
public $config;
public $where;
public $multilang;
public $lang_default;
public $lang_current;
public $languages;
public $is_multilang;
public function __construct( $field = array(), $value = null, $unique = '', $config = array() ) {
$this->field = $field;
$this->value = $value;
$this->org_value = $value;
$this->unique = $unique;
$this->config = $config;
$this->where = ( isset( $this->config['type'] ) ) ? $this->config['type'] : '';
$this->multilang = ( isset( $this->config['multilang'] ) ) ? $this->config['multilang'] : false;
$this->is_multilang = ( isset( $this->config['is_multilang'] ) ) ? (bool) $this->config['is_multilang'] : false;
$this->google_fonts = '';
$this->lang_default = ( $this->multilang && isset( $this->multilang['default'] ) ) ? $this->multilang['default'] : mb_substr( get_locale(), 0, 2 );
$this->lang_current = ( $this->multilang && isset( $this->multilang['current'] ) ) ? $this->multilang['current'] : $this->lang_default;
$this->languages = (
$this->multilang &&
isset( $this->multilang['languages'] ) &&
is_array( $this->multilang['languages'] )
) ? $this->multilang['languages'] : array( $this->lang_default );
}
/*
* @return bool true if multilang is set to true
*/
public function is_multilang() {
return $this->is_multilang;
}
abstract public function output();
public function element_before() {
$element = 'div';
if ( isset( $this->field['pseudo'] ) && $this->field['pseudo'] ) {
$element = 'span';
}
return ( isset( $this->field['before'] ) ) ? '<' . $element . ' class="exopite-sof-before">' . $this->field['before'] . '</' . $element . '>' : '';
}
public function element_after() {
$out = ( isset( $this->field['info'] ) ) ? '<span class="exopite-sof-text-desc">' . $this->field['info'] . '</span>' : '';
$out .= $this->element_help();
$out .= ( isset( $this->field['after'] ) ) ? '<div class="exopite-sof-after">' . $this->field['after'] . '</div>' : '';
// $out .= $this->element_get_error();
return $out;
}
public function element_prepend() {
$out = '';
if ( isset( $this->field['prepend'] ) || isset( $this->field['append'] ) ) {
$out .= '<span class="exopite-sof-form-field exopite-sof-form-field-input">';
}
if ( isset( $this->field['prepend'] ) ) {
$out .= '<span class="input-prepend">';
if ( strpos( $this->field['prepend'], 'fa-' ) !== false ) {
$out .= '<i class="fa ' . $this->field['prepend'] . '" aria-hidden="true"></i>';
} elseif ( strpos( $this->field['prepend'], 'dashicons' ) !== false ) {
$out .= '<span class="dashicons ' . $this->field['prepend'] . '"></span>';
} else {
$out .= $this->field['prepend'];
}
$out .= '</span>';
}
return $out;
}
public function element_append() {
$out = '';
if ( isset( $this->field['append'] ) ) {
$out .= '<span class="input-append">';
if ( strpos( $this->field['append'], 'fa-' ) !== false ) {
$out .= '<i class="fa ' . $this->field['append'] . '" aria-hidden="true"></i>';
} elseif ( strpos( $this->field['append'], 'dashicons' ) !== false ) {
$out .= '<span class="dashicons ' . $this->field['append'] . '"></span>';
} else {
$out .= $this->field['append'];
}
$out .= '</span>';
}
if ( isset( $this->field['prepend'] ) || isset( $this->field['append'] ) ) {
$out .= '</span>';
}
return $out;
}
public function element_help() {
return ( isset( $this->field['help'] ) ) ? '<span class="exopite-sof-help" title="' . $this->field['help'] . '" data-title="' . $this->field['help'] . '"><span class="fa fa-question"></span></span>' : '';
}
public function element_type() {
return $this->field['type'];
}
public function element_name( $extra_name = '' ) {
$extra_multilang = ( isset( $this->config['is_multilang'] ) && ( $this->config['is_multilang'] === true ) ) ? '[' . $this->lang_current . ']' : '';
// for some reason this not work, maybe because abstract class
// $extra_multilang = ( $this->is_multilang() ) ? '[' . $this->lang_current . ']' : '';
// Because we changed to unique, this will determinate if it is a "sub" field. Sub field is inside group.
if ( isset( $this->field['sub'] ) ) {
$name = $this->unique . '[' . $this->field['id'] . ']' . $extra_name;
} else {
if ( $this->config['is_options_simple'] ) {
$name = $this->field['id'] . $extra_name;
} else {
// This is the actual
$name = $this->unique . $extra_multilang . '[' . $this->field['id'] . ']' . $extra_name;
}
}
return ( ! empty( $this->unique ) ) ? $name : '';
}
public function element_value( $value = null ) {
$value = $this->value;
if ( ! isset( $value ) && isset( $this->field['default'] ) && ! empty( $this->field['default'] ) ) {
$default = $this->field['default'];
if ( is_array( $default ) ) {
if ( isset( $default['function'] ) && is_callable( $default['function'] ) ) {
$args = ( isset( $default['args'] ) ) ? $default['args'] : '';
return call_user_func( $default['function'], $args );
}
}
return $default;
}
return $value;
}
public function element_attributes( $el_attributes = array() ) {
$attributes = ( isset( $this->field['attributes'] ) ) ? $this->field['attributes'] : array();
$element_id = ( isset( $this->field['id'] ) ) ? $this->field['id'] : '';
if ( $el_attributes !== false ) {
$sub_element = ( isset( $this->field['sub'] ) ) ? 'sub-' : '';
$el_attributes = ( is_string( $el_attributes ) || is_numeric( $el_attributes ) ) ? array( 'data-' . $sub_element . 'depend-id' => $element_id . '_' . $el_attributes ) : $el_attributes;
$el_attributes = ( empty( $el_attributes ) && isset( $element_id ) ) ? array( 'data-' . $sub_element . 'depend-id' => $element_id ) : $el_attributes;
}
$attributes = wp_parse_args( $attributes, $el_attributes );
$atts = '';
if ( ! empty( $attributes ) ) {
foreach ( $attributes as $key => $value ) {
if ( $value === 'only-key' ) {
$atts .= ' ' . $key;
} else {
$atts .= ' ' . $key . '="' . $value . '"';
}
}
}
return $atts;
}
public function element_class( $el_class = '' ) {
$classes = ( isset( $this->field['class'] ) ) ? array_merge( explode( ' ', $el_class ), explode( ' ', $this->field['class'] ) ) : explode( ' ', $el_class );
$classes = array_filter( $classes );
$field_class = implode( ' ', $classes );
return ( ! empty( $field_class ) ) ? ' class="' . $field_class . '"' : '';
}
public function checked( $value = '', $current = '', $type = 'checked', $echo = false ) {
$value = maybe_unserialize( $value );
if ( is_array( $value ) && in_array( $current, $value ) ) {
$result = ' ' . $type . '="' . $type . '"';
} else if ( $value == $current ) {
$result = ' ' . $type . '="' . $type . '"';
} else {
$result = '';
}
if ( $echo ) {
echo $result;
}
return $result;
}
public function get_google_fonts_json() {
if( empty( $this->google_fonts ) ) {
$google_fonts_json_fn = implode( DIRECTORY_SEPARATOR, array( __DIR__, 'assets', 'google-fonts.json' ) );
if ( file_exists( $google_fonts_json_fn ) ) {
$google_fonts_json = file_get_contents( $google_fonts_json_fn );
$this->google_fonts = json_decode( $google_fonts_json );
}
}
return $this->google_fonts;
}
public static function do_enqueue( $styles_scripts, $args ) {
foreach ( $styles_scripts as $resource ) {
$resource_file = join( DIRECTORY_SEPARATOR, array(
$args['plugin_sof_path'] . 'assets',
$resource['fn']
) );
$resource_url = join( '/', array(
untrailingslashit( $args['plugin_sof_url'] ),
'assets',
$resource['fn']
) );
if ( ! file_exists( $resource_file ) ) {
continue;
}
if ( ! empty( $resource['version'] ) ) {
$version = $resource['version'];
} else {
$version = filemtime( $resource_file );
}
switch ( $resource['type'] ) {
case 'script':
$function = 'wp_enqueue_script';
break;
case 'style':
$function = 'wp_enqueue_style';
break;
default:
continue 2;
}
$function( $resource['name'], $resource_url, $resource['dependency'], $version, $resource['attr'] );
}
}
}
}

@ -0,0 +1,101 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Tab
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_accordion' ) ) {
class Exopite_Simple_Options_Framework_Field_accordion extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array(), $multilang ) {
parent::__construct( $field, $value, $unique, $config, $multilang );
$this->defaults = array(
'section_title' => esc_attr( 'Section Title', 'exopite-sof' ),
'closed' => true,
'allow_all_open' => true,
);
$this->is_accordion_closed = ( isset( $this->field['options']['closed'] ) ) ? (bool) $this->field['options']['closed'] : $this->defaults['closed'];
$this->allow_all_open = ( isset( $this->field['options']['allow_all_open'] ) ) ? (bool) $this->field['options']['allow_all_open'] : $this->defaults['allow_all_open'];
}
public function output() {
echo $this->element_before();
$unallows = array( 'accordion' );
$sections = array_values( $this->field['sections'] );
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
$self = new Exopite_Simple_Options_Framework( array(
'id' => $this->element_name(),
'multilang' => $this->config['multilang'],
'is_options_simple' => $this->config['is_options_simple'],
), null );
echo '<div class="exopite-sof-accordion">';
echo '<div class="exopite-sof-accordion__wrapper" data-all-open="' . $this->allow_all_open . '">';
/**
* Accordion items
*/
foreach ( $sections as $key => $section ) {
$is_section_closed = ( isset( $section['options']['closed'] ) ) ? (bool) $section['options']['closed'] : $this->defaults['closed'];
$section_title = ( isset( $section['options']['title'] ) ) ? esc_attr( $section['options']['title'] ) : $this->defaults['section_title'];
$muster_classes = array();
if ( $is_section_closed && $this->is_accordion_closed ) {
$muster_classes[] = 'exopite-sof-accordion--hidden';
}
echo '<div class="exopite-sof-cloneable__item exopite-sof-accordion__item ' . implode( ' ', $muster_classes ) . '">';
echo '<h4 class="exopite-sof-cloneable__title exopite-sof-accordion__title">' . $section_title . '</h4>';
echo '<div class="exopite-sof-accordion__content">';
foreach ( $section['fields'] as $field ) {
if ( in_array( $field['type'], $unallows ) ) {
$field['_notice'] = true;
continue;
}
$self->include_field_class( array( 'type' => $field['type'] ) );
$self->enqueue_field_class( array( 'type' => $field['type'] ) );
$field_value = '';
if ( isset( $this->value[ $field['id'] ] ) ) {
$field_value = $this->value[ $field['id'] ];
} elseif ( isset( $field['default'] ) ) {
$field_value = $field['default'];
}
echo $self->add_field( $field, $field_value );
}
echo '</div>'; // exopite-sof-accordion__content
echo '</div>'; // exopite-sof-accordion__title
}
echo '</div>'; // exopite-sof-accordion__wrapper
echo '</div>'; // exopite-sof-accordion
echo $this->element_after();
}
}
}

@ -0,0 +1,101 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Ace Editor
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_ace_editor' ) ) {
class Exopite_Simple_Options_Framework_Field_ace_editor extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$editor_id = $this->field['id'];
$defaults = array(
'theme' => 'ace/theme/chrome',
'mode' => 'ace/mode/javascript',
'showGutter' => true,
'showPrintMargin' => true,
'enableBasicAutocompletion' => true,
'enableSnippets' => true,
'enableLiveAutocompletion' => true,
);
$options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
$options = json_encode( wp_parse_args( $options, $defaults ) );
echo $this->element_before();
echo '<div class="exopite-sof-ace-editor-wrapper">';
echo '<div id="exopite-sof-ace-' . $editor_id . '" class="exopite-sof-ace-editor"' . $this->element_attributes() . '></div>';
echo '</div>';
echo '<textarea class="exopite-sof-ace-editor-textarea hidden" name="' . $this->element_name() . '">' . $this->element_value() . '</textarea>';
echo '<textarea class="exopite-sof-ace-editor-options hidden">' . $options . '</textarea>';
echo $this->element_after();
}
public static function enqueue( $args ) {
//https://cdnjs.com/libraries/ace/
// wp_enqueue_script( 'ace-editor', '//cdnjs.cloudflare.com/ajax/libs/ace/1.2.4/ace.js', array( 'jquery' ), '1.2.4', true );
//
// wp_enqueue_script( 'ace-editor-language_tool', '//cdnjs.cloudflare.com/ajax/libs/ace/1.2.9/ext-language_tools.js', array( 'ace-editor' ), '1.2.4', true );
//
// $script_file = 'ace-loader.min.js';
// $script_name = 'exopite-sof-ace-loader';
//
// wp_enqueue_script( $script_name, $args['plugin_sof_url'] . 'assets/' . $script_file, array( 'ace-editor-language_tool' ), filemtime( join( DIRECTORY_SEPARATOR, array(
// $args['plugin_sof_path'] . 'assets',
// $script_file
// ) ) ), true );
/**
* For some reason this is not working. :-O
* Maybe ace.js file is corrupted? Tried to download twice.
*/
$resources = array(
array(
'name' => 'ace-editor',
'fn' => 'editors/ace/ace.js',
'type' => 'script',
'dependency' => array( 'jquery' ),
'version' => '1.2.4',
'attr' => true,
),
array(
'name' => 'ace-editor-language_tool',
'fn' => 'editors/ace/ext-language_tools.js',
'type' => 'script',
'dependency' => array( 'ace-editor' ),
'version' => '1.2.4',
'attr' => true,
),
array(
'name' => 'exopite-sof-ace-loader',
'fn' => 'ace-loader.min.js',
'type' => 'script',
'dependency' => array( 'ace-editor-language_tool' ),
'version' => '',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

@ -0,0 +1,107 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Attached
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_attached' ) ) {
class Exopite_Simple_Options_Framework_Field_attached extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $where = '' ) {
parent::__construct( $field, $value, $unique, $where );
$defaults = array(
'type' => 'image',
);
$options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
$this->field['options'] = wp_parse_args( $options, $defaults );
}
public function output() {
echo $this->element_before();
if ( $this->where != 'metabox' ) {
echo 'This item only available in metabox!<br>';
} else {
$attachment_type = ( isset( $this->field['options'] ) && isset( $this->field['options']['type'] ) ) ? $this->field['options']['type'] : '';
$images = get_attached_media( $attachment_type, get_the_ID() );
$post_type = get_post_type_object( get_post_type( get_the_ID() ) );
if ( count( $images ) == 0 ) {
printf( esc_attr__( 'There is no attachment with type %s for this %s.', 'exopite-sof' ), $this->field['options']['type'], esc_html( $post_type->labels->singular_name ) );
} else {
echo '<div class="exopite-sof-attachment-container" data-ajaxurl="' . site_url( 'wp-admin/admin-ajax.php' ) . '">';
foreach ( $images as $image ) { ?>
<span class="exopite-sof-attachment-media exopite-sof-attachment-media-js"
data-media-id="<?php echo $image->ID; ?>"><span
class="exopite-sof-attachment-media-delete-overlay"></span><span
class="exopite-sof-attachment-media-delete exopite-sof-attachment-media-delete-js"><i
class="fa fa-times" aria-hidden="true"></i></span><img
src="<?php echo wp_get_attachment_image_src( $image->ID, 'thumbnail' )[0]; ?>"/></span>
<?php }
echo '</div>';
}
}
echo $this->element_after();
}
public static function enqueue( $args ) {
// wp_enqueue_script( 'jquery-finderselect', $args['plugin_sof_url'] . 'assets/jquery.finderSelect.min.js', array( 'jquery' ), '0.7.0', true );
// $script_file = 'loader-jquery-finderselect.min.js';
// $script_name = 'exopite-sof-jquery-finderselect-loader';
// wp_enqueue_script( $script_name, $args['plugin_sof_url'] . 'assets/' . $script_file, array( 'jquery-finderselect' ), filemtime( join( DIRECTORY_SEPARATOR, array(
// $args['plugin_sof_path'] . 'assets',
// $script_file
// ) ) ), true );
$resources = array(
array(
'name' => 'jquery-finderselect',
'fn' => 'jquery.finderSelect.min.js',
'type' => 'script',
'dependency' => array( 'jquery' ),
'version' => '0.7.0',
'attr' => true,
),
array(
'name' => 'exopite-sof-jquery-finderselect-loader',
'fn' => 'loader-jquery-finderselect.min.js',
'type' => 'script',
'dependency' => array( 'jquery-finderselect' ),
'version' => '',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

@ -0,0 +1,103 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Backup
*
* @since 1.0.0
* @version 1.0.0
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_backup' ) ) {
class Exopite_Simple_Options_Framework_Field_backup extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
if ( $this->config['type'] == 'menu' ) {
$nonce = wp_create_nonce( 'exopite_sof_backup' );
$options = get_option( $this->unique );
$export = esc_url( add_query_arg( array(
'action' => 'exopite-sof-export-options',
'export' => $this->unique,
'wpnonce' => $nonce
), admin_url( 'admin-ajax.php' ) ) );
$encoded_options = '';
if ( $options ) {
$encoded_options = $this->encode_string( $options );
}
echo '<textarea name="_nonce" class="exopite-sof__import"></textarea>';
echo '<small class="exopite-sof-info--small">( ' . esc_attr__( 'copy-paste your backup string here', 'exopite-sof' ) . ' )</small>';
echo '<a href="#" class="button button-primary exopite-sof-import-js" data-confirm="' . esc_attr__( 'Are you sure, you want to overwrite existing options?', 'exopite-sof' ) . '">' . esc_attr__( 'Import a Backup', 'exopite-sof' ) . '</a>';
echo '<hr />';
echo '<textarea name="_nonce" class="exopite-sof__export" readonly>' . $encoded_options . '</textarea>';
echo '<a href="' . $export . '" class="button button-primary" target="_blank">' . esc_attr__( 'Download Backup', 'exopite-sof' ) . '</a>';
echo '<hr />';
echo '<small class="exopite-sof-info--small exopite-sof-info--warning">' . esc_attr__( 'Please be sure for reset all of framework options.', 'exopite-sof' ) . '</small>';
echo '<a href="#" class="button button-warning exopite-sof-reset-js" data-confirm="' . esc_attr__( 'Are you sure, you want to reset all options?', 'exopite-sof' ) . '">' . esc_attr__( 'Reset All Options', 'exopite-sof' ) . '</a>';
echo '<div class="exopite-sof--data" data-admin="' . admin_url( 'admin-ajax.php' ) . '" data-unique="' . $this->unique . '" data-wpnonce="' . $nonce . '"></div>';
} else {
echo 'This item only available in menu!<br>';
}
echo $this->element_after();
}
/**
* Encode string for backup options
*/
function encode_string( $option ) {
return json_encode( $option );
// return rtrim( strtr( call_user_func( 'base' . '64' . '_encode', addslashes( gzcompress( serialize( $option ), 9 ) ) ), '+/', '-_' ), '=' );
}
/**
* Decode string for backup options
*/
function decode_string( $option ) {
return json_decode( $_POST['value'], true );
// return unserialize( gzuncompress( stripslashes( call_user_func( 'base' . '64' . '_decode', rtrim( strtr( $option, '-_', '+/' ), '=' ) ) ) ) );
}
public static function enqueue( $args ) {
/*
* https://sweetalert.js.org/guides/
*/
// wp_enqueue_script( 'sweetalert', '//unpkg.com/sweetalert/dist/sweetalert.min.js', false, '2.1.0', true );
$resources = array(
array(
'name' => 'sweetalert',
'fn' => 'sweetalert.min.js',
'type' => 'script',
'dependency' => false,
'version' => '2.1.0',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

@ -0,0 +1,51 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Button
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_button' ) ) {
class Exopite_Simple_Options_Framework_Field_button extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
$defaults = array(
'href' => '',
'target' => '_self',
'value' => 'button',
'btn-class' => 'exopite-sof-btn',
'btn-id' => '',
);
$options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
$this->field['options'] = wp_parse_args( $options, $defaults );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
echo $this->element_before();
echo '<a ';
if ( ! empty( $this->field['options']['href'] ) ) {
echo 'href="' . $this->field['options']['href'] . '"';
}
if ( ! empty( $this->field['options']['btn-id'] ) ) {
echo ' id="' . $this->field['options']['btn-id'] . '"';
}
echo ' target="' . $this->field['options']['target'] . '"';
echo ' class="' . $this->field['options']['btn-class'] . ' ' . $classes . '"';
echo $this->element_attributes() . '/>' . $this->field['options']['value'] . '</a>';
echo $this->element_after();
}
}
}

@ -0,0 +1,47 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Button Bar
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_button_bar' ) ) {
class Exopite_Simple_Options_Framework_Field_button_bar extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
if ( isset( $this->field['options'] ) ) {
$options = $this->field['options'];
$options = ( is_array( $options ) ) ? $options : array_filter( $this->element_data( $options ) );
if ( ! empty( $options ) ) {
echo '<div class="button-bar">';
foreach ( $options as $key => $value ) {
echo '<div class="button-bar__item">';
echo '<input type="radio" name="' . $this->element_name() . '" value="' . $key . '"' . $this->element_attributes( $key ) . $this->checked( $this->element_value(), $key ) . '>';
echo '<button class="button-bar__button">' . $value . '</button>';
echo '</div>';
}
echo '</div>';
}
}
echo $this->element_after();
}
}
}

@ -0,0 +1,55 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Card
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_card' ) ) {
class Exopite_Simple_Options_Framework_Field_card extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
echo $this->element_before();
echo '<div class="card ' . $classes . '">';
if ( ! empty( $this->field['header'] ) ) {
echo '<div class="card-header">';
echo $this->field['header'];
echo '</div>';
}
echo '<div class="card-body">';
if ( ! empty( $this->field['title'] ) ) {
echo '<h4 class="card-title">' . $this->field['title'] . '</h4>';
}
echo '<div class="card-text">' . $this->field['content'] . '</div>';
echo '</div>';
if ( ! empty( $this->field['footer'] ) ) {
echo '<div class="card-footer text-muted">';
echo $this->field['footer'];
echo '</div>';
}
echo '</div>';
echo $this->element_after();
}
}
}

@ -0,0 +1,46 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Checkbox
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_checkbox' ) ) {
class Exopite_Simple_Options_Framework_Field_checkbox extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
$label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
$style = ( isset( $this->field['style'] ) ) ? $this->field['style'] : '';
switch ( $style ) {
case 'fancy':
echo '<label class="checkbox">';
echo '<input type="checkbox" class="checkbox__input" name="' . $this->element_name() . '" value="yes"' . $this->element_attributes() . checked( $this->element_value(), 'yes', false ) . '>';
echo '<div class="checkbox__checkmark"></div>';
echo $label;
echo '</label>';
break;
default:
echo '<label><input type="checkbox" name="' . $this->element_name() . '" value="yes"' . $this->element_class() . $this->element_attributes() . checked( $this->element_value(), 'yes', false ) . '/> ' . $label . '</label>';
break;
}
echo $this->element_after();
}
}
}

@ -0,0 +1,89 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Color
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_color' ) ) {
class Exopite_Simple_Options_Framework_Field_color extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array(), $multilang ) {
parent::__construct( $field, $value, $unique, $config, $multilang );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
$controls = array( 'hue', 'brightness', 'saturation', 'wheel' );
$control = ( isset( $this->field['control'] ) ) ? $this->field['control'] : 'saturation';
$formats = array( 'rgb', 'hex' );
$format = ( isset( $this->field['format'] ) ) ? $this->field['format'] : 'rgb';
echo $this->element_before();
echo '<input type="';
if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
echo 'color';
} else {
echo 'text';
}
echo '" ';
if ( ! isset( $this->field['picker'] ) || $this->field['picker'] != 'html5' ) {
echo 'class="minicolor ' . $classes . '" ';
}
if ( isset( $this->field['rgba'] ) && $this->field['rgba'] ) {
echo 'data-opacity="1" ';
}
if ( in_array( $control, $controls ) ) {
echo 'data-control="' . $control . '" '; // hue, brightness, saturation, wheel
}
if ( in_array( $format, $formats ) ) {
echo 'data-format="' . $format . '" '; // hue, brightness, saturation, wheel
}
echo 'name="' . $this->element_name() . '" value="' . $this->element_value() . '"';
if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
echo $this->element_class();
}
echo $this->element_attributes() . '/>';
}
public static function enqueue( $args ) {
$resources = array(
array(
'name' => 'minicolors_css',
'fn' => 'jquery.minicolors.css',
'type' => 'style',
'dependency' => array(),
'version' => '20181201',
'attr' => 'all',
),
array(
'name' => 'minicolors_js',
'fn' => 'jquery.minicolors.js',
'type' => 'script',
'dependency' => array( 'jquery' ),
'version' => '20181201',
'attr' => true,
),
array(
'name' => 'minicolors-loader',
'fn' => 'loader-minicolors.js',
'type' => 'script',
'dependency' => array( 'minicolors_js' ),
'version' => '20190407',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

@ -0,0 +1,68 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Color
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_color_wp' ) ) {
class Exopite_Simple_Options_Framework_Field_color_wp extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array(), $multilang ) {
parent::__construct( $field, $value, $unique, $config, $multilang );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
/*
* Color Picker
*
* @link https://paulund.co.uk/adding-a-new-color-picker-with-wordpress-3-5
*/
echo $this->element_before();
echo '<input type="text" class="colorpicker ' . $classes . '" ';
if ( isset( $this->field['rgba'] ) && $this->field['rgba'] ) {
echo 'data-alpha="true" ';
}
echo 'name="' . $this->element_name() . '" value="' . $this->element_value() . '"';
echo $this->element_attributes() . '/>';
}
public static function enqueue( $args ) {
// Add the color picker css file from WordPress
wp_enqueue_style( 'wp-color-picker' );
$resources = array(
array(
'name' => 'wp-color-picker-alpha',
'fn' => 'wp-color-picker-alpha.min.js',
'type' => 'script',
'dependency' => array( 'wp-color-picker' ),
'version' => '2.1.3',
'attr' => true,
),
array(
'name' => 'exopite-sof-wp-color-picker-loader',
'fn' => 'loader-color-picker.min.js',
'type' => 'script',
'dependency' => array( 'wp-color-picker-alpha' ),
'version' => '20190407',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

@ -0,0 +1,40 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Content
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_content' ) ) {
class Exopite_Simple_Options_Framework_Field_content extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$content = ( isset( $this->field['content'] ) ) ? $this->field['content'] : '';
if ( isset( $this->field['callback'] ) ) {
$callback = $this->field['callback'];
if ( is_callable( $callback['function'] ) ) {
$args = ( isset( $callback['args'] ) ) ? $callback['args'] : '';
$content = call_user_func( $callback['function'], $args );
}
}
echo $this->element_before();
echo '<div' . $this->element_class() . $this->element_attributes() . '>' . $content . '</div>';
echo $this->element_after();
}
}
}

@ -0,0 +1,66 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Date
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_date' ) ) {
class Exopite_Simple_Options_Framework_Field_date extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$date_format = ( ! empty( $this->field['format'] ) ) ? $this->field['format'] : 'mm/dd/yy';
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
echo $this->element_before();
echo $this->element_prepend();
if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
echo '<input type="date" ';
} else {
echo '<input type="text" ';
echo 'class="datepicker ' . $classes . '" ';
}
echo 'name="' . $this->element_name() . '" ';
if ( isset( $this->field['picker'] ) && $this->field['picker'] == 'html5' ) {
echo 'value="' . $this->element_value() . '"' . $this->element_class() . $this->element_attributes() . ' ';
} else {
echo 'value="' . $this->element_value() . '"' . $this->element_attributes() . ' ';
echo 'data-format="' . $date_format . '"';
}
echo '>';
echo $this->element_append();
echo $this->element_after();
}
public static function enqueue( $args ) {
$resources = array(
array(
'name' => 'exopite-sof-datepicker-loader',
'fn' => 'loader-datepicker.min.js',
'type' => 'script',
'dependency' => array( 'jquery' ),
'version' => '',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

@ -0,0 +1,163 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Editor
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_editor' ) ) {
class Exopite_Simple_Options_Framework_Field_editor extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? explode( ' ', $this->field['class'] ) : array();//$this->element_class()
$editor = ( isset( $this->field['editor'] ) ) ? $this->field['editor'] : 'tinymce';
echo $this->element_before();
if ( $editor == 'tinymce' && isset( $this->field['sub'] ) && $this->field['sub'] ) {
$classes[] = 'tinymce-js';
$classes = implode( ' ', $classes );
echo '<textarea id="' . $this->field['id'] . '" name="' . $this->element_name() . '" class="' . $classes . '"' . $this->element_attributes() . '>' . $this->element_value() . '</textarea>';
} elseif ( $editor == 'trumbowyg' ) {
$classes[] = 'trumbowyg-js';
$classes = implode( ' ', $classes );
echo '<textarea id="' . $this->field['id'] . '" name="' . $this->element_name() . '" data-icon-path="' . plugin_dir_url( __DIR__ ) . 'assets/editors/trumbowyg/icons.svg" class="' . $classes . '"' . $this->element_attributes() . '>' . $this->element_value() . '</textarea>';
} else {
$args = array(
'textarea_rows' => 15,
'editor_class' => implode( ' ', $classes ),
'textarea_name' => $this->element_name(),
'teeny' => false,
// output the minimal editor config used in Press This
'dfw' => false,
// replace the default fullscreen with DFW (supported on the front-end in WordPress 3.4)
'tinymce' => true,
// load TinyMCE, can be used to pass settings directly to TinyMCE using an array()
'quicktags' => true
// load Quicktags, can be used to pass settings directly to Quicktags using an array()
);
wp_editor( $this->element_value(), $this->field['id'], $args );
}
echo $this->element_after();
}
public static function enqueue( $args ) {
if ( isset( $args['field'] ) && isset( $args['field']['editor'] ) && is_array( $args['field']['editor'] ) ) {
foreach ( $args['field']['editor'] as $editor ) {
switch ( $editor ) {
case 'trumbowyg':
$resources = array(
array(
'name' => 'trumbowyg',
'fn' => 'editors/trumbowyg/trumbowyg.min.css',
'type' => 'style',
'dependency' => array(),
'version' => '2.10.0',
'attr' => 'all',
),
array(
'name' => 'trumbowyg-colors',
'fn' => 'editors/trumbowyg/trumbowyg.colors.min.css',
'type' => 'style',
'dependency' => array(),
'version' => '2.10.0',
'attr' => 'all',
),
array(
'name' => 'trumbowyg-user',
'fn' => 'editors/trumbowyg/trumbowyg.user.min.css',
'type' => 'style',
'dependency' => array(),
'version' => '2.10.0',
'attr' => 'all',
),
array(
'name' => 'trumbowyg',
'fn' => 'editors/trumbowyg/trumbowyg.min.js',
'type' => 'script',
'dependency' => array( 'jquery' ),
'version' => '1.8.2',
'attr' => true,
),
array(
'name' => 'trumbowyg-base64',
'fn' => 'editors/trumbowyg/trumbowyg.base64.min.js',
'type' => 'script',
'dependency' => array( 'trumbowyg' ),
'version' => '1.8.2',
'attr' => true,
),
array(
'name' => 'trumbowyg-colors',
'fn' => 'editors/trumbowyg/trumbowyg.colors.min.js',
'type' => 'script',
'dependency' => array( 'trumbowyg' ),
'version' => '1.8.2',
'attr' => true,
),
array(
'name' => 'trumbowyg-fontfamily',
'fn' => 'editors/trumbowyg/trumbowyg.fontfamily.min.js',
'type' => 'script',
'dependency' => array( 'trumbowyg' ),
'version' => '1.8.2',
'attr' => true,
),
array(
'name' => 'trumbowyg-fontsize',
'fn' => 'editors/trumbowyg/trumbowyg.fontsize.min.js',
'type' => 'script',
'dependency' => array( 'trumbowyg' ),
'version' => '1.8.2',
'attr' => true,
),
array(
'name' => 'exopite-sof-trumbowyg-loader',
'fn' => 'loader-jquery-trumbowyg.min.js',
'type' => 'script',
'dependency' => array( 'trumbowyg' ),
'version' => '',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
break;
}
}
}
}
}
}

@ -0,0 +1,96 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Fieldset
*
* - to group elements
* - set element amount per row (1,2,3,4,6) <- like bootstrap
* - title (if more then one) top or bottom of element
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_fieldset' ) ) {
class Exopite_Simple_Options_Framework_Field_fieldset extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array(), $multilang ) {
parent::__construct( $field, $value, $unique, $config, $multilang );
}
public function output() {
echo $this->element_before();
$unallows = array();
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
$self = new Exopite_Simple_Options_Framework( array(
'id' => $this->element_name(),
'multilang' => $this->config['multilang'],
'is_options_simple' => $this->config['is_options_simple'],
), null );
$i = 0;
$fields = $this->field['fields'];
echo '<div class="container">';
echo '<div class="row">';
/**
* 1 -> col-12 col-lg-12 (12/index)
* 2 -> col-12 col-lg-6
* 3 -> col-12 col-lg-4
* 4 -> col-12 col-lg-3
* 6 -> col-12 col-lg-2
*/
$col_classes = array( 'col', 'col-xs-12' );
$allowed_cols = array( 1, 2, 3, 4, 6 );
$col_number = ( isset( $this->field['options']['cols'] ) ) ? intval( $this->field['options']['cols'] ) : 1;
if ( ! in_array( $col_number, $allowed_cols ) ) {
$col_number = 1;
} else {
$col_classes[] = 'col-lg-' . ( 12 / $col_number );
$col_classes[] = 'exopite-sof-col-lg';
}
foreach ( $fields as $field ) {
echo '<div class="' . implode( ' ', $col_classes ) . '">';
if ( in_array( $field['type'], $unallows ) ) {
$field['_notice'] = true;
continue;
}
if ( is_serialized( $this->value ) ) {
$this->value = unserialize( $this->value );
}
$field_value = '';
if ( isset( $field['id'] ) && isset( $this->value[ $field['id'] ] ) ) {
$field_value = $this->value[ $field['id'] ];
} elseif ( isset( $field['default'] ) ) {
$field_value = $field['default'];
}
$class = 'Exopite_Simple_Options_Framework_Field_' . $field['type'];
echo $self->add_field( $field, $field_value );
echo '</div>'; // col
}
echo '</div>'; // row
echo '</div>'; // container
echo $this->element_after();
}
}
}

@ -0,0 +1,63 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Gallery
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_gallery' ) ) {
class Exopite_Simple_Options_Framework_Field_gallery extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array(), $multilang ) {
parent::__construct( $field, $value, $unique, $config, $multilang );
}
public function output() {
echo $this->element_before();
echo $this->element_prepend();
$defaults = array(
'add_button' => esc_attr__( 'Add to gallery', 'exopite-sof' ),
'media_frame_title' => esc_attr__( 'Select images for gallery', 'exopite-sof' ),
'media_frame_button' => esc_attr__( 'Add', 'exopite-sof' ),
'media_type' => 'image',
);
$options = ( isset( $field['options'] ) && is_array( $field['options'] ) ) ? $field['options'] : array();
$options = wp_parse_args( $options, $defaults );
$value = $this->element_value();
echo '<div class="exopite-sof-gallery-field" data-media-frame-title="' . esc_attr( $options['media_frame_title'] ) . '" data-media-frame-button="' . esc_attr( $options['media_frame_button'] ) . '" data-media-frame-type="' . esc_attr( $options['media_type'] ) . '">';
echo '<input type="hidden" name="' . $this->element_name() . '" data-control="gallery-ids" value="' . $this->element_value() . '"' . $this->element_class() . $this->element_attributes() . '/>';
echo '<div class="exopite-sof-gallery">';
if ( $value ) :
$meta_array = explode( ',', $value );
foreach ( $meta_array as $meta_gall_item ) :
echo '<span><span class="exopite-sof-image-delete"></span><img id="' . esc_attr( $meta_gall_item ) . '" src="' . wp_get_attachment_thumb_url( $meta_gall_item ) . '"></span>';
endforeach;
endif;
echo '</div>';
echo '<input class="exopite-sof-gallery-add button button-primary exopite-sof-button" type="button" value="' . esc_attr( $options['add_button'] ) . '" />';
echo '</div>';
echo $this->element_append();
echo $this->element_after();
}
}
}

@ -0,0 +1,364 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Group
*
* @since 1.0.0
* @version 1.0.0
*
*/
/**
*
* - check defults
* - design
* - add/remove group item
* - accrodion (open/close) items (after clone, new item open)
* https://codepen.io/brenden/pen/Kwbpyj
* https://www.jquery-az.com/detailed-guide-use-jquery-accordion-plugin-examples/
* http://inspirationalpixels.com/tutorials/creating-an-accordion-with-html-css-jquery
* https://www.w3schools.com/howto/howto_js_accordion.asp
* http://uniondesign.ca/simple-accordion-without-jquery-ui/
* - clean up
*
* - remove name if empty unique from all fields
* so this->name() should include name="" and
* fields are not
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_group' ) ) {
class Exopite_Simple_Options_Framework_Field_group extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
$defaults = array(
'group_title' => esc_attr( 'Group Title', 'exopite-sof' ),
'repeater' => false,
'cloneable' => true,
'sortable' => true,
'accordion' => true,
'closed' => true,
'limit' => 0,
'button_title' => esc_attr( 'Add new', 'exopite-sof' ),
);
$options = ( ! empty( $this->field['options'] ) ) ? $this->field['options'] : array();
$this->field['options'] = wp_parse_args( $options, $defaults );
$this->group_title = ( isset( $this->field['options']['group_title'] ) ) ? $this->field['options']['group_title'] : $defaults['group_title'];
$this->is_repeater = ( isset( $this->field['options']['repeater'] ) ) ? (bool) $this->field['options']['repeater'] : $defaults['repeater'];
$this->is_accordion = ( isset( $this->field['options']['accordion'] ) ) ? (bool) $this->field['options']['accordion'] : $defaults['accordion'];
$this->is_accordion_closed = ( isset( $this->field['options']['closed'] ) ) ? (bool) $this->field['options']['closed'] : $defaults['closed'];
$this->limit = ( isset( $this->field['options']['limit'] ) ) ? (int) $this->field['options']['limit'] : $defaults['limit'];
$this->is_multilang = ( isset( $this->config['is_multilang'] ) ) ? (bool) $this->config['is_multilang'] : false;
if ( ! $this->is_repeater ) {
$this->is_cloneable = false;
$this->is_sortable = false;
} else {
$this->is_cloneable = ( isset( $this->field['options']['cloneable'] ) ) ? (bool) $this->field['options']['cloneable'] : $defaults['cloneable'];
$this->is_sortable = ( isset( $this->field['options']['sortable'] ) ) ? (bool) $this->field['options']['sortable'] : $defaults['sortable'];
}
}
public function output() {
echo $this->element_before();
$unallows = array();
// $unallows = array( 'group' );
// $unallows = array( 'group', 'tab' );
$fields = array_values( $this->field['fields'] );
$unique_id = ( ! empty( $this->unique ) ) ? $this->unique : $this->field['id'];
$multilang_array_index = ( $this->is_multilang ) ? "[{$this->config['multilang']['current']}]" : "";
if ( $this->config['is_options_simple'] ) {
$parent_array = $this->field['id'];
} else {
$parent_array = $this->unique . '[' . $this->field['id'] . ']';
}
if ( $this->is_repeater ) {
if ( $this->config['is_options_simple'] ) {
$base_id = array(
'id' => "{$this->field['id']}[REPLACEME]",
'is_options_simple' => true
);
} else {
$base_id = array(
'id' => $this->unique . $multilang_array_index . '[' . $this->field['id'] . ']' . '[REPLACEME]'
);
}
} else {
if ( $this->config['is_options_simple'] ) {
$base_id = array(
'id' => "{$this->field['id']}",
'is_options_simple' => true
);
} else {
$base_id = array(
'id' => $this->unique . $multilang_array_index . '[' . $this->field['id'] . ']'
);
}
}
$muster_classes = array();
if ( $this->is_repeater ) {
$muster_classes = array( 'exopite-sof-cloneable__muster', 'exopite-sof-cloneable__muster--hidden' );
if ( $this->is_accordion ) {
$muster_classes[] = 'exopite-sof-accordion--hidden';
$muster_classes[] = 'exopite-sof-accordion__item';
}
} else {
if ( $this->is_accordion ) {
$muster_classes[] = 'exopite-sof-accordion__item';
if ( $this->is_accordion_closed ) {
$muster_classes[] = 'exopite-sof-accordion--hidden';
}
}
}
$limit = $this->limit;
$sortable = $this->is_sortable;
$classes = array( 'exopite-sof-group' );
if ( $this->is_accordion ) {
$classes[] = 'exopite-sof-accordion';
}
echo '<div class="' . implode( ' ', $classes ) . '" data-limit="' . $limit . '">';
$wrapper_classes = array( 'exopite-sof-accordion__wrapper' );
if ( $this->is_accordion && ! $this->is_repeater ) {
echo '<div class="' . implode( ' ', $wrapper_classes ) . '">';
}
echo '<div class="exopite-sof-cloneable__item ' . implode( ' ', $muster_classes ) . '">';
if ( $this->is_repeater || ! empty( $this->group_title ) ) {
echo '<h4 class="exopite-sof-cloneable__title exopite-sof-accordion__title"><span class="exopite-sof-cloneable__text">' . $this->group_title . '</span>';
if ( $this->is_repeater ) {
echo '<span class="exopite-sof-cloneable--helper">';
if ( $sortable ) {
echo '<i class="fa fa-arrows-v"></i>';
}
if ( $this->is_cloneable ) {
echo '<i class="exopite-sof-cloneable--clone fa fa-clone disabled"></i>';
}
echo '<i class="exopite-sof-cloneable--remove fa fa-times disabled"></i>';
echo '</span>';
}
echo '</h4>';
}
echo '<div class="exopite-sof-cloneable__content ';
if ( ! $this->is_repeater ) {
echo 'exopite-sof-sub-dependencies ';
}
echo 'exopite-sof-accordion__content">';
$self = new Exopite_Simple_Options_Framework( $base_id, null );
$self->config['multilang'] = $this->config['multilang'];
$num = 0;
foreach ( $fields as $field ) {
if ( in_array( $field['type'], $unallows ) ) {
$field['_notice'] = true;
continue;
}
$class = 'Exopite_Simple_Options_Framework_Field_' . $field['type'];
if ( $this->config['is_options_simple'] ) {
$field['is_options_simple'] = true;
}
$field['sub'] = true;
$field_default = ( isset( $field['default'] ) ) ? $field['default'] : '';
// Set repeater default field fields as disabled,
// to prevent save them.
// If repeater, template field has no values
if ( $this->is_repeater ) {
$field_value = null;
$field_attributes = array(
'disabled' => 'only-key',
);
if ( isset( $field['attributes'] ) && is_array( $field['attributes'] ) ) {
$field['attributes'] += $field_attributes;
} else {
$field['attributes'] = $field_attributes;
}
} else {
if ( is_serialized( $this->value ) ) {
$this->value = unserialize( $this->value );
}
$field_value = ( isset( $field['id'] ) && isset( $this->value[ $field['id'] ] ) ) ? $this->value[ $field['id'] ] : '';
$field_value = ( $this->is_repeater ) ? null : $field_value;
}
$self->add_field( $field, $field_value );
$num ++;
}
echo '</div>'; // exopite-sof-cloneable-content
echo '</div>'; // exopite-sof-cloneable__item
if ( $this->is_accordion && ! $this->is_repeater ) {
echo '</div>'; // exopite-sof-accordion__wrapper
}
// IF REPEATER
if ( $this->field['options']['repeater'] ) {
$classes = array( 'exopite-sof-cloneable__wrapper', 'exopite-sof-accordion__wrapper' );
if ( isset( $this->field['options']['mode'] ) && $this->field['options']['mode'] == 'compact' ) {
$classes[] = 'exopite-sof-group-compact';
}
if ( isset( $this->config['type'] ) && $this->config['type'] == 'metabox' && isset( $this->config['options'] ) && $this->config['options'] == 'simple' ) {
echo '<div class="' . implode( ' ' , $classes ) . '" data-is-sortable="' . $sortable . '" data-name="' . $this->element_name() . '">';
} else {
$data_multilang = ( $this->config['multilang'] ) ? true : false;
echo '<div class="' . implode( ' ' , $classes ) . '" data-multilang="' . $data_multilang . '" data-is-sortable="' . $sortable . '" data-name="' . $base_id['id'] . '">';
}
if ( $this->value ) {
if ( $this->config['is_options_simple'] ) {
if ( is_serialized( $this->value ) ) {
$this->value = unserialize( $this->value );
}
}
$num = 0;
foreach ( $this->value as $key => $value ) {
/**
* If multilang, then
* - check if first element is current language is exist
* - is a string (if changed from single language) but not current language
* then skip.
* (without this check group will display from other languages elements as empty)
*/
echo '<div class="exopite-sof-cloneable__item';
if ( $this->is_accordion && $this->is_accordion_closed ) {
echo ' exopite-sof-accordion__item';
}
if ( $this->is_accordion && $this->is_accordion_closed ) {
echo ' exopite-sof-accordion--hidden';
}
echo '">';
echo '<h4 class="exopite-sof-cloneable__title exopite-sof-accordion__title"><span class="exopite-sof-cloneable__text">' . $this->field['options']['group_title'] . '</span>';
echo '<span class="exopite-sof-cloneable--helper">';
if ( $sortable ) {
echo '<i class="fa fa-arrows-v"></i>';
}
if ( $this->is_cloneable ) {
echo '<i class="exopite-sof-cloneable--clone fa fa-clone"></i>';
}
echo '<i class="exopite-sof-cloneable--remove fa fa-times"></i>';
echo '</span>';
echo '</h4>';
echo '<div class="exopite-sof-cloneable__content exopite-sof-sub-dependencies exopite-sof-accordion__content">';
if ( $this->config['is_options_simple'] ) {
$self->unique = $this->field['id'] . '[' . $num . ']';
} else {
$self->unique = $this->unique . $multilang_array_index . '[' . $this->field['id'] . '][' . $num . ']';
}
foreach ( $fields as $field ) {
$field['sub'] = true;
if ( $this->config['is_options_simple'] ) {
$field['is_options_simple'] = true;
}
if ( in_array( $field['type'], $unallows ) ) {
continue;
}
$value = ( isset( $this->value[ $num ][ $field['id'] ] ) ) ? $this->value[ $num ][ $field['id'] ] : '';
$self->add_field( $field, $value );
}
echo '</div>'; // exopite-sof-cloneable__content
echo '</div>'; // exopite-sof-cloneable__item
$num ++;
}
}
echo '</div>'; // exopite-sof-cloneable__wrapper
echo '<div class="exopite-sof-cloneable-data" data-unique-id="' . $unique_id . '" data-limit="' . $this->field['options']['limit'] . '">' . esc_attr__( '最多数量:', 'exopite-sof' ) . ' ' . $this->field['options']['limit'] . '个</div>';
echo '<a href="#" class="button button-primary exopite-sof-cloneable--add">' . $this->field['options']['button_title'] . '</a>';
}
echo '</div>'; // exopite-sof-group
echo $this->element_after();
}
}
}

@ -0,0 +1,27 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Hidden
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_hidden' ) ) {
class Exopite_Simple_Options_Framework_Field_hidden extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
echo '<input type="' . $this->element_type() . '" name="' . $this->element_name() . '" value="' . $this->element_value() . '"' . $this->element_class() . $this->element_attributes() . '/>';
echo $this->element_after();
}
}
}

@ -0,0 +1,106 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Image
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_image' ) ) {
class Exopite_Simple_Options_Framework_Field_image extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
/**
* Get an attachment ID given a URL.
*
* @param string $url
*
* @return int Attachment ID on success, 0 on failure
*/
function get_attachment_id( $url ) {
$attachment_id = 0;
$dir = wp_upload_dir();
// To handle relative urls
if ( substr( $url, 0, strlen( '/' ) ) === '/' ) {
$url = get_site_url() . $url;
}
if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory?
$file = basename( $url );
$query_args = array(
'post_type' => 'attachment',
'post_status' => 'inherit',
'fields' => 'ids',
'meta_query' => array(
array(
'value' => $file,
'compare' => 'LIKE',
'key' => '_wp_attachment_metadata',
),
)
);
$query = new WP_Query( $query_args );
if ( $query->have_posts() ) {
foreach ( $query->posts as $post_id ) {
$meta = wp_get_attachment_metadata( $post_id );
$original_file = basename( $meta['file'] );
$cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
if ( $original_file === $file || in_array( $file, $cropped_image_files ) ) {
$attachment_id = $post_id;
break;
}
}
}
}
return $attachment_id;
}
public function output() {
/**
* Open WordPress Media Uploader with PHP and JavaScript
*
* @link https://rudrastyh.com/wordpress/customizable-media-uploader.html
*/
echo $this->element_before();
$preview = '';
$value = $this->element_value();
$add = ( ! empty( $this->field['add_title'] ) ) ? $this->field['add_title'] : esc_attr__( '选择图片', 'exopite-sof' );
$hidden = ( empty( $value ) ) ? ' hidden' : '';
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
if ( ! empty( $value ) ) {
$attachment = wp_get_attachment_image_src( $this->get_attachment_id( $value ), 'thumbnail' );
$preview = $attachment[0];
}
echo '<div class="exopite-sof-media exopite-sof-image ' . $classes . '" ' . $this->element_attributes() . '>';
echo '<div class="exopite-sof-image-preview' . $hidden . '">';
echo '<div class="exopite-sof-image-inner"><i class="fa fa-times exopite-sof-image-remove"></i><img src="' . $preview . '" alt="preview" /></div>';
echo '</div>';
echo '<input type="text" name="' . $this->element_name() . '" value="' . $this->element_value() . '">';
echo '<a href="#" class="button button-primary exopite-sof-button">' . $add . '</a>';
echo '</div>';
echo $this->element_after();
}
public static function enqueue( $args ) {
wp_enqueue_media();
}
}
}

@ -0,0 +1,44 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Image Select
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_image_select' ) ) {
class Exopite_Simple_Options_Framework_Field_image_select extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$input_type = ( ! empty( $this->field['radio'] ) ) ? 'radio' : 'checkbox';
$input_attr = ( $input_type == 'checkbox' ) ? '[]' : '';
$layout = ( isset( $this->field['layout'] ) && $this->field['layout'] == 'vertical' ) ? 'exopite-sof-field-image-selector-vertical' : 'exopite-sof-field-image-selector-horizontal';
echo $this->element_before();
echo '<div class="exopite-sof-field-image-selector ' . $layout . '">';
// echo ( empty( $input_attr ) ) ? '<div class="exopite-sof-field-image-selector">' : '';
if ( isset( $this->field['options'] ) ) {
$options = $this->field['options'];
foreach ( $options as $key => $value ) {
echo '<label><input type="' . $input_type . '" name="' . $this->element_name( $input_attr ) . '" value="' . $key . '"' . $this->element_class() . $this->element_attributes( $key ) . $this->checked( $this->element_value(), $key ) . '/>';
echo ( ! empty( $this->field['text_select'] ) ) ? '<span class="exopite-sof-' . sanitize_title( $value ) . '">' . $value . '</span>' : '<img src="' . $value . '" alt="' . $key . '" />';
echo '</label>';
}
}
echo '</div>';
// echo ( empty( $input_attr ) ) ? '</div>' : '';
echo $this->element_after();
}
}
}

@ -0,0 +1,42 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Textarea
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_meta' ) ) {
class Exopite_Simple_Options_Framework_Field_meta extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
if ( $this->config['type'] != 'metabox') {
echo 'This item only available in metabox!<br>';
} else {
if ( ! empty( $this->field['meta-key'] ) ) {
$value = get_post_meta( get_the_ID(), $this->field['meta-key'], true );
echo $this->element_before();
echo '<textarea readonly' . $this->element_class() . $this->element_attributes() . '>' . var_export( $value, true ) . '</textarea>';
echo $this->element_after();
}
}
}
}
}

@ -0,0 +1,42 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Notice
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_notice' ) ) {
class Exopite_Simple_Options_Framework_Field_notice extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
$content = ( isset( $this->field['content'] ) ) ? $this->field['content'] : '';
if ( isset( $this->field['callback'] ) ) {
$callback = $this->field['callback'];
if ( is_callable( $callback['function'] ) ) {
$args = ( isset( $callback['args'] ) ) ? $callback['args'] : '';
$content = call_user_func( $callback['function'], $args );
}
}
echo $this->element_before();
echo '<div class="exopite-sof-notice ' . $classes . '">' . $content . '</div>';
echo $this->element_after();
}
}
}

@ -0,0 +1,49 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Number
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_number' ) ) {
class Exopite_Simple_Options_Framework_Field_number extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
$unit = ( isset( $this->field['unit'] ) ) ? '<em>' . $this->field['unit'] . '</em>' : '';
$attr = array();
if ( isset( $this->field['min'] ) ) {
$attr[] = 'min="' . $this->field['min'] . '"';
}
if ( isset( $this->field['max'] ) ) {
$attr[] = 'max="' . $this->field['max'] . '"';
}
if ( isset( $this->field['step'] ) ) {
$attr[] = 'step="' . $this->field['step'] . '"';
}
$attrs = ( ! empty( $attr ) ) ? ' ' . trim( implode( ' ', $attr ) ) : '';
echo $this->element_prepend();
echo '<input type="number" name="' . $this->element_name() . '" value="' . $this->element_value() . '"' . $this->element_class() . $this->element_attributes() . $attrs . '/>';
echo $this->element_append();
echo $unit;
echo $this->element_after();
}
}
}

@ -0,0 +1,33 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Password
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_password' ) ) {
class Exopite_Simple_Options_Framework_Field_password extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array()) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
echo $this->element_prepend();
echo '<input type="' . $this->element_type() . '" name="' . $this->element_name() . '" value="' . $this->element_value() . '"' . $this->element_class() . $this->element_attributes() . '/>';
echo $this->element_append();
echo $this->element_after();
}
}
}

@ -0,0 +1,79 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Radio
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_radio' ) ) {
class Exopite_Simple_Options_Framework_Field_radio extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
echo $this->element_before();
if ( isset( $this->field['options'] ) ) {
$options = $this->field['options'];
$options = ( is_array( $options ) ) ? $options : array_filter( $this->element_data( $options ) );
$style = ( isset( $this->field['style'] ) ) ? $this->field['style'] : '';
if ( ! empty( $options ) ) {
echo '<ul' . $this->element_class() . '>';
foreach ( $options as $key => $value ) {
switch ( $style ) {
case 'fancy':
echo '<li>';
echo '<label class="radio-button ' . $classes . '">';
echo '<input type="radio" class="radio-button__input" name="' . $this->element_name() . '" value="' . $key . '"' . $this->element_attributes( $key ) . $this->checked( $this->element_value(), $key ) . '>';
echo '<div class="radio-button__checkmark"></div>';
echo $value;
echo '</label>';
echo '</li>';
break;
default:
echo '<li><label><input type="radio" name="' . $this->element_name() . '" value="' . $key . '"' . $this->element_attributes( $key ) . $this->checked( $this->element_value(), $key ) . '/> ' . $value . '</label></li>';
break;
}
}
echo '</ul>';
}
} else {
$label = ( isset( $this->field['label'] ) ) ? $this->field['label'] : '';
switch ( $this->field['style'] ) {
case 'fancy':
echo '<label class="radio-button ' . $classes . '">';
echo '<input type="radio" class="radio-button__input" name="' . $this->element_name() . '"' . $this->element_attributes() . checked( $this->element_value(), 1, false ) . '>';
echo '<div class="radio-button__checkmark"></div>';
echo $label;
echo '</label>';
break;
default:
echo '<label><input type="radio" name="' . $this->element_name() . '" value="1"' . $this->element_class() . $this->element_attributes() . checked( $this->element_value(), 1, false ) . '/> ' . $label . '</label>';
break;
}
}
echo $this->element_after();
}
}
}

@ -0,0 +1,49 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Range
*
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_range' ) ) {
class Exopite_Simple_Options_Framework_Field_range extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
/**
* Update input if range changed
*
* @link https://stackoverflow.com/questions/10004723/html5-input-type-range-show-range-value/45210546#45210546
*/
$attr = array();
if ( ! empty( $this->field['min'] ) ) {
$attr[] = 'min="' . $this->field['min'] . '"';
}
if ( ! empty( $this->field['max'] ) ) {
$attr[] = 'max="' . $this->field['max'] . '"';
}
if ( ! empty( $this->field['step'] ) ) {
$attr[] = 'step="' . $this->field['step'] . '"';
}
$attrs = ( ! empty( $attr ) ) ? ' ' . trim( implode( ' ', $attr ) ) : '';
$unit = ( isset( $this->field['unit'] ) ) ? '<em>' . $this->field['unit'] . '</em>' : '';
$classes = ( isset( $this->field['class'] ) ) ? implode( ' ', explode( ' ', $this->field['class'] ) ) : '';
echo $this->element_before();
echo '<input type="range" name="' . $this->element_name() . '" oninput="updateRangeInput(this)" class="range ' . $classes . '"' . $attrs . ' value="' . $this->element_value() . '"' . $this->element_attributes() . '>' . $unit;
echo '<input type="number" value="' . $this->element_value() . '" oninput="updateInputRange(this)"' . $attrs . '>';
echo $this->element_after();
}
}
}

@ -0,0 +1,327 @@
<?php if ( ! defined( 'ABSPATH' ) ) {
die;
} // Cannot access pages directly.
/**
*
* Field: Select
*
*/
/* Usage:
*
array(
'id' => 'select_1',
'type' => 'select',
'title' => 'Title',
'query' => array(
'type' => 'callback',
'function' => array( $this, 'function_name' ),
'args' => array() // WordPress query args
),
),
OPTIONS OR QUERY:
- with static options
'options' => array(
'bmw' => 'BMW',
'mercedes' => 'Mercedes',
'volkswagen' => 'Volkswagen',
'other' => 'Other',
),
- with a callback function
'query' => array(
'type' => 'callback',
'function' => array( $this, 'function_name' ),
'args' => array() // WordPress query args
),
- with a build-in types, you can use: posts, pages, categories, tags, menus, post_types and users
'query' => array(
'type' => 'users',
'args' => array( // WordPress query args
'orderby' => 'nicename',
'meta_query' => array(), // Your meta query
),
),
- also possible to use different args on different pages with ['query']['args']['multi_query'] = true
'query' => array(
'type' => 'users',
'args' => array( // WordPress query args
'multi_query' => true, // to activate multi query
array(
'display_on' => array( 'page-slugs or ids' ), // page slug or id where this args should apply
... continue with your meta query ...
),
array(
'display_on' => array( 'page-slugs or ids' ), // page slug or id where this args should apply
'orderby' => 'nicename',
'meta_query' => array(
'relation' => 'AND',
array(), // your meta query
array(), // your meta query
),
),
),
),
*/
if ( ! class_exists( 'Exopite_Simple_Options_Framework_Field_select' ) ) {
class Exopite_Simple_Options_Framework_Field_select extends Exopite_Simple_Options_Framework_Fields {
public function __construct( $field, $value = '', $unique = '', $config = array() ) {
parent::__construct( $field, $value, $unique, $config );
}
public function output() {
echo $this->element_before();
echo $this->element_prepend();
if ( isset( $this->field['options'] ) || isset( $this->field['query'] ) ) {
$options = ( isset( $this->field['options'] ) && is_array( $this->field['options'] ) ) ? $this->field['options'] : array();
$query = ( isset( $this->field['query'] ) && isset( $this->field['query']['type'] ) ) ? $this->field['query'] : false;
$select = ( $query ) ? $this->element_data( $query['type'] ) : $options;
$class = $this->element_class();
$extra_name = ( isset( $this->field['attributes']['multiple'] ) ) ? '[]' : '';
echo '<select name="' . $this->element_name( $extra_name ) . '"' . $this->element_class() . $this->element_attributes() . '>';
echo ( isset( $this->field['default_option'] ) ) ? '<option value="">' . $this->field['default_option'] . '</option>' : '';
if ( ! empty( $select ) ) {
foreach ( $select as $key => $value ) {
echo '<option value="' . $key . '" ' . $this->checked( $this->element_value(), $key, 'selected' ) . '>' . $value . '</option>';
}
}
echo '</select>';
}
echo $this->element_append();
echo $this->element_after();
}
/**
* Populate select from wp_query
*/
public function element_data( $type = '' ) {
$select = array();
$query = ( isset( $this->field['query'] ) ) ? $this->field['query'] : array();
$query_args = array();
/**
* Make possible to have different args for different pages.
*/
if ( isset( $query['args'] ) && is_array( $query['args'] ) ) {
// Check if multi_query is set
if ( isset( $query['args']['multi_query'] ) && true === $query['args']['multi_query'] ) {
foreach ( $query['args'] as $args ) {
// Skip if not an array (eg. 'multi_query' => true )
if ( ! is_array( $args ) ) {
continue;
}
global $post;
$display_on = $args['display_on'];
// 'disply_on' is the post slog or id
if ( ( is_array( $display_on ) && in_array( $post->post_name, $display_on ) ) ||
( ! is_array( $display_on ) && $display_on == $post->post_name ) ||
( is_array( $display_on ) && in_array( $post->ID, $display_on ) ) ||
( ! is_array( $display_on ) && $display_on == $post->ID )
) {
// remove 'display_on'
unset( $args['display_on'] );
// set args
$query_args = $args;
}
}
} else {
$query_args = $query['args'];
}
}
switch ( $type ) {
case 'pages':
case 'page':
$pages = get_pages( $query_args );
if ( ! is_wp_error( $pages ) && ! empty( $pages ) ) {
foreach ( $pages as $page ) {
$select[ $page->ID ] = $page->post_title;
}
}
break;
case 'posts':
case 'post':
$posts = get_posts( $query_args );
if ( ! is_wp_error( $posts ) && ! empty( $posts ) ) {
foreach ( $posts as $post ) {
$select[ $post->ID ] = $post->post_title;
}
}
break;
case 'categories':
case 'category':
$categories = get_categories( $query_args );
if ( ! is_wp_error( $categories ) && ! empty( $categories ) && ! isset( $categories['errors'] ) ) {
foreach ( $categories as $category ) {
$select[ $category->term_id ] = $category->name;
}
}
break;
case 'tags':
case 'tag':
$taxonomies = ( isset( $query_args['taxonomies'] ) ) ? $query_args['taxonomies'] : 'post_tag';
$tags = get_terms( $taxonomies, $query_args );
if ( ! is_wp_error( $tags ) && ! empty( $tags ) ) {
foreach ( $tags as $tag ) {
$select[ $tag->term_id ] = $tag->name;
}
}
break;
case 'menus':
case 'menu':
$menus = wp_get_nav_menus( $query_args );
if ( ! is_wp_error( $menus ) && ! empty( $menus ) ) {
foreach ( $menus as $menu ) {
$select[ $menu->term_id ] = $menu->name;
}
}
break;
case 'post_types':
case 'post_type':
$query_args['show_in_nav_menus'] = true;
$post_types = get_post_types( $query_args );
if ( ! is_wp_error( $post_types ) && ! empty( $post_types ) ) {
foreach ( $post_types as $post_type ) {
$select[ $post_type ] = ucfirst( $post_type );
}
}
break;
case 'users':
case 'user':
$users = get_users( $query_args );
/**
* key: the name in select
* value: the value in select
*/
$key = ( isset ( $this->field['query']['key'] ) ) ? sanitize_key( $this->field['query']['key'] ) : 'ID';
$value = ( isset ( $this->field['query']['value'] ) ) ? sanitize_key( $this->field['query']['value'] ) : 'user_login';
if ( ! is_wp_error( $users ) && ! empty( $users ) ) {
foreach ( $users as $user ) {
$select[ $user->{$key} ] = $user->{$value};
}
}
break;
case 'custom':
case 'callback':
/**
* Get post object if it is a metabox and not yet set.
* Then send post object to callback function.
*/
if ( isset( $this->config['type'] ) && $this->config['type'] == 'metabox' && ! isset( $post ) ) {
global $post;
} else {
$post = array();
}
if ( is_callable( $query['function'] ) ) {
$select = call_user_func( $query['function'], $query_args, $post );
}
break;
}
return $select;
}
public static function enqueue( $args ) {
/**
* https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.2/chosen.jquery.min.js
* https://www.sitepoint.com/jquery-select-box-components-chosen-vs-select2/
*/
$resources = array(
array(
'name' => 'jquery-chosen',
'fn' => 'chosen.min.css',
'type' => 'style',
'dependency' => array(),
'version' => '1.8.2',
'attr' => 'all',
),
array(
'name' => 'jquery-chosen',
'fn' => 'chosen.jquery.min.js',
'type' => 'script',
'dependency' => array( 'jquery' ),
'version' => '1.8.2',
'attr' => true,
),
array(
'name' => 'exopite-sof-jquery-chosen-loader',
'fn' => 'loader-jquery-chosen.min.js',
'type' => 'script',
'dependency' => array( 'jquery-chosen' ),
'version' => '',
'attr' => true,
),
);
parent::do_enqueue( $resources, $args );
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save