first commit
5834
wp-content/plugins/wp-smart-editor/extensions/wp-table-manager-light/app/admin/assets/css/bootstrap.scss
vendored
Normal file
@@ -0,0 +1,103 @@
|
||||
#jao {
|
||||
|
||||
padding: 10px;
|
||||
|
||||
}
|
||||
|
||||
ul.jaofiletree {
|
||||
font-family: Verdana, sans-serif;
|
||||
font-size: 11px;
|
||||
line-height: 18px;
|
||||
padding: 0;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
ul.jaofiletree li {
|
||||
list-style: none;
|
||||
padding: 0px;
|
||||
padding-left: 20px;
|
||||
margin: 0px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
ul.jaofiletree a {
|
||||
color: #333;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
padding: 0px 2px;
|
||||
}
|
||||
|
||||
ul.jaofiletree a:hover {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.jaofiletree li.selected > a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/* Core Styles */
|
||||
.jaofiletree li.directory { background: url(../images/jao/directory.png) left top no-repeat; }
|
||||
.jaofiletree li.expanded { background: url(../images/jao/folder_open.png) left top no-repeat; }
|
||||
.jaofiletree li.drive { background: url(../images/jao/drive.png) left top no-repeat; }
|
||||
.jaofiletree li.file { background: url(../images/jao/file.png) left top no-repeat; }
|
||||
.jaofiletree li.wait { background: url(../images/jao/spinner.gif) left top no-repeat; }
|
||||
/* File Extensions*/
|
||||
.jaofiletree li.ext_3gp { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_afp { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_afpa { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_asp { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_aspx { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_avi { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_bat { background: url(../images/jao/application.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_bmp { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_c { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_cfm { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_cgi { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_com { background: url(../images/jao/application.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_cpp { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_css { background: url(../images/jao/css.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_doc { background: url(../images/jao/doc.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_exe { background: url(../images/jao/application.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_gif { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_fla { background: url(../images/jao/flash.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_h { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_htm { background: url(../images/jao/html.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_html { background: url(../images/jao/html.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_jar { background: url(../images/jao/java.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_jpg { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_jpeg { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_js { background: url(../images/jao/script.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_lasso { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_log { background: url(../images/jao/txt.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_m4p { background: url(../images/jao/music.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_mov { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_mp3 { background: url(../images/jao/music.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_mp4 { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_mpg { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_mpeg { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_ogg { background: url(../images/jao/music.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_pcx { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_pdf { background: url(../images/jao/pdf.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_php { background: url(../images/jao/php.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_png { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_ppt { background: url(../images/jao/ppt.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_psd { background: url(../images/jao/psd.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_pl { background: url(../images/jao/script.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_py { background: url(../images/jao/script.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_rb { background: url(../images/jao/ruby.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_rbx { background: url(../images/jao/ruby.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_rhtml { background: url(../images/jao/ruby.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_rpm { background: url(../images/jao/linux.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_ruby { background: url(../images/jao/ruby.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_sql { background: url(../images/jao/db.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_swf { background: url(../images/jao/flash.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_tif { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_tiff { background: url(../images/jao/picture.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_txt { background: url(../images/jao/txt.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_vb { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_wav { background: url(../images/jao/music.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_wmv { background: url(../images/jao/film.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_xls { background: url(../images/jao/xls.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_xlsx { background: url(../images/jao/xlsx.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_xml { background: url(../images/jao/code.png) left top no-repeat; }
|
||||
.jaofiletree li.ext_zip { background: url(../images/jao/zip.png) left top no-repeat; }
|
||||
@@ -0,0 +1,25 @@
|
||||
#lean_overlay {
|
||||
position: fixed;
|
||||
z-index:100101;
|
||||
top: 0px;
|
||||
left: 0px;
|
||||
height:100%;
|
||||
width:100%;
|
||||
background: #000;
|
||||
display: none;
|
||||
}
|
||||
|
||||
#wptmmodal {
|
||||
width: 90%;
|
||||
height: 0px;
|
||||
padding: 20px;
|
||||
visibility: hidden;
|
||||
z-index: 99999999 !important;
|
||||
background: #FFF;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
box-shadow: 0px 0px 4px rgba(0,0,0,0.7);
|
||||
-webkit-box-shadow: 0 0 4px rgba(0,0,0,0.7);
|
||||
-moz-box-shadow: 0 0px 4px rgba(0,0,0,0.7);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
.sprite {
|
||||
background-image: url(../images/table-sprites.png);
|
||||
background-repeat: no-repeat;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.sprite_border_all {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -5px -5px;
|
||||
}
|
||||
|
||||
.sprite_border_bottom {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -37px -5px;
|
||||
}
|
||||
|
||||
.sprite_border_fall {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -69px -5px;
|
||||
}
|
||||
|
||||
.sprite_border_horizontal {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -101px -5px;
|
||||
}
|
||||
|
||||
.sprite_border_inside {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -5px -37px;
|
||||
}
|
||||
|
||||
.sprite_border_left {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -37px -37px;
|
||||
}
|
||||
|
||||
.sprite_border_outline {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -69px -37px;
|
||||
}
|
||||
|
||||
.sprite_border_remove {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -101px -37px;
|
||||
}
|
||||
|
||||
.sprite_border_right {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -5px -69px;
|
||||
}
|
||||
|
||||
.sprite_border_top {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -37px -69px;
|
||||
}
|
||||
|
||||
.sprite_border_up {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -69px -69px;
|
||||
}
|
||||
|
||||
.sprite_border_vertical {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
background-position: -101px -69px;
|
||||
}
|
||||
|
||||
.sprite_text_align_center {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -5px -101px;
|
||||
}
|
||||
|
||||
.sprite_text_align_justify {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -31px -101px;
|
||||
}
|
||||
|
||||
.sprite_text_align_left {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -57px -101px;
|
||||
}
|
||||
|
||||
.sprite_text_align_right {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -83px -101px;
|
||||
}
|
||||
|
||||
.sprite_text_bold {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -109px -101px;
|
||||
}
|
||||
|
||||
.sprite_text_italic {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -133px -5px;
|
||||
}
|
||||
|
||||
.sprite_text_underline {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -133px -31px;
|
||||
}
|
||||
|
||||
.sprite_vertical_align_bottom {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -133px -57px;
|
||||
}
|
||||
|
||||
.sprite_vertical_align_middle {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -135px -83px;
|
||||
}
|
||||
|
||||
.sprite_vertical_align_top {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background-position: -135px -109px;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Wptm
|
||||
*
|
||||
* We developed this code with our hearts and passion.
|
||||
* We hope you found it useful, easy to understand and to customize.
|
||||
* Otherwise, please feel free to contact us at contact@joomunited.com *
|
||||
* @package Wptm
|
||||
* @copyright Copyright (C) 2014 JoomUnited (http://www.joomunited.com). All rights reserved.
|
||||
* @copyright Copyright (C) 2014 Damien Barrère (http://www.crac-design.com). All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
body.wptmditor { margin: 10px 10px 10px 20px; min-height: 140px;}
|
||||
|
||||
|
After Width: | Height: | Size: 9.7 KiB |
|
After Width: | Height: | Size: 703 B |
|
After Width: | Height: | Size: 8.6 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 1.3 KiB |
@@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
||||
|
After Width: | Height: | Size: 464 B |
|
After Width: | Height: | Size: 603 B |
|
After Width: | Height: | Size: 618 B |
|
After Width: | Height: | Size: 579 B |
|
After Width: | Height: | Size: 264 B |
|
After Width: | Height: | Size: 651 B |
|
After Width: | Height: | Size: 346 B |
|
After Width: | Height: | Size: 294 B |
|
After Width: | Height: | Size: 653 B |
|
After Width: | Height: | Size: 582 B |
|
After Width: | Height: | Size: 288 B |
|
After Width: | Height: | Size: 734 B |
|
After Width: | Height: | Size: 633 B |
|
After Width: | Height: | Size: 668 B |
|
After Width: | Height: | Size: 385 B |
|
After Width: | Height: | Size: 591 B |
|
After Width: | Height: | Size: 538 B |
|
After Width: | Height: | Size: 606 B |
|
After Width: | Height: | Size: 588 B |
|
After Width: | Height: | Size: 856 B |
|
After Width: | Height: | Size: 626 B |
|
After Width: | Height: | Size: 859 B |
|
After Width: | Height: | Size: 1.3 KiB |
|
After Width: | Height: | Size: 342 B |
|
After Width: | Height: | Size: 673 B |
|
After Width: | Height: | Size: 673 B |
|
After Width: | Height: | Size: 383 B |
|
After Width: | Height: | Size: 2.1 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 5.0 KiB |
|
After Width: | Height: | Size: 4.2 KiB |
|
After Width: | Height: | Size: 5.7 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 4.0 KiB |
|
After Width: | Height: | Size: 43 B |
|
After Width: | Height: | Size: 4.5 KiB |
|
After Width: | Height: | Size: 623 B |
515
wp-content/plugins/wp-smart-editor/extensions/wp-table-manager-light/app/admin/assets/js/bootbox.js
vendored
Normal file
@@ -0,0 +1,515 @@
|
||||
/**
|
||||
* bootbox.js v3.0.0
|
||||
*
|
||||
* http://bootboxjs.com/license.txt
|
||||
*/
|
||||
var bootbox = window.bootbox || (function(document, $) {
|
||||
|
||||
var _animate = true,
|
||||
_backdrop = 'static',
|
||||
_defaultHref = 'javascript:;',
|
||||
_classes = '',
|
||||
_icons = {},
|
||||
/* last var should always be the public object we'll return */
|
||||
that = {};
|
||||
|
||||
|
||||
that.setIcons = function(icons) {
|
||||
_icons = icons;
|
||||
if (typeof _icons !== 'object' || _icons == null) {
|
||||
_icons = {};
|
||||
}
|
||||
};
|
||||
|
||||
that.alert = function(/*str, label, cb*/) {
|
||||
var str = "",
|
||||
label = _translate('OK'),
|
||||
cb = null;
|
||||
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
// no callback, default button label
|
||||
str = arguments[0];
|
||||
break;
|
||||
case 2:
|
||||
// callback *or* custom button label dependent on type
|
||||
str = arguments[0];
|
||||
if (typeof arguments[1] == 'function') {
|
||||
cb = arguments[1];
|
||||
} else {
|
||||
label = arguments[1];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
// callback and custom button label
|
||||
str = arguments[0];
|
||||
label = arguments[1];
|
||||
cb = arguments[2];
|
||||
break;
|
||||
default:
|
||||
throw new Error("Incorrect number of arguments: expected 1-3");
|
||||
break;
|
||||
}
|
||||
|
||||
return that.dialog(str, {
|
||||
// only button (ok)
|
||||
"label" : label,
|
||||
"icon" : _icons.OK,
|
||||
"callback": cb
|
||||
}, {
|
||||
// ensure that the escape key works; either invoking the user's
|
||||
// callback or true to just close the dialog
|
||||
"onEscape": cb || true
|
||||
});
|
||||
};
|
||||
|
||||
that.confirm = function(/*str, labelCancel, labelOk, cb*/) {
|
||||
var str = "",
|
||||
labelCancel = _translate('CANCEL'),
|
||||
labelOk = _translate('CONFIRM'),
|
||||
cb = null;
|
||||
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
str = arguments[0];
|
||||
break;
|
||||
case 2:
|
||||
str = arguments[0];
|
||||
if (typeof arguments[1] == 'function') {
|
||||
cb = arguments[1];
|
||||
} else {
|
||||
labelCancel = arguments[1];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
str = arguments[0];
|
||||
labelCancel = arguments[1];
|
||||
if (typeof arguments[2] == 'function') {
|
||||
cb = arguments[2];
|
||||
} else {
|
||||
labelOk = arguments[2];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
str = arguments[0];
|
||||
labelCancel = arguments[1];
|
||||
labelOk = arguments[2];
|
||||
cb = arguments[3];
|
||||
break;
|
||||
default:
|
||||
throw new Error("Incorrect number of arguments: expected 1-4");
|
||||
break;
|
||||
}
|
||||
|
||||
var cancelCallback = function() {
|
||||
if (typeof cb === 'function') {
|
||||
cb(false);
|
||||
}
|
||||
};
|
||||
|
||||
var confirmCallback = function() {
|
||||
if (typeof cb === 'function') {
|
||||
cb(true);
|
||||
}
|
||||
};
|
||||
|
||||
return that.dialog(str, [{
|
||||
// first button (cancel)
|
||||
"label" : labelCancel,
|
||||
"icon" : _icons.CANCEL,
|
||||
"callback": cancelCallback
|
||||
}, {
|
||||
// second button (confirm)
|
||||
"label" : labelOk,
|
||||
"icon" : _icons.CONFIRM,
|
||||
"callback": confirmCallback
|
||||
}], {
|
||||
// escape key bindings
|
||||
"onEscape": cancelCallback
|
||||
});
|
||||
};
|
||||
|
||||
that.prompt = function(/*str, labelCancel, labelOk, cb, defaultVal*/) {
|
||||
var str = "",
|
||||
labelCancel = _translate('CANCEL'),
|
||||
labelOk = _translate('CONFIRM'),
|
||||
cb = null,
|
||||
defaultVal = "";
|
||||
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
str = arguments[0];
|
||||
break;
|
||||
case 2:
|
||||
str = arguments[0];
|
||||
if (typeof arguments[1] == 'function') {
|
||||
cb = arguments[1];
|
||||
} else {
|
||||
labelCancel = arguments[1];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
str = arguments[0];
|
||||
labelCancel = arguments[1];
|
||||
if (typeof arguments[2] == 'function') {
|
||||
cb = arguments[2];
|
||||
} else {
|
||||
labelOk = arguments[2];
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
str = arguments[0];
|
||||
labelCancel = arguments[1];
|
||||
labelOk = arguments[2];
|
||||
cb = arguments[3];
|
||||
break;
|
||||
case 5:
|
||||
str = arguments[0];
|
||||
labelCancel = arguments[1];
|
||||
labelOk = arguments[2];
|
||||
cb = arguments[3];
|
||||
defaultVal = arguments[4];
|
||||
break;
|
||||
default:
|
||||
throw new Error("Incorrect number of arguments: expected 1-5");
|
||||
break;
|
||||
}
|
||||
|
||||
var header = str;
|
||||
|
||||
// let's keep a reference to the form object for later
|
||||
var form = $("<form></form>");
|
||||
form.append("<input autocomplete=off type=text value='" + defaultVal + "' />");
|
||||
|
||||
var cancelCallback = function() {
|
||||
if (typeof cb === 'function') {
|
||||
// yep, native prompts dismiss with null, whereas native
|
||||
// confirms dismiss with false...
|
||||
cb(null);
|
||||
}
|
||||
};
|
||||
|
||||
var confirmCallback = function() {
|
||||
if (typeof cb === 'function') {
|
||||
cb(form.find("input[type=text]").val());
|
||||
}
|
||||
};
|
||||
|
||||
var div = that.dialog(form, [{
|
||||
// first button (cancel)
|
||||
"label" : labelCancel,
|
||||
"icon" : _icons.CANCEL,
|
||||
"callback": cancelCallback
|
||||
}, {
|
||||
// second button (confirm)
|
||||
"label" : labelOk,
|
||||
"icon" : _icons.CONFIRM,
|
||||
"callback": confirmCallback
|
||||
}], {
|
||||
// prompts need a few extra options
|
||||
"header" : header,
|
||||
// explicitly tell dialog NOT to show the dialog...
|
||||
"show" : false,
|
||||
"onEscape": cancelCallback
|
||||
});
|
||||
|
||||
// ... the reason the prompt needs to be hidden is because we need
|
||||
// to bind our own "shown" handler, after creating the modal but
|
||||
// before any show(n) events are triggered
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/69
|
||||
|
||||
div.on("shown", function() {
|
||||
form.find("input[type=text]").focus();
|
||||
|
||||
// ensure that submitting the form (e.g. with the enter key)
|
||||
// replicates the behaviour of a normal prompt()
|
||||
form.on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
div.find(".button-primary").click();
|
||||
});
|
||||
});
|
||||
|
||||
div.modal("show");
|
||||
div.fadeIn();
|
||||
return div;
|
||||
};
|
||||
|
||||
that.dialog = function(str, handlers, options) {
|
||||
var buttons = "",
|
||||
callbacks = [],
|
||||
options = options || {};
|
||||
|
||||
// check for single object and convert to array if necessary
|
||||
if (handlers == null) {
|
||||
handlers = [];
|
||||
} else if (typeof handlers.length == 'undefined') {
|
||||
handlers = [handlers];
|
||||
}
|
||||
|
||||
var i = handlers.length;
|
||||
while (i--) {
|
||||
var label = null,
|
||||
href = null,
|
||||
_class = null,
|
||||
icon = '',
|
||||
callback = null;
|
||||
|
||||
if (typeof handlers[i]['label'] == 'undefined' &&
|
||||
typeof handlers[i]['class'] == 'undefined' &&
|
||||
typeof handlers[i]['callback'] == 'undefined') {
|
||||
// if we've got nothing we expect, check for condensed format
|
||||
|
||||
var propCount = 0, // condensed will only match if this == 1
|
||||
property = null; // save the last property we found
|
||||
|
||||
// be nicer to count the properties without this, but don't think it's possible...
|
||||
for (var j in handlers[i]) {
|
||||
property = j;
|
||||
if (++propCount > 1) {
|
||||
// forget it, too many properties
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (propCount == 1 && typeof handlers[i][j] == 'function') {
|
||||
// matches condensed format of label -> function
|
||||
handlers[i]['label'] = property;
|
||||
handlers[i]['callback'] = handlers[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof handlers[i]['callback']== 'function') {
|
||||
callback = handlers[i]['callback'];
|
||||
}
|
||||
|
||||
if (handlers[i]['class']) {
|
||||
_class = handlers[i]['class'];
|
||||
} else if (i == handlers.length -1 && handlers.length <= 2) {
|
||||
// always add a primary to the main option in a two-button dialog
|
||||
_class = 'button-primary';
|
||||
}
|
||||
|
||||
if (handlers[i]['label']) {
|
||||
label = handlers[i]['label'];
|
||||
} else {
|
||||
label = "Option "+(i+1);
|
||||
}
|
||||
|
||||
if (handlers[i]['icon']) {
|
||||
icon = "<i class='"+handlers[i]['icon']+"'></i> ";
|
||||
}
|
||||
|
||||
if (handlers[i]['href']) {
|
||||
href = handlers[i]['href'];
|
||||
}
|
||||
else {
|
||||
href = _defaultHref;
|
||||
}
|
||||
|
||||
buttons = "<a data-handler='"+i+"' class='button "+_class+"' href='" + href + "'>"+icon+""+label+"</a>" + buttons;
|
||||
|
||||
callbacks[i] = callback;
|
||||
}
|
||||
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/46#issuecomment-8235302
|
||||
// and https://github.com/twitter/bootstrap/issues/4474
|
||||
// for an explanation of the inline overflow: hidden
|
||||
// @see https://github.com/twitter/bootstrap/issues/4854
|
||||
// for an explanation of tabIndex=-1
|
||||
|
||||
var parts = ["<div class='bootbox modal' tabindex='-1' style='overflow:hidden;'>"];
|
||||
|
||||
if (options['header']) {
|
||||
var closeButton = '';
|
||||
if (typeof options['headerCloseButton'] == 'undefined' || options['headerCloseButton']) {
|
||||
closeButton = "<a href='"+_defaultHref+"' class='close'>×</a>";
|
||||
}
|
||||
|
||||
parts.push("<div class='modal-header'>"+closeButton+"<h3>"+options['header']+"</h3></div>");
|
||||
}
|
||||
|
||||
// push an empty body into which we'll inject the proper content later
|
||||
parts.push("<div class='modal-body'></div>");
|
||||
|
||||
if (buttons) {
|
||||
parts.push("<div class='modal-footer'>"+buttons+"</div>");
|
||||
}
|
||||
|
||||
parts.push("</div>");
|
||||
|
||||
var div = $(parts.join("\n"));
|
||||
|
||||
// check whether we should fade in/out
|
||||
var shouldFade = (typeof options.animate === 'undefined') ? _animate : options.animate;
|
||||
|
||||
if (shouldFade) {
|
||||
div.addClass("fade");
|
||||
}
|
||||
|
||||
var optionalClasses = (typeof options.classes === 'undefined') ? _classes : options.classes;
|
||||
if (optionalClasses) {
|
||||
div.addClass(optionalClasses);
|
||||
}
|
||||
|
||||
// now we've built up the div properly we can inject the content whether it was a string or a jQuery object
|
||||
div.find(".modal-body").html(str);
|
||||
|
||||
div.on('hidden', function() {
|
||||
div.remove();
|
||||
});
|
||||
|
||||
// hook into the modal's keyup trigger to check for the escape key
|
||||
div.on('keyup.dismiss.modal', function(e) {
|
||||
// any truthy value passed to onEscape will dismiss the dialog...
|
||||
if (e.which == 27 && options.onEscape) {
|
||||
if (typeof options.onEscape === 'function') {
|
||||
// ... but only a function will be invoked (obviously)
|
||||
options.onEscape();
|
||||
}
|
||||
|
||||
div.modal('hide');
|
||||
}
|
||||
});
|
||||
|
||||
// well, *if* we have a primary - give the first dom element focus
|
||||
div.on('shown', function() {
|
||||
div.find("a.button-primary:first").focus();
|
||||
});
|
||||
|
||||
// wire up button handlers
|
||||
div.on('click', '.modal-footer a, a.close', function(e) {
|
||||
|
||||
var handler = $(this).data("handler"),
|
||||
cb = callbacks[handler],
|
||||
hideModal = null;
|
||||
|
||||
// sort of @see https://github.com/makeusabrew/bootbox/pull/68 - heavily adapted
|
||||
// if we've got a custom href attribute, all bets are off
|
||||
if (typeof handler !== 'undefined' &&
|
||||
typeof handlers[handler]['href'] !== 'undefined') {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
if (typeof cb == 'function') {
|
||||
hideModal = cb();
|
||||
}
|
||||
|
||||
// the only way hideModal *will* be false is if a callback exists and
|
||||
// returns it as a value. in those situations, don't hide the dialog
|
||||
// @see https://github.com/makeusabrew/bootbox/pull/25
|
||||
if (hideModal !== false) {
|
||||
div.modal("hide");
|
||||
$('.modal-backdrop').remove();
|
||||
}
|
||||
});
|
||||
|
||||
// stick the modal right at the bottom of the main body out of the way
|
||||
$("#mybootstrap").append(div);
|
||||
|
||||
div.modal({
|
||||
// unless explicitly overridden take whatever our default backdrop value is
|
||||
backdrop : (typeof options.backdrop === 'undefined') ? _backdrop : options.backdrop,
|
||||
// ignore bootstrap's keyboard options; we'll handle this ourselves (more fine-grained control)
|
||||
keyboard : false,
|
||||
// @ see https://github.com/makeusabrew/bootbox/issues/69
|
||||
// we *never* want the modal to be shown before we can bind stuff to it
|
||||
// this method can also take a 'show' option, but we'll only use that
|
||||
// later if we need to
|
||||
show : false
|
||||
});
|
||||
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/64
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/60
|
||||
// ...caused by...
|
||||
// @see https://github.com/twitter/bootstrap/issues/4781
|
||||
div.on("show", function(e) {
|
||||
$(document).off("focusin.modal");
|
||||
});
|
||||
|
||||
if (typeof options.show === 'undefined' || options.show === true) {
|
||||
div.modal("show");
|
||||
div.addClass('in');
|
||||
}
|
||||
|
||||
return div;
|
||||
};
|
||||
|
||||
/**
|
||||
* #modal is deprecated in v3; it can still be used but no guarantees are
|
||||
* made - have never been truly convinced of its merit but perhaps just
|
||||
* needs a tidyup and some TLC
|
||||
*/
|
||||
that.modal = function(/*str, label, options*/) {
|
||||
var str;
|
||||
var label;
|
||||
var options;
|
||||
|
||||
var defaultOptions = {
|
||||
"onEscape": null,
|
||||
"keyboard": true,
|
||||
"backdrop": _backdrop
|
||||
};
|
||||
|
||||
switch (arguments.length) {
|
||||
case 1:
|
||||
str = arguments[0];
|
||||
break;
|
||||
case 2:
|
||||
str = arguments[0];
|
||||
if (typeof arguments[1] == 'object') {
|
||||
options = arguments[1];
|
||||
} else {
|
||||
label = arguments[1];
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
str = arguments[0];
|
||||
label = arguments[1];
|
||||
options = arguments[2];
|
||||
break;
|
||||
default:
|
||||
throw new Error("Incorrect number of arguments: expected 1-3");
|
||||
break;
|
||||
}
|
||||
|
||||
defaultOptions['header'] = label;
|
||||
|
||||
if (typeof options == 'object') {
|
||||
options = $.extend(defaultOptions, options);
|
||||
} else {
|
||||
options = defaultOptions;
|
||||
}
|
||||
|
||||
return that.dialog(str, [], options);
|
||||
};
|
||||
|
||||
|
||||
that.hideAll = function() {
|
||||
$(".bootbox").modal("hide");
|
||||
};
|
||||
|
||||
that.animate = function(animate) {
|
||||
_animate = animate;
|
||||
};
|
||||
|
||||
that.backdrop = function(backdrop) {
|
||||
_backdrop = backdrop;
|
||||
};
|
||||
|
||||
that.classes = function(classes) {
|
||||
_classes = classes;
|
||||
};
|
||||
|
||||
function _translate(str) {
|
||||
return wptmCmd.str
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
}(document, window.jQuery));
|
||||
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/71
|
||||
window.bootbox = bootbox;
|
||||
2170
wp-content/plugins/wp-smart-editor/extensions/wp-table-manager-light/app/admin/assets/js/bootstrap.js
vendored
Normal file
708
wp-content/plugins/wp-smart-editor/extensions/wp-table-manager-light/app/admin/assets/js/iris.min.js
vendored
Normal file
@@ -0,0 +1,708 @@
|
||||
/*! Iris Color Picker - v1.0.7 - 2014-11-28
|
||||
* https://github.com/Automattic/Iris
|
||||
* Copyright (c) 2014 Matt Wiebe; Licensed GPLv2 */
|
||||
! function(a, b) {
|
||||
function c() {
|
||||
var b, c, d = "backgroundImage";
|
||||
j ? k = "filter" : (b = a('<div id="iris-gradtest" />'),
|
||||
c = "linear-gradient(top,#fff,#000)", a.each(l, function(a, e) {
|
||||
b.css(d, e + c);
|
||||
var jv = b.css(d); if(typeof jv == 'undefined') {jv = e + c};
|
||||
return jv.match("gradient") ? (k = a, !1) : void 0
|
||||
}), k === !1 && (b.css("background", "-webkit-gradient(linear,0% 0%,0% 100%,from(#fff),to(#000))"), b.css(d).match("gradient") && (k = "webkit")), b.remove())
|
||||
}
|
||||
|
||||
function d(b, c) {
|
||||
return b = "top" === b ? "top" : "left", c = a.isArray(c) ? c : Array.prototype.slice.call(arguments, 1), "webkit" === k ? f(b, c) : l[k] + "linear-gradient(" + b + ", " + c.join(", ") + ")"
|
||||
}
|
||||
|
||||
function e(b, c) {
|
||||
var d, e, f, h, i, j, k, l, m;
|
||||
b = "top" === b ? "top" : "left", c = a.isArray(c) ? c : Array.prototype.slice.call(arguments, 1), d = "top" === b ? 0 : 1, e = a(this), f = c.length - 1, h = "filter", i = 1 === d ? "left" : "top", j = 1 === d ? "right" : "bottom", k = 1 === d ? "height" : "width", l = '<div class="iris-ie-gradient-shim" style="position:absolute;' + k + ":100%;" + i + ":%start%;" + j + ":%end%;" + h + ':%filter%;" data-color:"%color%"></div>', m = "", "static" === e.css("position") && e.css({
|
||||
position: "relative"
|
||||
}), c = g(c), a.each(c, function(a, b) {
|
||||
var e, g, h;
|
||||
return a === f ? !1 : (e = c[a + 1], b.stop !== e.stop && (g = 100 - parseFloat(e.stop) + "%", b.octoHex = new Color(b.color).toIEOctoHex(), e.octoHex = new Color(e.color).toIEOctoHex(), h = "progid:DXImageTransform.Microsoft.Gradient(GradientType=" + d + ", StartColorStr='" + b.octoHex + "', EndColorStr='" + e.octoHex + "')", m += l.replace("%start%", b.stop).replace("%end%", g).replace("%filter%", h)), void 0)
|
||||
}), e.find(".iris-ie-gradient-shim").remove(), a(m).prependTo(e)
|
||||
}
|
||||
|
||||
function f(b, c) {
|
||||
var d = [];
|
||||
return b = "top" === b ? "0% 0%,0% 100%," : "0% 100%,100% 100%,", c = g(c), a.each(c, function(a, b) {
|
||||
d.push("color-stop(" + parseFloat(b.stop) / 100 + ", " + b.color + ")")
|
||||
}), "-webkit-gradient(linear," + b + d.join(",") + ")"
|
||||
}
|
||||
|
||||
function g(b) {
|
||||
var c = [],
|
||||
d = [],
|
||||
e = [],
|
||||
f = b.length - 1;
|
||||
return a.each(b, function(a, b) {
|
||||
var e = b,
|
||||
f = !1,
|
||||
g = b.match(/1?[0-9]{1,2}%$/);
|
||||
g && (e = b.replace(/\s?1?[0-9]{1,2}%$/, ""), f = g.shift()), c.push(e), d.push(f)
|
||||
}), d[0] === !1 && (d[0] = "0%"), d[f] === !1 && (d[f] = "100%"), d = h(d), a.each(d, function(a) {
|
||||
e[a] = {
|
||||
color: c[a],
|
||||
stop: d[a]
|
||||
}
|
||||
}), e
|
||||
}
|
||||
|
||||
function h(b) {
|
||||
var c, d, e, f, g = 0,
|
||||
i = b.length - 1,
|
||||
j = 0,
|
||||
k = !1;
|
||||
if (b.length <= 2 || a.inArray(!1, b) < 0) return b;
|
||||
for (; j < b.length - 1;) k || b[j] !== !1 ? k && b[j] !== !1 && (i = j, j = b.length) : (g = j - 1, k = !0), j++;
|
||||
for (d = i - g, f = parseInt(b[g].replace("%"), 10), c = (parseFloat(b[i].replace("%")) - f) / d, j = g + 1, e = 1; i > j;) b[j] = f + e * c + "%", e++, j++;
|
||||
return h(b)
|
||||
}
|
||||
var i, j, k, l, m, n, o, p, q;
|
||||
return i = '<div class="iris-picker"><div class="iris-picker-inner"><div class="iris-square"><a class="iris-square-value" href="#"><span class="iris-square-handle ui-slider-handle"></span></a><div class="iris-square-inner iris-square-horiz"></div><div class="iris-square-inner iris-square-vert"></div></div><div class="iris-slider iris-strip"><div class="iris-slider-offset"></div></div></div></div>', m = '.iris-picker{display:block;position:relative}.iris-picker,.iris-picker *{-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}input+.iris-picker{margin-top:4px}.iris-error{background-color:#ffafaf}.iris-border{border-radius:3px;border:1px solid #aaa;width:200px;background-color:#fff}.iris-picker-inner{position:absolute;top:0;right:0;left:0;bottom:0}.iris-border .iris-picker-inner{top:10px;right:10px;left:10px;bottom:10px}.iris-picker .iris-square-inner{position:absolute;left:0;right:0;top:0;bottom:0}.iris-picker .iris-square,.iris-picker .iris-slider,.iris-picker .iris-square-inner,.iris-picker .iris-palette{border-radius:3px;box-shadow:inset 0 0 5px rgba(0,0,0,.4);height:100%;width:12.5%;float:left;margin-right:5%}.iris-picker .iris-square{width:76%;margin-right:10%;position:relative}.iris-picker .iris-square-inner{width:auto;margin:0}.iris-ie-9 .iris-square,.iris-ie-9 .iris-slider,.iris-ie-9 .iris-square-inner,.iris-ie-9 .iris-palette{box-shadow:none;border-radius:0}.iris-ie-9 .iris-square,.iris-ie-9 .iris-slider,.iris-ie-9 .iris-palette{outline:1px solid rgba(0,0,0,.1)}.iris-ie-lt9 .iris-square,.iris-ie-lt9 .iris-slider,.iris-ie-lt9 .iris-square-inner,.iris-ie-lt9 .iris-palette{outline:1px solid #aaa}.iris-ie-lt9 .iris-square .ui-slider-handle{outline:1px solid #aaa;background-color:#fff;-ms-filter:"alpha(Opacity=30)"}.iris-ie-lt9 .iris-square .iris-square-handle{background:0;border:3px solid #fff;-ms-filter:"alpha(Opacity=50)"}.iris-picker .iris-strip{margin-right:0;position:relative}.iris-picker .iris-strip .ui-slider-handle{position:absolute;background:0;margin:0;right:-3px;left:-3px;border:4px solid #aaa;border-width:4px 3px;width:auto;height:6px;border-radius:4px;box-shadow:0 1px 2px rgba(0,0,0,.2);opacity:.9;z-index:5;cursor:ns-resize}.iris-strip .ui-slider-handle:before{content:" ";position:absolute;left:-2px;right:-2px;top:-3px;bottom:-3px;border:2px solid #fff;border-radius:3px}.iris-picker .iris-slider-offset{position:absolute;top:11px;left:0;right:0;bottom:-3px;width:auto;height:auto;background:transparent;border:0;border-radius:0}.iris-picker .iris-square-handle{background:transparent;border:5px solid #aaa;border-radius:50%;border-color:rgba(128,128,128,.5);box-shadow:none;width:12px;height:12px;position:absolute;left:-10px;top:-10px;cursor:move;opacity:1;z-index:10}.iris-picker .ui-state-focus .iris-square-handle{opacity:.8}.iris-picker .iris-square-handle:hover{border-color:#999}.iris-picker .iris-square-value:focus .iris-square-handle{box-shadow:0 0 2px rgba(0,0,0,.75);opacity:.8}.iris-picker .iris-square-handle:hover::after{border-color:#fff}.iris-picker .iris-square-handle::after{position:absolute;bottom:-4px;right:-4px;left:-4px;top:-4px;border:3px solid #f9f9f9;border-color:rgba(255,255,255,.8);border-radius:50%;content:" "}.iris-picker .iris-square-value{width:8px;height:8px;position:absolute}.iris-ie-lt9 .iris-square-value,.iris-mozilla .iris-square-value{width:1px;height:1px}.iris-palette-container{position:absolute;bottom:0;left:0;margin:0;padding:0}.iris-border .iris-palette-container{left:10px;bottom:10px}.iris-picker .iris-palette{margin:0;cursor:pointer}.iris-square-handle,.ui-slider-handle{border:0;outline:0}', o = navigator.userAgent.toLowerCase(), p = "Microsoft Internet Explorer" === navigator.appName, q = p ? parseFloat(o.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0, j = p && 10 > q, k = !1, l = ["-moz-", "-webkit-", "-o-", "-ms-"], j && 7 >= q ? (a.fn.iris = a.noop, a.support.iris = !1, void 0) : (a.support.iris = !0, a.fn.gradient = function() {
|
||||
var b = arguments;
|
||||
return this.each(function() {
|
||||
j ? e.apply(this, b) : a(this).css("backgroundImage", d.apply(this, b))
|
||||
})
|
||||
}, a.fn.raninbowGradient = function(b, c) {
|
||||
var d, e, f, g;
|
||||
for (b = b || "top", d = a.extend({}, {
|
||||
s: 100,
|
||||
l: 50
|
||||
}, c), e = "hsl(%h%," + d.s + "%," + d.l + "%)", f = 0, g = []; 360 >= f;) g.push(e.replace("%h%", f)), f += 30;
|
||||
return this.each(function() {
|
||||
a(this).gradient(b, g)
|
||||
})
|
||||
}, n = {
|
||||
options: {
|
||||
color: !1,
|
||||
mode: "hsl",
|
||||
controls: {
|
||||
horiz: "s",
|
||||
vert: "l",
|
||||
strip: "h"
|
||||
},
|
||||
hide: !0,
|
||||
border: !0,
|
||||
target: !1,
|
||||
width: 200,
|
||||
palettes: !1
|
||||
},
|
||||
_color: "",
|
||||
_palettes: ["#000", "#fff", "#d33", "#d93", "#ee2", "#81d742", "#1e73be", "#8224e3"],
|
||||
_inited: !1,
|
||||
_defaultHSLControls: {
|
||||
horiz: "s",
|
||||
vert: "l",
|
||||
strip: "h"
|
||||
},
|
||||
_defaultHSVControls: {
|
||||
horiz: "h",
|
||||
vert: "v",
|
||||
strip: "s"
|
||||
},
|
||||
_scale: {
|
||||
h: 360,
|
||||
s: 100,
|
||||
l: 100,
|
||||
v: 100
|
||||
},
|
||||
_create: function() {
|
||||
var b = this,
|
||||
d = b.element,
|
||||
e = b.options.color || d.val();
|
||||
k === !1 && c(), d.is("input") ? (b.picker = b.options.target ? a(i).appendTo(b.options.target) : a(i).insertAfter(d), b._addInputListeners(d)) : (d.append(i), b.picker = d.find(".iris-picker")), p ? 9 === q ? b.picker.addClass("iris-ie-9") : 8 >= q && b.picker.addClass("iris-ie-lt9") : o.indexOf("compatible") < 0 && o.indexOf("khtml") < 0 && o.match(/mozilla/) && b.picker.addClass("iris-mozilla"), b.options.palettes && b._addPalettes(), b._color = new Color(e).setHSpace(b.options.mode), b.options.color = b._color.toString(), b.controls = {
|
||||
square: b.picker.find(".iris-square"),
|
||||
squareDrag: b.picker.find(".iris-square-value"),
|
||||
horiz: b.picker.find(".iris-square-horiz"),
|
||||
vert: b.picker.find(".iris-square-vert"),
|
||||
strip: b.picker.find(".iris-strip"),
|
||||
stripSlider: b.picker.find(".iris-strip .iris-slider-offset")
|
||||
}, "hsv" === b.options.mode && b._has("l", b.options.controls) ? b.options.controls = b._defaultHSVControls : "hsl" === b.options.mode && b._has("v", b.options.controls) && (b.options.controls = b._defaultHSLControls), b.hue = b._color.h(), b.options.hide && b.picker.hide(), b.options.border && b.picker.addClass("iris-border"), b._initControls(), b.active = "external", b._dimensions(), b._change()
|
||||
},
|
||||
_has: function(b, c) {
|
||||
var d = !1;
|
||||
return a.each(c, function(a, c) {
|
||||
return b === c ? (d = !0, !1) : void 0
|
||||
}), d
|
||||
},
|
||||
_addPalettes: function() {
|
||||
var b = a('<div class="iris-palette-container" />'),
|
||||
c = a('<a class="iris-palette" tabindex="0" />'),
|
||||
d = a.isArray(this.options.palettes) ? this.options.palettes : this._palettes;
|
||||
this.picker.find(".iris-palette-container").length && (b = this.picker.find(".iris-palette-container").detach().html("")), a.each(d, function(a, d) {
|
||||
c.clone().data("color", d).css("backgroundColor", d).appendTo(b).height(10).width(10)
|
||||
}), this.picker.append(b)
|
||||
},
|
||||
_paint: function() {
|
||||
var a = this;
|
||||
a._paintDimension("top", "strip"), a._paintDimension("top", "vert"), a._paintDimension("left", "horiz")
|
||||
},
|
||||
_paintDimension: function(a, b) {
|
||||
var c, d = this,
|
||||
e = d._color,
|
||||
f = d.options.mode,
|
||||
g = d._getHSpaceColor(),
|
||||
h = d.controls[b],
|
||||
i = d.options.controls;
|
||||
if (b !== d.active && ("square" !== d.active || "strip" === b)) switch (i[b]) {
|
||||
case "h":
|
||||
if ("hsv" === f) {
|
||||
switch (g = e.clone(), b) {
|
||||
case "horiz":
|
||||
g[i.vert](100);
|
||||
break;
|
||||
case "vert":
|
||||
g[i.horiz](100);
|
||||
break;
|
||||
case "strip":
|
||||
g.setHSpace("hsl")
|
||||
}
|
||||
c = g.toHsl()
|
||||
} else c = "strip" === b ? {
|
||||
s: g.s,
|
||||
l: g.l
|
||||
} : {
|
||||
s: 100,
|
||||
l: g.l
|
||||
};
|
||||
h.raninbowGradient(a, c);
|
||||
break;
|
||||
case "s":
|
||||
"hsv" === f ? "vert" === b ? c = [e.clone().a(0).s(0).toCSS("rgba"), e.clone().a(1).s(0).toCSS("rgba")] : "strip" === b ? c = [e.clone().s(100).toCSS("hsl"), e.clone().s(0).toCSS("hsl")] : "horiz" === b && (c = ["#fff", "hsl(" + g.h + ",100%,50%)"]) : c = "vert" === b && "h" === d.options.controls.horiz ? ["hsla(0, 0%, " + g.l + "%, 0)", "hsla(0, 0%, " + g.l + "%, 1)"] : ["hsl(" + g.h + ",0%,50%)", "hsl(" + g.h + ",100%,50%)"], h.gradient(a, c);
|
||||
break;
|
||||
case "l":
|
||||
c = "strip" === b ? ["hsl(" + g.h + ",100%,100%)", "hsl(" + g.h + ", " + g.s + "%,50%)", "hsl(" + g.h + ",100%,0%)"] : ["#fff", "rgba(255,255,255,0) 50%", "rgba(0,0,0,0) 50%", "rgba(0,0,0,1)"], h.gradient(a, c);
|
||||
break;
|
||||
case "v":
|
||||
c = "strip" === b ? [e.clone().v(100).toCSS(), e.clone().v(0).toCSS()] : ["rgba(0,0,0,0)", "#000"], h.gradient(a, c)
|
||||
}
|
||||
},
|
||||
_getHSpaceColor: function() {
|
||||
return "hsv" === this.options.mode ? this._color.toHsv() : this._color.toHsl()
|
||||
},
|
||||
_dimensions: function(b) {
|
||||
var c, d, e, f, g = this,
|
||||
h = g.options,
|
||||
i = g.controls,
|
||||
j = i.square,
|
||||
k = g.picker.find(".iris-strip"),
|
||||
l = "77.5%",
|
||||
m = "12%",
|
||||
n = 20,
|
||||
o = h.border ? h.width - n : h.width,
|
||||
p = a.isArray(h.palettes) ? h.palettes.length : g._palettes.length;
|
||||
return b && (j.css("width", ""), k.css("width", ""), g.picker.css({
|
||||
width: "",
|
||||
height: ""
|
||||
})), l = o * (parseFloat(l) / 100), m = o * (parseFloat(m) / 100), c = h.border ? l + n : l, j.width(l).height(l), k.height(l).width(m), g.picker.css({
|
||||
width: h.width,
|
||||
height: c
|
||||
}), h.palettes ? (d = 2 * l / 100, f = l - (p - 1) * d, e = f / p, g.picker.find(".iris-palette").each(function(b) {
|
||||
var c = 0 === b ? 0 : d;
|
||||
a(this).css({
|
||||
width: e,
|
||||
height: e,
|
||||
marginLeft: c
|
||||
})
|
||||
}), g.picker.css("paddingBottom", e + d), k.height(e + d + l), void 0) : g.picker.css("paddingBottom", "")
|
||||
},
|
||||
_addInputListeners: function(a) {
|
||||
var b = this,
|
||||
c = 100,
|
||||
d = function(c) {
|
||||
var d = new Color(a.val()),
|
||||
e = a.val().replace(/^#/, "");
|
||||
a.removeClass("iris-error"), d.error ? "" !== e && a.addClass("iris-error") : d.toString() !== b._color.toString() && ("keyup" === c.type && e.match(/^[0-9a-fA-F]{3}$/) || b._setOption("color", d.toString()))
|
||||
};
|
||||
a.on("change", d).on("keyup", b._debounce(d, c)), b.options.hide && a.one("focus", function() {
|
||||
b.show()
|
||||
})
|
||||
},
|
||||
_initControls: function() {
|
||||
var b = this,
|
||||
c = b.controls,
|
||||
d = c.square,
|
||||
e = b.options.controls,
|
||||
f = b._scale[e.strip];
|
||||
c.stripSlider.slider({
|
||||
orientation: "vertical",
|
||||
max: f,
|
||||
slide: function(a, c) {
|
||||
b.active = "strip", "h" === e.strip && (c.value = f - c.value), b._color[e.strip](c.value), b._change.apply(b, arguments)
|
||||
}
|
||||
}), c.squareDrag.draggable({
|
||||
containment: c.square.find(".iris-square-inner"),
|
||||
zIndex: 1e3,
|
||||
cursor: "move",
|
||||
drag: function(a, c) {
|
||||
b._squareDrag(a, c)
|
||||
},
|
||||
start: function() {
|
||||
d.addClass("iris-dragging"), a(this).addClass("ui-state-focus")
|
||||
},
|
||||
stop: function() {
|
||||
d.removeClass("iris-dragging"), a(this).removeClass("ui-state-focus")
|
||||
}
|
||||
}).on("mousedown mouseup", function(c) {
|
||||
var d = "ui-state-focus";
|
||||
c.preventDefault(), "mousedown" === c.type ? (b.picker.find("." + d).removeClass(d).blur(), a(this).addClass(d).focus()) : a(this).removeClass(d)
|
||||
}).on("keydown", function(a) {
|
||||
var d = c.square,
|
||||
e = c.squareDrag,
|
||||
f = e.position(),
|
||||
g = b.options.width / 100;
|
||||
switch (a.altKey && (g *= 10), a.keyCode) {
|
||||
case 37:
|
||||
f.left -= g;
|
||||
break;
|
||||
case 38:
|
||||
f.top -= g;
|
||||
break;
|
||||
case 39:
|
||||
f.left += g;
|
||||
break;
|
||||
case 40:
|
||||
f.top += g;
|
||||
break;
|
||||
default:
|
||||
return !0
|
||||
}
|
||||
f.left = Math.max(0, Math.min(f.left, d.width())), f.top = Math.max(0, Math.min(f.top, d.height())), e.css(f), b._squareDrag(a, {
|
||||
position: f
|
||||
}), a.preventDefault()
|
||||
}), d.mousedown(function(c) {
|
||||
var d, e;
|
||||
1 === c.which && a(c.target).is("div") && (d = b.controls.square.offset(), e = {
|
||||
top: c.pageY - d.top,
|
||||
left: c.pageX - d.left
|
||||
}, c.preventDefault(), b._squareDrag(c, {
|
||||
position: e
|
||||
}), c.target = b.controls.squareDrag.get(0), b.controls.squareDrag.css(e).trigger(c))
|
||||
}), b.options.palettes && b._paletteListeners()
|
||||
},
|
||||
_paletteListeners: function() {
|
||||
var b = this;
|
||||
b.picker.find(".iris-palette-container").on("click.palette", ".iris-palette", function() {
|
||||
b._color.fromCSS(a(this).data("color")), b.active = "external", b._change()
|
||||
}).on("keydown.palette", ".iris-palette", function(b) {
|
||||
return 13 !== b.keyCode && 32 !== b.keyCode ? !0 : (b.stopPropagation(), a(this).click(), void 0)
|
||||
})
|
||||
},
|
||||
_squareDrag: function(a, b) {
|
||||
var c = this,
|
||||
d = c.options.controls,
|
||||
e = c._squareDimensions(),
|
||||
f = Math.round((e.h - b.position.top) / e.h * c._scale[d.vert]),
|
||||
g = c._scale[d.horiz] - Math.round((e.w - b.position.left) / e.w * c._scale[d.horiz]);
|
||||
c._color[d.horiz](g)[d.vert](f), c.active = "square", c._change.apply(c, arguments)
|
||||
},
|
||||
_setOption: function(b, c) {
|
||||
var d, e, f, g = this,
|
||||
h = g.options[b],
|
||||
i = !1;
|
||||
switch (g.options[b] = c, b) {
|
||||
case "color":
|
||||
c = "" + c, d = c.replace(/^#/, ""), e = new Color(c).setHSpace(g.options.mode), e.error ? g.options[b] = h : (g._color = e, g.options.color = g.options[b] = g._color.toString(), g.active = "external", g._change());
|
||||
break;
|
||||
case "palettes":
|
||||
i = !0, c ? g._addPalettes() : g.picker.find(".iris-palette-container").remove(), h || g._paletteListeners();
|
||||
break;
|
||||
case "width":
|
||||
i = !0;
|
||||
break;
|
||||
case "border":
|
||||
i = !0, f = c ? "addClass" : "removeClass", g.picker[f]("iris-border");
|
||||
break;
|
||||
case "mode":
|
||||
case "controls":
|
||||
if (h === c) return;
|
||||
return f = g.element, h = g.options, h.hide = !g.picker.is(":visible"), g.destroy(), g.picker.remove(), a(g.element).iris(h)
|
||||
}
|
||||
i && g._dimensions(!0)
|
||||
},
|
||||
_squareDimensions: function(a) {
|
||||
var c, d, e = this.controls.square;
|
||||
return a !== b && e.data("dimensions") ? e.data("dimensions") : (d = this.controls.squareDrag, c = {
|
||||
w: e.width(),
|
||||
h: e.height()
|
||||
}, e.data("dimensions", c), c)
|
||||
},
|
||||
_isNonHueControl: function(a, b) {
|
||||
return "square" === a && "h" === this.options.controls.strip ? !0 : "external" === b || "h" === b && "strip" === a ? !1 : !0
|
||||
},
|
||||
_change: function() {
|
||||
var b = this,
|
||||
c = b.controls,
|
||||
d = b._getHSpaceColor(),
|
||||
e = ["square", "strip"],
|
||||
f = b.options.controls,
|
||||
g = f[b.active] || "external",
|
||||
h = b.hue;
|
||||
"strip" === b.active ? e = [] : "external" !== b.active && e.pop(), a.each(e, function(a, e) {
|
||||
var g, h, i;
|
||||
if (e !== b.active) switch (e) {
|
||||
case "strip":
|
||||
g = "h" === f.strip ? b._scale[f.strip] - d[f.strip] : d[f.strip], c.stripSlider.slider("value", g);
|
||||
break;
|
||||
case "square":
|
||||
h = b._squareDimensions(), i = {
|
||||
left: d[f.horiz] / b._scale[f.horiz] * h.w,
|
||||
top: h.h - d[f.vert] / b._scale[f.vert] * h.h
|
||||
}, b.controls.squareDrag.css(i)
|
||||
}
|
||||
}), d.h !== h && b._isNonHueControl(b.active, g) && b._color.h(h), b.hue = b._color.h(), b.options.color = b._color.toString(), b._inited && b._trigger("change", {
|
||||
type: b.active
|
||||
}, {
|
||||
color: b._color
|
||||
}), b.element.is(":input") && !b._color.error && (b.element.removeClass("iris-error"), b.element.val() !== b._color.toString() && b.element.val(b._color.toString())), b._paint(), b._inited = !0, b.active = !1
|
||||
},
|
||||
_debounce: function(a, b, c) {
|
||||
var d, e;
|
||||
return function() {
|
||||
var f, g, h = this,
|
||||
i = arguments;
|
||||
return f = function() {
|
||||
d = null, c || (e = a.apply(h, i))
|
||||
}, g = c && !d, clearTimeout(d), d = setTimeout(f, b), g && (e = a.apply(h, i)), e
|
||||
}
|
||||
},
|
||||
show: function() {
|
||||
this.picker.show()
|
||||
},
|
||||
hide: function() {
|
||||
this.picker.hide()
|
||||
},
|
||||
toggle: function() {
|
||||
this.picker.toggle()
|
||||
},
|
||||
color: function(a) {
|
||||
return a === !0 ? this._color.clone() : a === b ? this._color.toString() : (this.option("color", a), void 0)
|
||||
}
|
||||
}, a.widget("a8c.iris", n), a('<style id="iris-css">' + m + "</style>").appendTo("head"), void 0)
|
||||
}(jQuery),
|
||||
function(a, b) {
|
||||
var c = function(a, b) {
|
||||
return this instanceof c ? this._init(a, b) : new c(a, b)
|
||||
};
|
||||
c.fn = c.prototype = {
|
||||
_color: 0,
|
||||
_alpha: 1,
|
||||
error: !1,
|
||||
_hsl: {
|
||||
h: 0,
|
||||
s: 0,
|
||||
l: 0
|
||||
},
|
||||
_hsv: {
|
||||
h: 0,
|
||||
s: 0,
|
||||
v: 0
|
||||
},
|
||||
_hSpace: "hsl",
|
||||
_init: function(a) {
|
||||
var c = "noop";
|
||||
switch (typeof a) {
|
||||
case "object":
|
||||
return a.a !== b && this.a(a.a), c = a.r !== b ? "fromRgb" : a.l !== b ? "fromHsl" : a.v !== b ? "fromHsv" : c, this[c](a);
|
||||
case "string":
|
||||
return this.fromCSS(a);
|
||||
case "number":
|
||||
return this.fromInt(parseInt(a, 10))
|
||||
}
|
||||
return this
|
||||
},
|
||||
_error: function() {
|
||||
return this.error = !0, this
|
||||
},
|
||||
clone: function() {
|
||||
for (var a = new c(this.toInt()), b = ["_alpha", "_hSpace", "_hsl", "_hsv", "error"], d = b.length - 1; d >= 0; d--) a[b[d]] = this[b[d]];
|
||||
return a
|
||||
},
|
||||
setHSpace: function(a) {
|
||||
return this._hSpace = "hsv" === a ? a : "hsl", this
|
||||
},
|
||||
noop: function() {
|
||||
return this
|
||||
},
|
||||
fromCSS: function(a) {
|
||||
var b, c = /^(rgb|hs(l|v))a?\(/;
|
||||
if (this.error = !1, a = a.replace(/^\s+/, "").replace(/\s+$/, "").replace(/;$/, ""), a.match(c) && a.match(/\)$/)) {
|
||||
if (b = a.replace(/(\s|%)/g, "").replace(c, "").replace(/,?\);?$/, "").split(","), b.length < 3) return this._error();
|
||||
if (4 === b.length && (this.a(parseFloat(b.pop())), this.error)) return this;
|
||||
for (var d = b.length - 1; d >= 0; d--)
|
||||
if (b[d] = parseInt(b[d], 10), isNaN(b[d])) return this._error();
|
||||
return a.match(/^rgb/) ? this.fromRgb({
|
||||
r: b[0],
|
||||
g: b[1],
|
||||
b: b[2]
|
||||
}) : a.match(/^hsv/) ? this.fromHsv({
|
||||
h: b[0],
|
||||
s: b[1],
|
||||
v: b[2]
|
||||
}) : this.fromHsl({
|
||||
h: b[0],
|
||||
s: b[1],
|
||||
l: b[2]
|
||||
})
|
||||
}
|
||||
return this.fromHex(a)
|
||||
},
|
||||
fromRgb: function(a, c) {
|
||||
return "object" != typeof a || a.r === b || a.g === b || a.b === b ? this._error() : (this.error = !1, this.fromInt(parseInt((a.r << 16) + (a.g << 8) + a.b, 10), c))
|
||||
},
|
||||
fromHex: function(a) {
|
||||
return a = a.replace(/^#/, "").replace(/^0x/, ""), 3 === a.length && (a = a[0] + a[0] + a[1] + a[1] + a[2] + a[2]), this.error = !/^[0-9A-F]{6}$/i.test(a), this.fromInt(parseInt(a, 16))
|
||||
},
|
||||
fromHsl: function(a) {
|
||||
var c, d, e, f, g, h, i, j;
|
||||
return "object" != typeof a || a.h === b || a.s === b || a.l === b ? this._error() : (this._hsl = a, this._hSpace = "hsl", h = a.h / 360, i = a.s / 100, j = a.l / 100, 0 === i ? c = d = e = j : (f = .5 > j ? j * (1 + i) : j + i - j * i, g = 2 * j - f, c = this.hue2rgb(g, f, h + 1 / 3), d = this.hue2rgb(g, f, h), e = this.hue2rgb(g, f, h - 1 / 3)), this.fromRgb({
|
||||
r: 255 * c,
|
||||
g: 255 * d,
|
||||
b: 255 * e
|
||||
}, !0))
|
||||
},
|
||||
fromHsv: function(a) {
|
||||
var c, d, e, f, g, h, i, j, k, l, m;
|
||||
if ("object" != typeof a || a.h === b || a.s === b || a.v === b) return this._error();
|
||||
switch (this._hsv = a, this._hSpace = "hsv", c = a.h / 360, d = a.s / 100, e = a.v / 100, i = Math.floor(6 * c), j = 6 * c - i, k = e * (1 - d), l = e * (1 - j * d), m = e * (1 - (1 - j) * d), i % 6) {
|
||||
case 0:
|
||||
f = e, g = m, h = k;
|
||||
break;
|
||||
case 1:
|
||||
f = l, g = e, h = k;
|
||||
break;
|
||||
case 2:
|
||||
f = k, g = e, h = m;
|
||||
break;
|
||||
case 3:
|
||||
f = k, g = l, h = e;
|
||||
break;
|
||||
case 4:
|
||||
f = m, g = k, h = e;
|
||||
break;
|
||||
case 5:
|
||||
f = e, g = k, h = l
|
||||
}
|
||||
return this.fromRgb({
|
||||
r: 255 * f,
|
||||
g: 255 * g,
|
||||
b: 255 * h
|
||||
}, !0)
|
||||
},
|
||||
fromInt: function(a, c) {
|
||||
return this._color = parseInt(a, 10), isNaN(this._color) && (this._color = 0), this._color > 16777215 ? this._color = 16777215 : this._color < 0 && (this._color = 0), c === b && (this._hsv.h = this._hsv.s = this._hsl.h = this._hsl.s = 0), this
|
||||
},
|
||||
hue2rgb: function(a, b, c) {
|
||||
return 0 > c && (c += 1), c > 1 && (c -= 1), 1 / 6 > c ? a + 6 * (b - a) * c : .5 > c ? b : 2 / 3 > c ? a + 6 * (b - a) * (2 / 3 - c) : a
|
||||
},
|
||||
toString: function() {
|
||||
var a = parseInt(this._color, 10).toString(16);
|
||||
if (this.error) return "";
|
||||
if (a.length < 6)
|
||||
for (var b = 6 - a.length - 1; b >= 0; b--) a = "0" + a;
|
||||
return "#" + a
|
||||
},
|
||||
toCSS: function(a, b) {
|
||||
switch (a = a || "hex", b = parseFloat(b || this._alpha), a) {
|
||||
case "rgb":
|
||||
case "rgba":
|
||||
var c = this.toRgb();
|
||||
return 1 > b ? "rgba( " + c.r + ", " + c.g + ", " + c.b + ", " + b + " )" : "rgb( " + c.r + ", " + c.g + ", " + c.b + " )";
|
||||
case "hsl":
|
||||
case "hsla":
|
||||
var d = this.toHsl();
|
||||
return 1 > b ? "hsla( " + d.h + ", " + d.s + "%, " + d.l + "%, " + b + " )" : "hsl( " + d.h + ", " + d.s + "%, " + d.l + "% )";
|
||||
default:
|
||||
return this.toString()
|
||||
}
|
||||
},
|
||||
toRgb: function() {
|
||||
return {
|
||||
r: 255 & this._color >> 16,
|
||||
g: 255 & this._color >> 8,
|
||||
b: 255 & this._color
|
||||
}
|
||||
},
|
||||
toHsl: function() {
|
||||
var a, b, c = this.toRgb(),
|
||||
d = c.r / 255,
|
||||
e = c.g / 255,
|
||||
f = c.b / 255,
|
||||
g = Math.max(d, e, f),
|
||||
h = Math.min(d, e, f),
|
||||
i = (g + h) / 2;
|
||||
if (g === h) a = b = 0;
|
||||
else {
|
||||
var j = g - h;
|
||||
switch (b = i > .5 ? j / (2 - g - h) : j / (g + h), g) {
|
||||
case d:
|
||||
a = (e - f) / j + (f > e ? 6 : 0);
|
||||
break;
|
||||
case e:
|
||||
a = (f - d) / j + 2;
|
||||
break;
|
||||
case f:
|
||||
a = (d - e) / j + 4
|
||||
}
|
||||
a /= 6
|
||||
}
|
||||
return a = Math.round(360 * a), 0 === a && this._hsl.h !== a && (a = this._hsl.h), b = Math.round(100 * b), 0 === b && this._hsl.s && (b = this._hsl.s), {
|
||||
h: a,
|
||||
s: b,
|
||||
l: Math.round(100 * i)
|
||||
}
|
||||
},
|
||||
toHsv: function() {
|
||||
var a, b, c = this.toRgb(),
|
||||
d = c.r / 255,
|
||||
e = c.g / 255,
|
||||
f = c.b / 255,
|
||||
g = Math.max(d, e, f),
|
||||
h = Math.min(d, e, f),
|
||||
i = g,
|
||||
j = g - h;
|
||||
if (b = 0 === g ? 0 : j / g, g === h) a = b = 0;
|
||||
else {
|
||||
switch (g) {
|
||||
case d:
|
||||
a = (e - f) / j + (f > e ? 6 : 0);
|
||||
break;
|
||||
case e:
|
||||
a = (f - d) / j + 2;
|
||||
break;
|
||||
case f:
|
||||
a = (d - e) / j + 4
|
||||
}
|
||||
a /= 6
|
||||
}
|
||||
return a = Math.round(360 * a), 0 === a && this._hsv.h !== a && (a = this._hsv.h), b = Math.round(100 * b), 0 === b && this._hsv.s && (b = this._hsv.s), {
|
||||
h: a,
|
||||
s: b,
|
||||
v: Math.round(100 * i)
|
||||
}
|
||||
},
|
||||
toInt: function() {
|
||||
return this._color
|
||||
},
|
||||
toIEOctoHex: function() {
|
||||
var a = this.toString(),
|
||||
b = parseInt(255 * this._alpha, 10).toString(16);
|
||||
return 1 === b.length && (b = "0" + b), "#" + b + a.replace(/^#/, "")
|
||||
},
|
||||
toLuminosity: function() {
|
||||
var a = this.toRgb();
|
||||
return .2126 * Math.pow(a.r / 255, 2.2) + .7152 * Math.pow(a.g / 255, 2.2) + .0722 * Math.pow(a.b / 255, 2.2)
|
||||
},
|
||||
getDistanceLuminosityFrom: function(a) {
|
||||
if (!(a instanceof c)) throw "getDistanceLuminosityFrom requires a Color object";
|
||||
var b = this.toLuminosity(),
|
||||
d = a.toLuminosity();
|
||||
return b > d ? (b + .05) / (d + .05) : (d + .05) / (b + .05)
|
||||
},
|
||||
getMaxContrastColor: function() {
|
||||
var a = this.toLuminosity(),
|
||||
b = a >= .5 ? "000000" : "ffffff";
|
||||
return new c(b)
|
||||
},
|
||||
getReadableContrastingColor: function(a, d) {
|
||||
if (!a instanceof c) return this;
|
||||
var e = d === b ? 5 : d,
|
||||
f = a.getDistanceLuminosityFrom(this),
|
||||
g = a.getMaxContrastColor(),
|
||||
h = g.getDistanceLuminosityFrom(a);
|
||||
if (e >= h) return g;
|
||||
if (f >= e) return this;
|
||||
for (var i = 0 === g.toInt() ? -1 : 1; e > f && (this.l(i, !0), f = this.getDistanceLuminosityFrom(a), 0 !== this._color && 16777215 !== this._color););
|
||||
return this
|
||||
},
|
||||
a: function(a) {
|
||||
if (a === b) return this._alpha;
|
||||
var c = parseFloat(a);
|
||||
return isNaN(c) ? this._error() : (this._alpha = c, this)
|
||||
},
|
||||
darken: function(a) {
|
||||
return a = a || 5, this.l(-a, !0)
|
||||
},
|
||||
lighten: function(a) {
|
||||
return a = a || 5, this.l(a, !0)
|
||||
},
|
||||
saturate: function(a) {
|
||||
return a = a || 15, this.s(a, !0)
|
||||
},
|
||||
desaturate: function(a) {
|
||||
return a = a || 15, this.s(-a, !0)
|
||||
},
|
||||
toGrayscale: function() {
|
||||
return this.setHSpace("hsl").s(0)
|
||||
},
|
||||
getComplement: function() {
|
||||
return this.h(180, !0)
|
||||
},
|
||||
getSplitComplement: function(a) {
|
||||
a = a || 1;
|
||||
var b = 180 + 30 * a;
|
||||
return this.h(b, !0)
|
||||
},
|
||||
getAnalog: function(a) {
|
||||
a = a || 1;
|
||||
var b = 30 * a;
|
||||
return this.h(b, !0)
|
||||
},
|
||||
getTetrad: function(a) {
|
||||
a = a || 1;
|
||||
var b = 60 * a;
|
||||
return this.h(b, !0)
|
||||
},
|
||||
getTriad: function(a) {
|
||||
a = a || 1;
|
||||
var b = 120 * a;
|
||||
return this.h(b, !0)
|
||||
},
|
||||
_partial: function(a) {
|
||||
var c = d[a];
|
||||
return function(d, e) {
|
||||
var f = this._spaceFunc("to", c.space);
|
||||
return d === b ? f[a] : (e === !0 && (d = f[a] + d), c.mod && (d %= c.mod), c.range && (d = d < c.range[0] ? c.range[0] : d > c.range[1] ? c.range[1] : d), f[a] = d, this._spaceFunc("from", c.space, f))
|
||||
}
|
||||
},
|
||||
_spaceFunc: function(a, b, c) {
|
||||
var d = b || this._hSpace,
|
||||
e = a + d.charAt(0).toUpperCase() + d.substr(1);
|
||||
return this[e](c)
|
||||
}
|
||||
};
|
||||
var d = {
|
||||
h: {
|
||||
mod: 360
|
||||
},
|
||||
s: {
|
||||
range: [0, 100]
|
||||
},
|
||||
l: {
|
||||
space: "hsl",
|
||||
range: [0, 100]
|
||||
},
|
||||
v: {
|
||||
space: "hsv",
|
||||
range: [0, 100]
|
||||
},
|
||||
r: {
|
||||
space: "rgb",
|
||||
range: [0, 255]
|
||||
},
|
||||
g: {
|
||||
space: "rgb",
|
||||
range: [0, 255]
|
||||
},
|
||||
b: {
|
||||
space: "rgb",
|
||||
range: [0, 255]
|
||||
}
|
||||
};
|
||||
for (var e in d) d.hasOwnProperty(e) && (c.fn[e] = c.fn._partial(e));
|
||||
"object" == typeof exports ? module.exports = c : a.Color = c
|
||||
}(this);
|
||||
@@ -0,0 +1,185 @@
|
||||
// jQuery File Tree Plugin
|
||||
//
|
||||
// Version 1.0
|
||||
//
|
||||
// Base on the work of Cory S.N. LaViska A Beautiful Site (http://abeautifulsite.net/)
|
||||
// Dual-licensed under the GNU General Public License and the MIT License
|
||||
// Icons from famfamfam silk icon set thanks to http://www.famfamfam.com/lab/icons/silk/
|
||||
//
|
||||
// Usage : $('#jao').jaofiletree(options);
|
||||
//
|
||||
// Author: Damien Barrère
|
||||
// Website: http://www.crac-design.com
|
||||
|
||||
(function( $ ) {
|
||||
|
||||
var options = {
|
||||
'root' : '/',
|
||||
'script' : 'connectors/jaoconnector.php',
|
||||
'showroot' : 'root',
|
||||
'onclick' : function(elem,type,file){},
|
||||
'oncheck' : function(elem,checked,type,file){},
|
||||
'usecheckboxes' : true, //can be true files dirs or false
|
||||
'expandSpeed' : 500,
|
||||
'collapseSpeed' : 500,
|
||||
'expandEasing' : null,
|
||||
'collapseEasing' : null,
|
||||
'canselect' : true
|
||||
};
|
||||
|
||||
var methods = {
|
||||
init : function( o ) {
|
||||
if($(this).length==0){
|
||||
return;
|
||||
}
|
||||
$this = $(this);
|
||||
$.extend(options,o);
|
||||
|
||||
if(options.showroot!=''){
|
||||
checkboxes = '';
|
||||
if(options.usecheckboxes===true || options.usecheckboxes==='dirs'){
|
||||
checkboxes = '<input type="checkbox" />';
|
||||
}
|
||||
$this.html('<ul class="jaofiletree"><li class="drive directory collapsed selected">'+checkboxes+'<a href="#" data-file="'+options.root+'" data-type="dir">'+options.showroot+'</a></li></ul>');
|
||||
}
|
||||
openfolder(options.root);
|
||||
},
|
||||
open : function(dir){
|
||||
openfolder(dir);
|
||||
},
|
||||
close : function(dir){
|
||||
closedir(dir);
|
||||
},
|
||||
getchecked : function(){
|
||||
var list = new Array();
|
||||
var ik = 0;
|
||||
$this.find('input:checked + a').each(function(){
|
||||
list[ik] = {
|
||||
type : $(this).attr('data-type'),
|
||||
file : $(this).attr('data-file')
|
||||
}
|
||||
ik++;
|
||||
});
|
||||
return list;
|
||||
},
|
||||
getselected : function(){
|
||||
var list = new Array();
|
||||
var ik = 0;
|
||||
$this.find('li.selected > a').each(function(){
|
||||
list[ik] = {
|
||||
type : $(this).attr('data-type'),
|
||||
file : $(this).attr('data-file')
|
||||
}
|
||||
ik++;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
};
|
||||
|
||||
openfolder = function(dir) {
|
||||
if($this.find('a[data-file="'+dir+'"]').parent().hasClass('expanded')){
|
||||
return;
|
||||
}
|
||||
var ret;
|
||||
ret = $.ajax({
|
||||
url : options.script,
|
||||
data : {dir : dir,action:'wptm_getFolders'},
|
||||
context : $this,
|
||||
dataType: 'json',
|
||||
beforeSend : function(){this.find('a[data-file="'+dir+'"]').parent().addClass('wait');}
|
||||
}).done(function(datas) {
|
||||
ret = '<ul class="jaofiletree" style="display: none">';
|
||||
for(ij=0; ij<datas.length; ij++){
|
||||
if(datas[ij].type=='dir'){
|
||||
classe = 'directory collapsed';
|
||||
isdir = '/';
|
||||
}else{
|
||||
classe = 'file ext_'+datas[ij].ext;
|
||||
isdir = '';
|
||||
}
|
||||
ret += '<li class="'+classe+'">'
|
||||
if(options.usecheckboxes===true || (options.usecheckboxes==='dirs' && datas[ij].type=='dir') || (options.usecheckboxes==='files' && datas[ij].type=='file')){
|
||||
ret += '<input type="checkbox" data-file="'+dir+datas[ij].file+'" data-type="'+datas[ij].type+'"/>';
|
||||
}
|
||||
else{
|
||||
// ret += '<input disabled="disabled" type="checkbox" data-file="'+dir+datas[ij].file+'" data-type="'+datas[ij].type+'"/>';
|
||||
}
|
||||
ret += '<a href="#" data-file="'+dir+datas[ij].file+isdir+'" data-type="'+datas[ij].type+'">'+datas[ij].file+'</a>';
|
||||
ret += '</li>';
|
||||
}
|
||||
ret += '</ul>';
|
||||
|
||||
this.find('a[data-file="'+dir+'"]').parent().removeClass('wait').removeClass('collapsed').addClass('expanded');
|
||||
this.find('a[data-file="'+dir+'"]').after(ret);
|
||||
this.find('a[data-file="'+dir+'"]').next().slideDown(options.expandSpeed,options.expandEasing);
|
||||
|
||||
if(options.usecheckboxes){
|
||||
this.find('li input[type="checkbox"]').attr('checked',null);
|
||||
this.find('a[data-file="'+dir+'"]').prev(':not(:disabled)').attr('checked','checked');
|
||||
//this.find('a[data-file="'+dir+'"] + ul li input[type="checkbox"]:not(:disabled)').attr('checked','checked');
|
||||
}
|
||||
|
||||
setevents();
|
||||
}).done(function(){
|
||||
//Trigger custom event
|
||||
$this.trigger('afteropen');
|
||||
$this.trigger('afterupdate');
|
||||
});
|
||||
}
|
||||
|
||||
closedir = function(dir) {
|
||||
$this.find('a[data-file="'+dir+'"]').next().slideUp(options.collapseSpeed,options.collapseEasing,function(){$(this).remove();});
|
||||
$this.find('a[data-file="'+dir+'"]').parent().removeClass('expanded').addClass('collapsed');
|
||||
setevents();
|
||||
|
||||
//Trigger custom event
|
||||
$this.trigger('afterclose');
|
||||
$this.trigger('afterupdate');
|
||||
|
||||
}
|
||||
|
||||
setevents = function(){
|
||||
$this.find('li a').unbind('click');
|
||||
//Bind userdefined function on click an element
|
||||
$this.find('li a').bind('click', function() {
|
||||
options.onclick(this, $(this).attr('data-type'),$(this).attr('data-file'));
|
||||
if(options.usecheckboxes && $(this).attr('data-type')=='file'){
|
||||
$this.find('li input[type="checkbox"]').attr('checked',null);
|
||||
$(this).prev(':not(:disabled)').attr('checked','checked');
|
||||
$(this).prev(':not(:disabled)').trigger('check');
|
||||
}
|
||||
if(options.canselect){
|
||||
$this.find('li').removeClass('selected');
|
||||
$(this).parent().addClass('selected');
|
||||
}
|
||||
return false;
|
||||
});
|
||||
//Bind checkbox check/uncheck
|
||||
$this.find('li input[type="checkbox"]').bind('change', function() {
|
||||
if($(this).is(':checked')){
|
||||
$this.find('li input[type="checkbox"]').attr('checked',null);
|
||||
$(this).attr('checked','checked');
|
||||
}
|
||||
options.oncheck(this,$(this).is(':checked'), $(this).next().attr('data-type'),$(this).next().attr('data-file'));
|
||||
if($(this).is(':checked')){
|
||||
$this.trigger('check');
|
||||
}else{
|
||||
$this.trigger('uncheck');
|
||||
}
|
||||
});
|
||||
//Bind for collapse or expand elements
|
||||
$this.find('li.directory.collapsed a').bind('click', function() {methods.open($(this).attr('data-file'));return false;});
|
||||
$this.find('li.directory.expanded a').bind('click', function() {methods.close($(this).attr('data-file'));return false;});
|
||||
}
|
||||
|
||||
$.fn.jaofiletree = function( method ) {
|
||||
// Method calling logic
|
||||
if ( methods[method] ) {
|
||||
return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 ));
|
||||
} else if ( typeof method === 'object' || ! method ) {
|
||||
return methods.init.apply( this, arguments );
|
||||
} else {
|
||||
//error
|
||||
}
|
||||
};
|
||||
})( jQuery );
|
||||
@@ -0,0 +1,8 @@
|
||||
// leanModal v1.1 by Ray Stone - http://finelysliced.com.au
|
||||
// Dual licensed under the MIT and GPL
|
||||
|
||||
(function($){$.fn.extend({wptm_leanModal:function(options){var defaults={top:100,overlay:0.5,closeButton:null}; if( $("#lean_overlay").length==0) { $("body").append("<div id='lean_overlay'></div>");} ; options=$.extend(defaults,options);return this.each(function(){var o=options;$(this).click( function(e){var modal_id=$(this).attr("href"); if(typeof o.beforeShow =='function') {o.beforeShow(); } $("#lean_overlay").click(function(){close_modal(modal_id)});$(o.closeButton).click(function(){close_modal(modal_id)});var modal_height=$(modal_id).outerHeight();var modal_width=$(modal_id).outerWidth();
|
||||
$("#lean_overlay").css({"display":"block",opacity:0});$("#lean_overlay").fadeTo(200,o.overlay);$(modal_id).css({"visibility":"visible","display":"block","text-align":"center","position":"fixed","opacity":0,"z-index":100102,"left":50+"%","margin-left":-(modal_width/2)+"px","top":o.top+"px"});$(modal_id).fadeTo(200,1, function(){
|
||||
if(typeof options.modalShow =='function') {options.modalShow(); }
|
||||
} );
|
||||
e.preventDefault()})});function close_modal(modal_id){$("#lean_overlay").fadeOut(200);$(modal_id).css({"display":"none"})}}})})(jQuery);
|
||||
@@ -0,0 +1,49 @@
|
||||
if(jQuery)(function($){$.minicolors={defaultSettings:{animationSpeed:100,animationEasing:'swing',change:null,changeDelay:0,control:'hue',defaultValue:'',hide:null,hideSpeed:100,inline:false,letterCase:'lowercase',opacity:false,position:'default',show:null,showSpeed:100,swatchPosition:'left',textfield:true,theme:'default'}};$.extend($.fn,{minicolors:function(method,data){switch(method){case'destroy':$(this).each(function(){destroy($(this));});return $(this);case'hide':hide();return $(this);case'opacity':if(data===undefined){return $(this).attr('data-opacity');}else{$(this).each(function(){refresh($(this).attr('data-opacity',data));});return $(this);}
|
||||
case'rgbObject':return rgbObject($(this),method==='rgbaObject');case'rgbString':case'rgbaString':return rgbString($(this),method==='rgbaString')
|
||||
case'settings':if(data===undefined){return $(this).data('minicolors-settings');}else{$(this).each(function(){var settings=$(this).data('minicolors-settings')||{};destroy($(this));$(this).minicolors($.extend(true,settings,data));});return $(this);}
|
||||
case'show':show($(this).eq(0));return $(this);case'value':if(data===undefined){return $(this).val();}else{$(this).each(function(){refresh($(this).val(data));});return $(this);}
|
||||
case'create':default:if(method!=='create')data=method;$(this).each(function(){init($(this),data);});return $(this);}}});function init(input,settings){var minicolors=$('<span class="minicolors" />'),defaultSettings=$.minicolors.defaultSettings;if(input.data('minicolors-initialized'))return;settings=$.extend(true,{},defaultSettings,settings);minicolors.addClass('minicolors-theme-'+settings.theme).addClass('minicolors-swatch-position-'+settings.swatchPosition).toggleClass('minicolors-swatch-left',settings.swatchPosition==='left').toggleClass('minicolors-with-opacity',settings.opacity);if(settings.position!==undefined){$.each(settings.position.split(' '),function(){minicolors.addClass('minicolors-position-'+this);});}
|
||||
input.addClass('minicolors-input').data('minicolors-initialized',true).data('minicolors-settings',settings).prop('size',7).prop('maxlength',7).wrap(minicolors).after('<span class="minicolors-panel minicolors-slider-'+settings.control+'">'+'<span class="minicolors-slider">'+'<span class="minicolors-picker"></span>'+'</span>'+'<span class="minicolors-opacity-slider">'+'<span class="minicolors-picker"></span>'+'</span>'+'<span class="minicolors-grid">'+'<span class="minicolors-grid-inner"></span>'+'<span class="minicolors-picker"><span></span></span>'+'</span>'+'</span>');input.parent().find('.minicolors-panel').on('selectstart',function(){return false;}).end();if(settings.swatchPosition==='left'){input.before('<span class="minicolors-swatch"><span></span></span>');}else{input.after('<span class="minicolors-swatch"><span></span></span>');}
|
||||
if(!settings.textfield)input.addClass('minicolors-hidden');if(settings.inline)input.parent().addClass('minicolors-inline');updateFromInput(input,false,true);}
|
||||
function destroy(input){var minicolors=input.parent();input.removeData('minicolors-initialized').removeData('minicolors-settings').removeProp('size').removeProp('maxlength').removeClass('minicolors-input');minicolors.before(input).remove();}
|
||||
function refresh(input){updateFromInput(input);}
|
||||
function show(input){var minicolors=input.parent(),panel=minicolors.find('.minicolors-panel'),settings=input.data('minicolors-settings');if(!input.data('minicolors-initialized')||input.prop('disabled')||minicolors.hasClass('minicolors-inline')||minicolors.hasClass('minicolors-focus'))return;hide();minicolors.addClass('minicolors-focus');panel.stop(true,true).fadeIn(settings.showSpeed,function(){if(settings.show)settings.show.call(input);});}
|
||||
function hide(){$('.minicolors-input').each(function(){var input=$(this),settings=input.data('minicolors-settings'),minicolors=input.parent();if(settings.inline)return;minicolors.find('.minicolors-panel').fadeOut(settings.hideSpeed,function(){if(minicolors.hasClass('minicolors-focus')){if(settings.hide)settings.hide.call(input);}
|
||||
minicolors.removeClass('minicolors-focus');});});}
|
||||
function move(target,event,animate){var input=target.parents('.minicolors').find('.minicolors-input'),settings=input.data('minicolors-settings'),picker=target.find('[class$=-picker]'),offsetX=target.offset().left,offsetY=target.offset().top,x=Math.round(event.pageX-offsetX),y=Math.round(event.pageY-offsetY),duration=animate?settings.animationSpeed:0,wx,wy,r,phi;if(event.originalEvent.changedTouches){x=event.originalEvent.changedTouches[0].pageX-offsetX;y=event.originalEvent.changedTouches[0].pageY-offsetY;}
|
||||
if(x<0)x=0;if(y<0)y=0;if(x>target.width())x=target.width();if(y>target.height())y=target.height();if(target.parent().is('.minicolors-slider-wheel')&&picker.parent().is('.minicolors-grid')){wx=75-x;wy=75-y;r=Math.sqrt(wx*wx+wy*wy);phi=Math.atan2(wy,wx);if(phi<0)phi+=Math.PI*2;if(r>75){r=75;x=75-(75*Math.cos(phi));y=75-(75*Math.sin(phi));}
|
||||
x=Math.round(x);y=Math.round(y);}
|
||||
if(target.is('.minicolors-grid')){picker.stop(true).animate({top:y+'px',left:x+'px'},duration,settings.animationEasing,function(){updateFromControl(input,target);});}else{picker.stop(true).animate({top:y+'px'},duration,settings.animationEasing,function(){updateFromControl(input,target);});}}
|
||||
function updateFromControl(input,target){function getCoords(picker,container){var left,top;if(!picker.length||!container)return null;left=picker.offset().left;top=picker.offset().top;return{x:left-container.offset().left+(picker.outerWidth()/2),y:top-container.offset().top+(picker.outerHeight()/2)};}
|
||||
var hue,saturation,brightness,rgb,x,y,r,phi,hex=input.val(),opacity=input.attr('data-opacity'),minicolors=input.parent(),settings=input.data('minicolors-settings'),panel=minicolors.find('.minicolors-panel'),swatch=minicolors.find('.minicolors-swatch'),grid=minicolors.find('.minicolors-grid'),slider=minicolors.find('.minicolors-slider'),opacitySlider=minicolors.find('.minicolors-opacity-slider'),gridPicker=grid.find('[class$=-picker]'),sliderPicker=slider.find('[class$=-picker]'),opacityPicker=opacitySlider.find('[class$=-picker]'),gridPos=getCoords(gridPicker,grid),sliderPos=getCoords(sliderPicker,slider),opacityPos=getCoords(opacityPicker,opacitySlider);if(target.is('.minicolors-grid, .minicolors-slider')){switch(settings.control){case'wheel':x=(grid.width()/2)-gridPos.x;y=(grid.height()/2)-gridPos.y;r=Math.sqrt(x*x+y*y);phi=Math.atan2(y,x);if(phi<0)phi+=Math.PI*2;if(r>75){r=75;gridPos.x=69-(75*Math.cos(phi));gridPos.y=69-(75*Math.sin(phi));}
|
||||
saturation=keepWithin(r/0.75,0,100);hue=keepWithin(phi*180/Math.PI,0,360);brightness=keepWithin(100-Math.floor(sliderPos.y*(100/slider.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});slider.css('backgroundColor',hsb2hex({h:hue,s:saturation,b:100}));break;case'saturation':hue=keepWithin(parseInt(gridPos.x*(360/grid.width())),0,360);saturation=keepWithin(100-Math.floor(sliderPos.y*(100/slider.height())),0,100);brightness=keepWithin(100-Math.floor(gridPos.y*(100/grid.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});slider.css('backgroundColor',hsb2hex({h:hue,s:100,b:brightness}));minicolors.find('.minicolors-grid-inner').css('opacity',saturation/100);break;case'brightness':hue=keepWithin(parseInt(gridPos.x*(360/grid.width())),0,360);saturation=keepWithin(100-Math.floor(gridPos.y*(100/grid.height())),0,100);brightness=keepWithin(100-Math.floor(sliderPos.y*(100/slider.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});slider.css('backgroundColor',hsb2hex({h:hue,s:saturation,b:100}));minicolors.find('.minicolors-grid-inner').css('opacity',1-(brightness/100));break;default:hue=keepWithin(360-parseInt(sliderPos.y*(360/slider.height())),0,360);saturation=keepWithin(Math.floor(gridPos.x*(100/grid.width())),0,100);brightness=keepWithin(100-Math.floor(gridPos.y*(100/grid.height())),0,100);hex=hsb2hex({h:hue,s:saturation,b:brightness});grid.css('backgroundColor',hsb2hex({h:hue,s:100,b:100}));break;}
|
||||
input.val(convertCase(hex,settings.letterCase));}
|
||||
if(target.is('.minicolors-opacity-slider')){if(settings.opacity){opacity=parseFloat(1-(opacityPos.y/opacitySlider.height())).toFixed(2);}else{opacity=1;}
|
||||
if(settings.opacity)input.attr('data-opacity',opacity);}
|
||||
swatch.find('SPAN').css({backgroundColor:hex,opacity:opacity});doChange(input,hex,opacity);}
|
||||
function updateFromInput(input,preserveInputValue,firstRun){var hex,hsb,opacity,x,y,r,phi,minicolors=input.parent(),settings=input.data('minicolors-settings'),swatch=minicolors.find('.minicolors-swatch'),grid=minicolors.find('.minicolors-grid'),slider=minicolors.find('.minicolors-slider'),opacitySlider=minicolors.find('.minicolors-opacity-slider'),gridPicker=grid.find('[class$=-picker]'),sliderPicker=slider.find('[class$=-picker]'),opacityPicker=opacitySlider.find('[class$=-picker]');hex=convertCase(parseHex(input.val(),true),settings.letterCase);if(!hex)hex=convertCase(parseHex(settings.defaultValue,true));hsb=hex2hsb(hex);if(!preserveInputValue)input.val(hex);if(settings.opacity){opacity=input.attr('data-opacity')===''?1:keepWithin(parseFloat(input.attr('data-opacity')).toFixed(2),0,1);if(isNaN(opacity))opacity=1;input.attr('data-opacity',opacity);swatch.find('SPAN').css('opacity',opacity);y=keepWithin(opacitySlider.height()-(opacitySlider.height()*opacity),0,opacitySlider.height());opacityPicker.css('top',y+'px');}
|
||||
swatch.find('SPAN').css('backgroundColor',hex);switch(settings.control){case'wheel':r=keepWithin(Math.ceil(hsb.s*0.75),0,grid.height()/2);phi=hsb.h*Math.PI/180;x=keepWithin(75-Math.cos(phi)*r,0,grid.width());y=keepWithin(75-Math.sin(phi)*r,0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=150-(hsb.b/(100/grid.height()));if(hex==='')y=0;sliderPicker.css('top',y+'px');slider.css('backgroundColor',hsb2hex({h:hsb.h,s:hsb.s,b:100}));break;case'saturation':x=keepWithin((5*hsb.h)/12,0,150);y=keepWithin(grid.height()-Math.ceil(hsb.b/(100/grid.height())),0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=keepWithin(slider.height()-(hsb.s*(slider.height()/100)),0,slider.height());sliderPicker.css('top',y+'px');slider.css('backgroundColor',hsb2hex({h:hsb.h,s:100,b:hsb.b}));minicolors.find('.minicolors-grid-inner').css('opacity',hsb.s/100);break;case'brightness':x=keepWithin((5*hsb.h)/12,0,150);y=keepWithin(grid.height()-Math.ceil(hsb.s/(100/grid.height())),0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=keepWithin(slider.height()-(hsb.b*(slider.height()/100)),0,slider.height());sliderPicker.css('top',y+'px');slider.css('backgroundColor',hsb2hex({h:hsb.h,s:hsb.s,b:100}));minicolors.find('.minicolors-grid-inner').css('opacity',1-(hsb.b/100));break;default:x=keepWithin(Math.ceil(hsb.s/(100/grid.width())),0,grid.width());y=keepWithin(grid.height()-Math.ceil(hsb.b/(100/grid.height())),0,grid.height());gridPicker.css({top:y+'px',left:x+'px'});y=keepWithin(slider.height()-(hsb.h/(360/slider.height())),0,slider.height());sliderPicker.css('top',y+'px');grid.css('backgroundColor',hsb2hex({h:hsb.h,s:100,b:100}));break;}
|
||||
if(!firstRun)doChange(input,hex,opacity);}
|
||||
function doChange(input,hex,opacity){var settings=input.data('minicolors-settings');if(hex+opacity!==input.data('minicolors-lastChange')){input.data('minicolors-lastChange',hex+opacity);if(settings.change){if(settings.changeDelay){clearTimeout(input.data('minicolors-changeTimeout'));input.data('minicolors-changeTimeout',setTimeout(function(){settings.change.call(input,hex,opacity);},settings.changeDelay));}else{settings.change.call(input,hex,opacity);}}}}
|
||||
function rgbObject(input){var hex=parseHex($(input).val(),true),rgb=hex2rgb(hex),opacity=$(input).attr('data-opacity');if(!rgb)return null;if(opacity!==undefined)$.extend(rgb,{a:parseFloat(opacity)});return rgb;}
|
||||
function rgbString(input,alpha){var hex=parseHex($(input).val(),true),rgb=hex2rgb(hex),opacity=$(input).attr('data-opacity');if(!rgb)return null;if(opacity===undefined)opacity=1;if(alpha){return'rgba('+rgb.r+', '+rgb.g+', '+rgb.b+', '+parseFloat(opacity)+')';}else{return'rgb('+rgb.r+', '+rgb.g+', '+rgb.b+')';}}
|
||||
function convertCase(string,letterCase){return letterCase==='uppercase'?string.toUpperCase():string.toLowerCase();}
|
||||
function parseHex(string,expand){string=string.replace(/[^A-F0-9]/ig,'');if(string.length!==3&&string.length!==6)return'';if(string.length===3&&expand){string=string[0]+string[0]+string[1]+string[1]+string[2]+string[2];}
|
||||
return'#'+string;}
|
||||
function keepWithin(value,min,max){if(value<min)value=min;if(value>max)value=max;return value;}
|
||||
function hsb2rgb(hsb){var rgb={};var h=Math.round(hsb.h);var s=Math.round(hsb.s*255/100);var v=Math.round(hsb.b*255/100);if(s===0){rgb.r=rgb.g=rgb.b=v;}else{var t1=v;var t2=(255-s)*v/255;var t3=(t1-t2)*(h%60)/60;if(h===360)h=0;if(h<60){rgb.r=t1;rgb.b=t2;rgb.g=t2+t3;}
|
||||
else if(h<120){rgb.g=t1;rgb.b=t2;rgb.r=t1-t3;}
|
||||
else if(h<180){rgb.g=t1;rgb.r=t2;rgb.b=t2+t3;}
|
||||
else if(h<240){rgb.b=t1;rgb.r=t2;rgb.g=t1-t3;}
|
||||
else if(h<300){rgb.b=t1;rgb.g=t2;rgb.r=t2+t3;}
|
||||
else if(h<360){rgb.r=t1;rgb.g=t2;rgb.b=t1-t3;}
|
||||
else{rgb.r=0;rgb.g=0;rgb.b=0;}}
|
||||
return{r:Math.round(rgb.r),g:Math.round(rgb.g),b:Math.round(rgb.b)};}
|
||||
function rgb2hex(rgb){var hex=[rgb.r.toString(16),rgb.g.toString(16),rgb.b.toString(16)];$.each(hex,function(nr,val){if(val.length===1)hex[nr]='0'+val;});return'#'+hex.join('');}
|
||||
function hsb2hex(hsb){return rgb2hex(hsb2rgb(hsb));}
|
||||
function hex2hsb(hex){var hsb=rgb2hsb(hex2rgb(hex));if(hsb.s===0)hsb.h=360;return hsb;}
|
||||
function rgb2hsb(rgb){var hsb={h:0,s:0,b:0};var min=Math.min(rgb.r,rgb.g,rgb.b);var max=Math.max(rgb.r,rgb.g,rgb.b);var delta=max-min;hsb.b=max;hsb.s=max!==0?255*delta/max:0;if(hsb.s!==0){if(rgb.r===max){hsb.h=(rgb.g-rgb.b)/delta;}else if(rgb.g===max){hsb.h=2+(rgb.b-rgb.r)/delta;}else{hsb.h=4+(rgb.r-rgb.g)/delta;}}else{hsb.h=-1;}
|
||||
hsb.h*=60;if(hsb.h<0){hsb.h+=360;}
|
||||
hsb.s*=100/255;hsb.b*=100/255;return hsb;}
|
||||
function hex2rgb(hex){hex=parseInt(((hex.indexOf('#')>-1)?hex.substring(1):hex),16);return{r:hex>>16,g:(hex&0x00FF00)>>8,b:(hex&0x0000FF)};}
|
||||
$(document).on('mousedown.minicolors touchstart.minicolors',function(event){if(!$(event.target).parents().add(event.target).hasClass('minicolors')){hide();}}).on('mousedown.minicolors touchstart.minicolors','.minicolors-grid, .minicolors-slider, .minicolors-opacity-slider',function(event){var target=$(this);event.preventDefault();$(document).data('minicolors-target',target);move(target,event,true);}).on('mousemove.minicolors touchmove.minicolors',function(event){var target=$(document).data('minicolors-target');if(target)move(target,event);}).on('mouseup.minicolors touchend.minicolors',function(){$(this).removeData('minicolors-target');}).on('mousedown.minicolors touchstart.minicolors','.minicolors-swatch',function(event){var input=$(this).parent().find('.minicolors-input'),minicolors=input.parent();if(minicolors.hasClass('minicolors-focus')){hide(input);}else{show(input);}}).on('focus.minicolors','.minicolors-input',function(event){var input=$(this);if(!input.data('minicolors-initialized'))return;show(input);}).on('blur.minicolors','.minicolors-input',function(event){var input=$(this),settings=input.data('minicolors-settings');if(!input.data('minicolors-initialized'))return;input.val(parseHex(input.val(),true));if(input.val()==='')input.val(parseHex(settings.defaultValue,true));input.val(convertCase(input.val(),settings.letterCase));}).on('keydown.minicolors','.minicolors-input',function(event){var input=$(this);if(!input.data('minicolors-initialized'))return;switch(event.keyCode){case 9:hide();break;case 27:hide();input.blur();break;}}).on('keyup.minicolors','.minicolors-input',function(event){var input=$(this);if(!input.data('minicolors-initialized'))return;updateFromInput(input,true);}).on('paste.minicolors','.minicolors-input',function(event){var input=$(this);if(!input.data('minicolors-initialized'))return;setTimeout(function(){updateFromInput(input,true);},1);});})(jQuery);
|
||||
@@ -0,0 +1,485 @@
|
||||
/*!
|
||||
* Nestable jQuery Plugin - Copyright (c) 2012 David Bushell - http://dbushell.com/
|
||||
* Dual-licensed under the BSD or MIT licenses
|
||||
*/
|
||||
;(function($, window, document, undefined)
|
||||
{
|
||||
var hasTouch = 'ontouchstart' in window;
|
||||
|
||||
/**
|
||||
* Detect CSS pointer-events property
|
||||
* events are normally disabled on the dragging element to avoid conflicts
|
||||
* https://github.com/ausi/Feature-detection-technique-for-pointer-events/blob/master/modernizr-pointerevents.js
|
||||
*/
|
||||
var hasPointerEvents = (function()
|
||||
{
|
||||
var el = document.createElement('div'),
|
||||
docEl = document.documentElement;
|
||||
if (!('pointerEvents' in el.style)) {
|
||||
return false;
|
||||
}
|
||||
el.style.pointerEvents = 'auto';
|
||||
el.style.pointerEvents = 'x';
|
||||
docEl.appendChild(el);
|
||||
var supports = window.getComputedStyle && window.getComputedStyle(el, '').pointerEvents === 'auto';
|
||||
docEl.removeChild(el);
|
||||
return !!supports;
|
||||
})();
|
||||
|
||||
var eStart = hasTouch ? 'touchstart' : 'mousedown',
|
||||
eMove = hasTouch ? 'touchmove' : 'mousemove',
|
||||
eEnd = hasTouch ? 'touchend' : 'mouseup';
|
||||
eCancel = hasTouch ? 'touchcancel' : 'mouseup';
|
||||
|
||||
var defaults = {
|
||||
listNodeName : 'ol',
|
||||
itemNodeName : 'li',
|
||||
rootClass : 'dd',
|
||||
listClass : 'dd-list',
|
||||
itemClass : 'dd-item',
|
||||
dragClass : 'dd-dragel',
|
||||
handleClass : 'dd-handle',
|
||||
collapsedClass : 'dd-collapsed',
|
||||
placeClass : 'dd-placeholder',
|
||||
noDragClass : 'dd-nodrag',
|
||||
emptyClass : 'dd-empty',
|
||||
expandBtnHTML : '<button data-action="expand" type="button">Expand</button>',
|
||||
collapseBtnHTML : '<button data-action="collapse" type="button">Collapse</button>',
|
||||
group : 0,
|
||||
maxDepth : 5,
|
||||
threshold : 20
|
||||
};
|
||||
|
||||
function Plugin(element, options)
|
||||
{
|
||||
this.w = $(window);
|
||||
this.el = $(element);
|
||||
this.options = $.extend({}, defaults, options);
|
||||
this.init();
|
||||
}
|
||||
|
||||
Plugin.prototype = {
|
||||
|
||||
init: function()
|
||||
{
|
||||
var list = this;
|
||||
|
||||
list.reset();
|
||||
|
||||
list.el.data('nestable-group', this.options.group);
|
||||
|
||||
list.placeEl = $('<div class="' + list.options.placeClass + '"/>');
|
||||
|
||||
$.each(this.el.find(list.options.itemNodeName), function(k, el) {
|
||||
list.setParent($(el));
|
||||
});
|
||||
|
||||
list.el.on('click', 'button', function(e) {
|
||||
if (list.dragEl || (!hasTouch && e.button !== 0)) {
|
||||
return;
|
||||
}
|
||||
var target = $(e.currentTarget),
|
||||
action = target.data('action'),
|
||||
item = target.parent(list.options.itemNodeName);
|
||||
if (action === 'collapse') {
|
||||
list.collapseItem(item);
|
||||
}
|
||||
if (action === 'expand') {
|
||||
list.expandItem(item);
|
||||
}
|
||||
});
|
||||
|
||||
var onStartEvent = function(e)
|
||||
{
|
||||
var handle = $(e.target);
|
||||
if (!handle.hasClass(list.options.handleClass)) {
|
||||
if (handle.closest('.' + list.options.noDragClass).length) {
|
||||
return;
|
||||
}
|
||||
handle = handle.closest('.' + list.options.handleClass);
|
||||
}
|
||||
if (!handle.length || list.dragEl || (!hasTouch && e.button !== 0) || (hasTouch && e.touches.length !== 1)) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
list.dragStart(hasTouch ? e.touches[0] : e);
|
||||
};
|
||||
|
||||
var onMoveEvent = function(e)
|
||||
{
|
||||
if (list.dragEl) {
|
||||
e.preventDefault();
|
||||
list.dragMove(hasTouch ? e.touches[0] : e);
|
||||
}
|
||||
};
|
||||
|
||||
var onEndEvent = function(e)
|
||||
{
|
||||
if (list.dragEl) {
|
||||
e.preventDefault();
|
||||
list.dragStop(hasTouch ? e.touches[0] : e);
|
||||
}
|
||||
};
|
||||
|
||||
if (hasTouch) {
|
||||
list.el[0].addEventListener(eStart, onStartEvent, false);
|
||||
window.addEventListener(eMove, onMoveEvent, false);
|
||||
window.addEventListener(eEnd, onEndEvent, false);
|
||||
window.addEventListener(eCancel, onEndEvent, false);
|
||||
} else {
|
||||
list.el.on(eStart, onStartEvent);
|
||||
list.w.on(eMove, onMoveEvent);
|
||||
list.w.on(eEnd, onEndEvent);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
serialize: function()
|
||||
{
|
||||
var data,
|
||||
depth = 0,
|
||||
list = this;
|
||||
step = function(level, depth)
|
||||
{
|
||||
var array = [ ],
|
||||
items = level.children(list.options.itemNodeName);
|
||||
items.each(function()
|
||||
{
|
||||
var li = $(this),
|
||||
item = $.extend({}, li.data()),
|
||||
sub = li.children(list.options.listNodeName);
|
||||
if (sub.length) {
|
||||
item.children = step(sub, depth + 1);
|
||||
}
|
||||
array.push(item);
|
||||
});
|
||||
return array;
|
||||
};
|
||||
data = step(list.el.find(list.options.listNodeName).first(), depth);
|
||||
return data;
|
||||
},
|
||||
|
||||
serialise: function()
|
||||
{
|
||||
return this.serialize();
|
||||
},
|
||||
|
||||
reset: function()
|
||||
{
|
||||
this.mouse = {
|
||||
offsetX : 0,
|
||||
offsetY : 0,
|
||||
startX : 0,
|
||||
startY : 0,
|
||||
lastX : 0,
|
||||
lastY : 0,
|
||||
nowX : 0,
|
||||
nowY : 0,
|
||||
distX : 0,
|
||||
distY : 0,
|
||||
dirAx : 0,
|
||||
dirX : 0,
|
||||
dirY : 0,
|
||||
lastDirX : 0,
|
||||
lastDirY : 0,
|
||||
distAxX : 0,
|
||||
distAxY : 0
|
||||
};
|
||||
this.moving = false;
|
||||
this.dragEl = null;
|
||||
this.dragRootEl = null;
|
||||
this.dragDepth = 0;
|
||||
this.hasNewRoot = false;
|
||||
this.pointEl = null;
|
||||
},
|
||||
|
||||
expandItem: function(li)
|
||||
{
|
||||
li.removeClass(this.options.collapsedClass);
|
||||
li.children('[data-action="expand"]').hide();
|
||||
li.children('[data-action="collapse"]').show();
|
||||
li.children(this.options.listNodeName).show();
|
||||
},
|
||||
|
||||
collapseItem: function(li)
|
||||
{
|
||||
var lists = li.children(this.options.listNodeName);
|
||||
if (lists.length) {
|
||||
li.addClass(this.options.collapsedClass);
|
||||
li.children('[data-action="collapse"]').hide();
|
||||
li.children('[data-action="expand"]').show();
|
||||
li.children(this.options.listNodeName).hide();
|
||||
}
|
||||
},
|
||||
|
||||
expandAll: function()
|
||||
{
|
||||
var list = this;
|
||||
list.el.find(list.options.itemNodeName).each(function() {
|
||||
list.expandItem($(this));
|
||||
});
|
||||
},
|
||||
|
||||
collapseAll: function()
|
||||
{
|
||||
var list = this;
|
||||
list.el.find(list.options.itemNodeName).each(function() {
|
||||
list.collapseItem($(this));
|
||||
});
|
||||
},
|
||||
|
||||
setParent: function(li)
|
||||
{
|
||||
if (li.children(this.options.listNodeName).length) {
|
||||
li.prepend($(this.options.expandBtnHTML));
|
||||
li.prepend($(this.options.collapseBtnHTML));
|
||||
}
|
||||
li.children('[data-action="expand"]').hide();
|
||||
},
|
||||
|
||||
unsetParent: function(li)
|
||||
{
|
||||
li.removeClass(this.options.collapsedClass);
|
||||
li.children('[data-action]').remove();
|
||||
li.children(this.options.listNodeName).remove();
|
||||
},
|
||||
|
||||
dragStart: function(e)
|
||||
{
|
||||
var mouse = this.mouse,
|
||||
target = $(e.target),
|
||||
dragItem = target.closest(this.options.itemNodeName);
|
||||
|
||||
this.placeEl.css('height', dragItem.height());
|
||||
|
||||
mouse.offsetX = e.offsetX !== undefined ? e.offsetX : e.pageX - target.offset().left;
|
||||
mouse.offsetY = e.offsetY !== undefined ? e.offsetY : e.pageY - target.offset().top;
|
||||
mouse.startX = mouse.lastX = e.pageX;
|
||||
mouse.startY = mouse.lastY = e.pageY;
|
||||
|
||||
this.dragRootEl = this.el;
|
||||
|
||||
this.dragEl = $(document.createElement(this.options.listNodeName)).addClass(this.options.listClass + ' ' + this.options.dragClass);
|
||||
this.dragEl.css('width', dragItem.width());
|
||||
|
||||
// fix for zepto.js
|
||||
//dragItem.after(this.placeEl).detach().appendTo(this.dragEl);
|
||||
dragItem.after(this.placeEl);
|
||||
dragItem[0].parentNode.removeChild(dragItem[0]);
|
||||
dragItem.appendTo(this.dragEl);
|
||||
|
||||
$(document.body).append(this.dragEl);
|
||||
this.dragEl.css({
|
||||
'left' : e.pageX - mouse.offsetX,
|
||||
'top' : e.pageY - mouse.offsetY
|
||||
});
|
||||
// total depth of dragging item
|
||||
var i, depth,
|
||||
items = this.dragEl.find(this.options.itemNodeName);
|
||||
for (i = 0; i < items.length; i++) {
|
||||
depth = $(items[i]).parents(this.options.listNodeName).length;
|
||||
if (depth > this.dragDepth) {
|
||||
this.dragDepth = depth;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
dragStop: function(e)
|
||||
{
|
||||
// fix for zepto.js
|
||||
//this.placeEl.replaceWith(this.dragEl.children(this.options.itemNodeName + ':first').detach());
|
||||
var el = this.dragEl.children(this.options.itemNodeName).first();
|
||||
el[0].parentNode.removeChild(el[0]);
|
||||
this.placeEl.replaceWith(el);
|
||||
|
||||
this.dragEl.remove();
|
||||
this.el.trigger('change',el);
|
||||
if (this.hasNewRoot) {
|
||||
this.dragRootEl.trigger('change',el);
|
||||
}
|
||||
this.reset();
|
||||
},
|
||||
|
||||
dragMove: function(e)
|
||||
{
|
||||
var list, parent, prev, next, depth,
|
||||
opt = this.options,
|
||||
mouse = this.mouse;
|
||||
|
||||
this.dragEl.css({
|
||||
'left' : e.pageX - mouse.offsetX,
|
||||
'top' : e.pageY - mouse.offsetY
|
||||
});
|
||||
|
||||
// mouse position last events
|
||||
mouse.lastX = mouse.nowX;
|
||||
mouse.lastY = mouse.nowY;
|
||||
// mouse position this events
|
||||
mouse.nowX = e.pageX;
|
||||
mouse.nowY = e.pageY;
|
||||
// distance mouse moved between events
|
||||
mouse.distX = mouse.nowX - mouse.lastX;
|
||||
mouse.distY = mouse.nowY - mouse.lastY;
|
||||
// direction mouse was moving
|
||||
mouse.lastDirX = mouse.dirX;
|
||||
mouse.lastDirY = mouse.dirY;
|
||||
// direction mouse is now moving (on both axis)
|
||||
mouse.dirX = mouse.distX === 0 ? 0 : mouse.distX > 0 ? 1 : -1;
|
||||
mouse.dirY = mouse.distY === 0 ? 0 : mouse.distY > 0 ? 1 : -1;
|
||||
// axis mouse is now moving on
|
||||
var newAx = Math.abs(mouse.distX) > Math.abs(mouse.distY) ? 1 : 0;
|
||||
|
||||
// do nothing on first move
|
||||
if (!mouse.moving) {
|
||||
mouse.dirAx = newAx;
|
||||
mouse.moving = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// calc distance moved on this axis (and direction)
|
||||
if (mouse.dirAx !== newAx) {
|
||||
mouse.distAxX = 0;
|
||||
mouse.distAxY = 0;
|
||||
} else {
|
||||
mouse.distAxX += Math.abs(mouse.distX);
|
||||
if (mouse.dirX !== 0 && mouse.dirX !== mouse.lastDirX) {
|
||||
mouse.distAxX = 0;
|
||||
}
|
||||
mouse.distAxY += Math.abs(mouse.distY);
|
||||
if (mouse.dirY !== 0 && mouse.dirY !== mouse.lastDirY) {
|
||||
mouse.distAxY = 0;
|
||||
}
|
||||
}
|
||||
mouse.dirAx = newAx;
|
||||
|
||||
/**
|
||||
* move horizontal
|
||||
*/
|
||||
if (mouse.dirAx && mouse.distAxX >= opt.threshold) {
|
||||
// reset move distance on x-axis for new phase
|
||||
mouse.distAxX = 0;
|
||||
prev = this.placeEl.prev(opt.itemNodeName);
|
||||
// increase horizontal level if previous sibling exists and is not collapsed
|
||||
if (mouse.distX > 0 && prev.length && !prev.hasClass(opt.collapsedClass)) {
|
||||
// cannot increase level when item above is collapsed
|
||||
list = prev.find(opt.listNodeName).last();
|
||||
// check if depth limit has reached
|
||||
depth = this.placeEl.parents(opt.listNodeName).length;
|
||||
if (depth + this.dragDepth <= opt.maxDepth) {
|
||||
// create new sub-level if one doesn't exist
|
||||
if (!list.length) {
|
||||
list = $('<' + opt.listNodeName + '/>').addClass(opt.listClass);
|
||||
list.append(this.placeEl);
|
||||
prev.append(list);
|
||||
this.setParent(prev);
|
||||
} else {
|
||||
// else append to next level up
|
||||
list = prev.children(opt.listNodeName).last();
|
||||
list.append(this.placeEl);
|
||||
}
|
||||
}
|
||||
}
|
||||
// decrease horizontal level
|
||||
if (mouse.distX < 0) {
|
||||
// we can't decrease a level if an item preceeds the current one
|
||||
next = this.placeEl.next(opt.itemNodeName);
|
||||
if (!next.length) {
|
||||
parent = this.placeEl.parent();
|
||||
this.placeEl.closest(opt.itemNodeName).after(this.placeEl);
|
||||
if (!parent.children().length) {
|
||||
this.unsetParent(parent.parent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var isEmpty = false;
|
||||
|
||||
// find list item under cursor
|
||||
if (!hasPointerEvents) {
|
||||
this.dragEl[0].style.visibility = 'hidden';
|
||||
}
|
||||
this.pointEl = $(document.elementFromPoint(e.pageX - document.body.scrollLeft, e.pageY - (window.pageYOffset || document.documentElement.scrollTop)));
|
||||
if (!hasPointerEvents) {
|
||||
this.dragEl[0].style.visibility = 'visible';
|
||||
}
|
||||
if (this.pointEl.hasClass(opt.handleClass)) {
|
||||
this.pointEl = this.pointEl.parent(opt.itemNodeName);
|
||||
}
|
||||
if (this.pointEl.hasClass(opt.emptyClass)) {
|
||||
isEmpty = true;
|
||||
}
|
||||
else if (!this.pointEl.length || !this.pointEl.hasClass(opt.itemClass)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// find parent list of item under cursor
|
||||
var pointElRoot = this.pointEl.closest('.' + opt.rootClass),
|
||||
isNewRoot = this.dragRootEl.data('nestable-id') !== pointElRoot.data('nestable-id');
|
||||
|
||||
/**
|
||||
* move vertical
|
||||
*/
|
||||
if (!mouse.dirAx || isNewRoot || isEmpty) {
|
||||
// check if groups match if dragging over new root
|
||||
if (isNewRoot && opt.group !== pointElRoot.data('nestable-group')) {
|
||||
return;
|
||||
}
|
||||
// check depth limit
|
||||
depth = this.dragDepth - 1 + this.pointEl.parents(opt.listNodeName).length;
|
||||
if (depth > opt.maxDepth) {
|
||||
return;
|
||||
}
|
||||
var before = e.pageY < (this.pointEl.offset().top + this.pointEl.height() / 2);
|
||||
parent = this.placeEl.parent();
|
||||
// if empty create new list to replace empty placeholder
|
||||
if (isEmpty) {
|
||||
list = $(document.createElement(opt.listNodeName)).addClass(opt.listClass);
|
||||
list.append(this.placeEl);
|
||||
this.pointEl.replaceWith(list);
|
||||
}
|
||||
else if (before) {
|
||||
this.pointEl.before(this.placeEl);
|
||||
}
|
||||
else {
|
||||
this.pointEl.after(this.placeEl);
|
||||
}
|
||||
if (!parent.children().length) {
|
||||
this.unsetParent(parent.parent());
|
||||
}
|
||||
if (!this.dragRootEl.find(opt.itemNodeName).length) {
|
||||
this.dragRootEl.append('<div class="' + opt.emptyClass + '"/>');
|
||||
}
|
||||
// parent root list has changed
|
||||
if (isNewRoot) {
|
||||
this.dragRootEl = pointElRoot;
|
||||
this.hasNewRoot = this.el[0] !== this.dragRootEl[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$.fn.nestable = function(params)
|
||||
{
|
||||
var lists = this,
|
||||
retval = this;
|
||||
|
||||
lists.each(function()
|
||||
{
|
||||
var plugin = $(this).data("nestable");
|
||||
|
||||
if (!plugin) {
|
||||
$(this).data("nestable", new Plugin(this, params));
|
||||
$(this).data("nestable-id", new Date().getTime());
|
||||
} else {
|
||||
if (typeof params === 'string' && typeof plugin[params] === 'function') {
|
||||
retval = plugin[params]();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return retval || lists;
|
||||
};
|
||||
|
||||
})(window.jQuery || window.Zepto, window, document);
|
||||
@@ -0,0 +1,18 @@
|
||||
//From http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
|
||||
;(function($) {
|
||||
$.fn.selectText = function(){
|
||||
var doc = document , element = this[0] , range, selection ;
|
||||
if (doc.body.createTextRange) {
|
||||
range = document.body.createTextRange();
|
||||
range.moveToElementText(element);
|
||||
range.select();
|
||||
} else if (window.getSelection) {
|
||||
selection = window.getSelection();
|
||||
range = document.createRange();
|
||||
range.selectNodeContents(element);
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
}
|
||||
element.focus();
|
||||
};
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,2 @@
|
||||
//From http://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse
|
||||
(function(d){d.fn.selectText=function(){var b=this[0],a,c;document.body.createTextRange?(a=document.body.createTextRange(),a.moveToElementText(b),a.select()):window.getSelection&&(c=window.getSelection(),a=document.createRange(),a.selectNodeContents(b),c.removeAllRanges(),c.addRange(a));b.focus()}})(jQuery);
|
||||
@@ -0,0 +1,6 @@
|
||||
/*
|
||||
* jQuery UI Touch Punch 0.2.2
|
||||
* Copyright 2011, Dave Furfero
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*/
|
||||
(function(b){b.support.touch="ontouchend" in document;if(!b.support.touch){return;}var c=b.ui.mouse.prototype,e=c._mouseInit,a;function d(g,h){if(g.originalEvent.touches.length>1){return;}g.preventDefault();var i=g.originalEvent.changedTouches[0],f=document.createEvent("MouseEvents");f.initMouseEvent(h,true,true,window,1,i.screenX,i.screenY,i.clientX,i.clientY,false,false,false,false,0,null);g.target.dispatchEvent(f);}c._touchStart=function(g){var f=this;if(a||!f._mouseCapture(g.originalEvent.changedTouches[0])){return;}a=true;f._touchMoved=false;d(g,"mouseover");d(g,"mousemove");d(g,"mousedown");};c._touchMove=function(f){if(!a){return;}this._touchMoved=true;d(f,"mousemove");};c._touchEnd=function(f){if(!a){return;}d(f,"mouseup");d(f,"mouseout");if(!this._touchMoved){d(f,"click");}a=false;};c._mouseInit=function(){var f=this;f.element.bind("touchstart",b.proxy(f,"_touchStart")).bind("touchmove",b.proxy(f,"_touchMove")).bind("touchend",b.proxy(f,"_touchEnd"));e.call(f);};})(jQuery);
|
||||
@@ -0,0 +1,27 @@
|
||||
function wptm_frameload() {
|
||||
jQuery("#wptm_loader").hide();
|
||||
jQuery("#wptmmodalframe").css('visibility',"visible");
|
||||
jQuery("#wptmmodalframe").show();
|
||||
}
|
||||
jQuery(document).ready(function($){
|
||||
$('.wptmlaunch').wptm_leanModal({ top : 20, beforeShow: function(){ $("#wptmmodal").css("height","90%"); $("#wptmmodalframe").css('visibility','hidden'); $("#wptmmodalframe").attr('src', $("#wptmmodalframe").attr('src')); $("#wptm_loader").show(); } });
|
||||
$('body').append('<div id="wptmmodal"><img src="images/spinner-2x.gif" width="32" id="wptm_loader" /> <iframe id="wptmmodalframe" onload="wptm_frameload()" width="100%" height="100%" marginWidth="0" marginHeight="0" frameBorder="0" scrolling="auto" src="admin.php?page=wptm&noheader=1&caninsert=1" /><button id="wptm-close-modal" onclick="jQuery(\'#lean_overlay\',window.parent.document).fadeOut(300);jQuery(\'#wptmmodal\',window.parent.document).fadeOut(300);" style="position: absolute; right: -23px;">x</button></div>');
|
||||
|
||||
$('body').on("click", ".wptmlaunch", function (e) {
|
||||
$("#wptmmodal").css("height", "90%");
|
||||
$("#wptmmodalframe").css('visibility', 'hidden');
|
||||
$("#wptmmodalframe").attr('src', $("#wptmmodalframe").attr('src'));
|
||||
$("#wptm_loader").show();
|
||||
|
||||
var modal_id = $(this).attr("href");
|
||||
//var modal_height=$(modal_id).outerHeight();
|
||||
var modal_width = $(modal_id).outerWidth();
|
||||
$("#lean_overlay").css({"display": "block", opacity: 0});
|
||||
$("#lean_overlay").fadeTo(200, 0.5);
|
||||
$(modal_id).css({"visibility": "visible", "display": "block", "text-align": "center", "position": "fixed", "opacity": 0, "z-index": 100102, "left": 50 + "%", "margin-left": -(modal_width / 2) + "px", "top": "20px"});
|
||||
$(modal_id).fadeTo(200, 1);
|
||||
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
tinymce.PluginManager.add("code",function(e){function o(){e.windowManager.open({title:"Source code",body:{type:"textbox",name:"code",multiline:!0,minWidth:e.getParam("code_dialog_width",600),minHeight:e.getParam("code_dialog_height",Math.min(tinymce.DOM.getViewPort().h-200,500)),value:e.getContent({source_view:!0}),spellcheck:!1,style:"direction: ltr; text-align: left"},onSubmit:function(o){e.focus(),e.undoManager.transact(function(){e.setContent(o.data.code)}),e.selection.setCursorLocation(),e.nodeChanged()}})}e.addCommand("mceCodeEditor",o),e.addButton("code",{icon:"code",tooltip:"Source code",onclick:o}),e.addMenuItem("code",{icon:"code",text:"Source code",context:"tools",onclick:o})});
|
||||
@@ -0,0 +1,953 @@
|
||||
/* global tinymce */
|
||||
tinymce.PluginManager.add( 'wpedittable', function( editor ) {
|
||||
var toolbar, serializer,
|
||||
each = tinymce.each,
|
||||
trim = tinymce.trim,
|
||||
iOS = tinymce.Env.iOS;
|
||||
|
||||
function isPlaceholder( node ) {
|
||||
return !! ( editor.dom.getAttrib( node, 'data-mce-placeholder' ) || editor.dom.getAttrib( node, 'data-mce-object' ) );
|
||||
}
|
||||
|
||||
editor.addButton( 'wp_img_remove', {
|
||||
tooltip: 'Remove',
|
||||
icon: 'dashicon dashicons-no',
|
||||
onclick: function() {
|
||||
removeImage( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
|
||||
editor.addButton( 'wp_img_edit', {
|
||||
tooltip: 'Edit table', // trailing space is needed, used for context
|
||||
icon: 'dashicon dashicons-edit',
|
||||
onclick: function() {
|
||||
editImage( editor.selection.getNode() );
|
||||
}
|
||||
} );
|
||||
|
||||
each( {
|
||||
alignleft: 'Align left',
|
||||
aligncenter: 'Align center',
|
||||
alignright: 'Align right',
|
||||
alignnone: 'No alignment'
|
||||
}, function( tooltip, name ) {
|
||||
var direction = name.slice( 5 );
|
||||
|
||||
editor.addButton( 'wp_img_' + name, {
|
||||
tooltip: tooltip,
|
||||
icon: 'dashicon dashicons-align-' + direction,
|
||||
cmd: 'alignnone' === name ? 'wpAlignNone' : 'Justify' + direction.slice( 0, 1 ).toUpperCase() + direction.slice( 1 ),
|
||||
onPostRender: function() {
|
||||
var self = this;
|
||||
|
||||
editor.on( 'NodeChange', function( event ) {
|
||||
var node;
|
||||
|
||||
// Don't bother.
|
||||
if ( event.element.nodeName !== 'IMG' ) {
|
||||
return;
|
||||
}
|
||||
|
||||
node = editor.dom.getParent( event.element, '.wp-caption' ) || event.element;
|
||||
|
||||
if ( 'alignnone' === name ) {
|
||||
self.active( ! /\balign(left|center|right)\b/.test( node.className ) );
|
||||
} else {
|
||||
self.active( editor.dom.hasClass( node, name ) );
|
||||
}
|
||||
} );
|
||||
}
|
||||
} );
|
||||
} );
|
||||
|
||||
editor.once( 'preinit', function() {
|
||||
toolbar = editor.wp._createToolbar( [
|
||||
'wp_img_alignleft',
|
||||
'wp_img_aligncenter',
|
||||
'wp_img_alignright',
|
||||
'wp_img_alignnone',
|
||||
'wp_img_edit',
|
||||
'wp_img_remove'
|
||||
] );
|
||||
} );
|
||||
|
||||
editor.on( 'wptoolbar', function( event ) {
|
||||
if ( event.element.nodeName === 'IMG' && ! isPlaceholder( event.element ) ) {
|
||||
event.toolbar = toolbar;
|
||||
}
|
||||
} );
|
||||
|
||||
// Safari on iOS fails to select image nodes in contentEditoble mode on touch/click.
|
||||
// Select them again.
|
||||
if ( iOS ) {
|
||||
editor.on( 'click', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' ) {
|
||||
var node = event.target;
|
||||
|
||||
window.setTimeout( function() {
|
||||
editor.selection.select( node );
|
||||
editor.nodeChanged();
|
||||
}, 200 );
|
||||
} else {
|
||||
toolbar.hide();
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
function parseShortcode( content ) {
|
||||
return content.replace( /(?:<p>)?\[(?:wp_)?caption([^\]]+)\]([\s\S]+?)\[\/(?:wp_)?caption\](?:<\/p>)?/g, function( a, b, c ) {
|
||||
var id, align, classes, caption, img, width;
|
||||
|
||||
id = b.match( /id=['"]([^'"]*)['"] ?/ );
|
||||
if ( id ) {
|
||||
b = b.replace( id[0], '' );
|
||||
}
|
||||
|
||||
align = b.match( /align=['"]([^'"]*)['"] ?/ );
|
||||
if ( align ) {
|
||||
b = b.replace( align[0], '' );
|
||||
}
|
||||
|
||||
classes = b.match( /class=['"]([^'"]*)['"] ?/ );
|
||||
if ( classes ) {
|
||||
b = b.replace( classes[0], '' );
|
||||
}
|
||||
|
||||
width = b.match( /width=['"]([0-9]*)['"] ?/ );
|
||||
if ( width ) {
|
||||
b = b.replace( width[0], '' );
|
||||
}
|
||||
|
||||
c = trim( c );
|
||||
img = c.match( /((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)([\s\S]*)/i );
|
||||
|
||||
if ( img && img[2] ) {
|
||||
caption = trim( img[2] );
|
||||
img = trim( img[1] );
|
||||
} else {
|
||||
// old captions shortcode style
|
||||
caption = trim( b ).replace( /caption=['"]/, '' ).replace( /['"]$/, '' );
|
||||
img = c;
|
||||
}
|
||||
|
||||
id = ( id && id[1] ) ? id[1].replace( /[<>&]+/g, '' ) : '';
|
||||
align = ( align && align[1] ) ? align[1] : 'alignnone';
|
||||
classes = ( classes && classes[1] ) ? ' ' + classes[1].replace( /[<>&]+/g, '' ) : '';
|
||||
|
||||
if ( ! width && img ) {
|
||||
width = img.match( /width=['"]([0-9]*)['"]/ );
|
||||
}
|
||||
|
||||
if ( width && width[1] ) {
|
||||
width = width[1];
|
||||
}
|
||||
|
||||
if ( ! width || ! caption ) {
|
||||
return c;
|
||||
}
|
||||
|
||||
width = parseInt( width, 10 );
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width += 10;
|
||||
}
|
||||
|
||||
return '<div class="mceTemp"><dl id="' + id + '" class="wp-caption ' + align + classes + '" style="width: ' + width + 'px">' +
|
||||
'<dt class="wp-caption-dt">'+ img +'</dt><dd class="wp-caption-dd">'+ caption +'</dd></dl></div>';
|
||||
});
|
||||
}
|
||||
|
||||
function getShortcode( content ) {
|
||||
return content.replace( /<div (?:id="attachment_|class="mceTemp)[^>]*>([\s\S]+?)<\/div>/g, function( a, b ) {
|
||||
var out = '';
|
||||
|
||||
if ( b.indexOf('<img ') === -1 ) {
|
||||
// Broken caption. The user managed to drag the image out?
|
||||
// Try to return the caption text as a paragraph.
|
||||
out = b.match( /<dd [^>]+>([\s\S]+?)<\/dd>/i );
|
||||
|
||||
if ( out && out[1] ) {
|
||||
return '<p>' + out[1] + '</p>';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
out = b.replace( /\s*<dl ([^>]+)>\s*<dt [^>]+>([\s\S]+?)<\/dt>\s*<dd [^>]+>([\s\S]*?)<\/dd>\s*<\/dl>\s*/gi, function( a, b, c, caption ) {
|
||||
var id, classes, align, width;
|
||||
|
||||
width = c.match( /width="([0-9]*)"/ );
|
||||
width = ( width && width[1] ) ? width[1] : '';
|
||||
|
||||
classes = b.match( /class="([^"]*)"/ );
|
||||
classes = ( classes && classes[1] ) ? classes[1] : '';
|
||||
align = classes.match( /align[a-z]+/i ) || 'alignnone';
|
||||
|
||||
if ( ! width || ! caption ) {
|
||||
if ( 'alignnone' !== align[0] ) {
|
||||
c = c.replace( /><img/, ' class="' + align[0] + '"><img' );
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
id = b.match( /id="([^"]*)"/ );
|
||||
id = ( id && id[1] ) ? id[1] : '';
|
||||
|
||||
classes = classes.replace( /wp-caption ?|align[a-z]+ ?/gi, '' );
|
||||
|
||||
if ( classes ) {
|
||||
classes = ' class="' + classes + '"';
|
||||
}
|
||||
|
||||
caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
|
||||
// no line breaks inside HTML tags
|
||||
return a.replace( /[\r\n\t]+/, ' ' );
|
||||
});
|
||||
|
||||
// convert remaining line breaks to <br>
|
||||
caption = caption.replace( /\s*\n\s*/g, '<br />' );
|
||||
|
||||
return '[caption id="' + id + '" align="' + align + '" width="' + width + '"' + classes + ']' + c + ' ' + caption + '[/caption]';
|
||||
});
|
||||
|
||||
if ( out.indexOf('[caption') === -1 ) {
|
||||
// the caption html seems broken, try to find the image that may be wrapped in a link
|
||||
// and may be followed by <p> with the caption text.
|
||||
out = b.replace( /[\s\S]*?((?:<a [^>]+>)?<img [^>]+>(?:<\/a>)?)(<p>[\s\S]*<\/p>)?[\s\S]*/gi, '<p>$1</p>$2' );
|
||||
}
|
||||
|
||||
return out;
|
||||
});
|
||||
}
|
||||
|
||||
function extractImageData( imageNode ) {
|
||||
var classes, extraClasses, metadata, captionBlock, caption, link, width, height,
|
||||
captionClassName = [],
|
||||
dom = editor.dom,
|
||||
isIntRegExp = /^\d+$/;
|
||||
|
||||
// default attributes
|
||||
metadata = {
|
||||
attachment_id: false,
|
||||
size: 'custom',
|
||||
caption: '',
|
||||
align: 'none',
|
||||
extraClasses: '',
|
||||
link: false,
|
||||
linkUrl: '',
|
||||
linkClassName: '',
|
||||
linkTargetBlank: false,
|
||||
linkRel: '',
|
||||
title: ''
|
||||
};
|
||||
|
||||
metadata.url = dom.getAttrib( imageNode, 'src' );
|
||||
metadata.alt = dom.getAttrib( imageNode, 'alt' );
|
||||
metadata.title = dom.getAttrib( imageNode, 'title' );
|
||||
|
||||
width = dom.getAttrib( imageNode, 'width' );
|
||||
height = dom.getAttrib( imageNode, 'height' );
|
||||
|
||||
if ( ! isIntRegExp.test( width ) || parseInt( width, 10 ) < 1 ) {
|
||||
width = imageNode.naturalWidth || imageNode.width;
|
||||
}
|
||||
|
||||
if ( ! isIntRegExp.test( height ) || parseInt( height, 10 ) < 1 ) {
|
||||
height = imageNode.naturalHeight || imageNode.height;
|
||||
}
|
||||
|
||||
metadata.customWidth = metadata.width = width;
|
||||
metadata.customHeight = metadata.height = height;
|
||||
|
||||
classes = tinymce.explode( imageNode.className, ' ' );
|
||||
extraClasses = [];
|
||||
|
||||
tinymce.each( classes, function( name ) {
|
||||
|
||||
if ( /^wp-image/.test( name ) ) {
|
||||
metadata.attachment_id = parseInt( name.replace( 'wp-image-', '' ), 10 );
|
||||
} else if ( /^align/.test( name ) ) {
|
||||
metadata.align = name.replace( 'align', '' );
|
||||
} else if ( /^size/.test( name ) ) {
|
||||
metadata.size = name.replace( 'size-', '' );
|
||||
} else {
|
||||
extraClasses.push( name );
|
||||
}
|
||||
|
||||
} );
|
||||
|
||||
metadata.extraClasses = extraClasses.join( ' ' );
|
||||
|
||||
// Extract caption
|
||||
captionBlock = dom.getParents( imageNode, '.wp-caption' );
|
||||
|
||||
if ( captionBlock.length ) {
|
||||
captionBlock = captionBlock[0];
|
||||
|
||||
classes = captionBlock.className.split( ' ' );
|
||||
tinymce.each( classes, function( name ) {
|
||||
if ( /^align/.test( name ) ) {
|
||||
metadata.align = name.replace( 'align', '' );
|
||||
} else if ( name && name !== 'wp-caption' ) {
|
||||
captionClassName.push( name );
|
||||
}
|
||||
} );
|
||||
|
||||
metadata.captionClassName = captionClassName.join( ' ' );
|
||||
|
||||
caption = dom.select( 'dd.wp-caption-dd', captionBlock );
|
||||
if ( caption.length ) {
|
||||
caption = caption[0];
|
||||
|
||||
metadata.caption = editor.serializer.serialize( caption )
|
||||
.replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' );
|
||||
}
|
||||
}
|
||||
|
||||
// Extract linkTo
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' ) {
|
||||
link = imageNode.parentNode;
|
||||
metadata.linkUrl = dom.getAttrib( link, 'href' );
|
||||
metadata.linkTargetBlank = dom.getAttrib( link, 'target' ) === '_blank' ? true : false;
|
||||
metadata.linkRel = dom.getAttrib( link, 'rel' );
|
||||
metadata.linkClassName = link.className;
|
||||
}
|
||||
|
||||
return metadata;
|
||||
}
|
||||
|
||||
function hasTextContent( node ) {
|
||||
return node && !! ( node.textContent || node.innerText );
|
||||
}
|
||||
|
||||
// Verify HTML in captions
|
||||
function verifyHTML( caption ) {
|
||||
if ( ! caption || ( caption.indexOf( '<' ) === -1 && caption.indexOf( '>' ) === -1 ) ) {
|
||||
return caption;
|
||||
}
|
||||
|
||||
if ( ! serializer ) {
|
||||
serializer = new tinymce.html.Serializer( {}, editor.schema );
|
||||
}
|
||||
|
||||
return serializer.serialize( editor.parser.parse( caption, { forced_root_block: false } ) );
|
||||
}
|
||||
|
||||
function updateImage( imageNode, imageData ) {
|
||||
var classes, className, node, html, parent, wrap, linkNode,
|
||||
captionNode, dd, dl, id, attrs, linkAttrs, width, height, align,
|
||||
dom = editor.dom;
|
||||
|
||||
classes = tinymce.explode( imageData.extraClasses, ' ' );
|
||||
|
||||
if ( ! classes ) {
|
||||
classes = [];
|
||||
}
|
||||
|
||||
if ( ! imageData.caption ) {
|
||||
classes.push( 'align' + imageData.align );
|
||||
}
|
||||
|
||||
if ( imageData.attachment_id ) {
|
||||
classes.push( 'wp-image-' + imageData.attachment_id );
|
||||
if ( imageData.size && imageData.size !== 'custom' ) {
|
||||
classes.push( 'size-' + imageData.size );
|
||||
}
|
||||
}
|
||||
|
||||
width = imageData.width;
|
||||
height = imageData.height;
|
||||
|
||||
if ( imageData.size === 'custom' ) {
|
||||
width = imageData.customWidth;
|
||||
height = imageData.customHeight;
|
||||
}
|
||||
|
||||
attrs = {
|
||||
src: imageData.url,
|
||||
width: width || null,
|
||||
height: height || null,
|
||||
alt: imageData.alt,
|
||||
title: imageData.title || null,
|
||||
'class': classes.join( ' ' ) || null
|
||||
};
|
||||
|
||||
dom.setAttribs( imageNode, attrs );
|
||||
|
||||
linkAttrs = {
|
||||
href: imageData.linkUrl,
|
||||
rel: imageData.linkRel || null,
|
||||
target: imageData.linkTargetBlank ? '_blank': null,
|
||||
'class': imageData.linkClassName || null
|
||||
};
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
// Update or remove an existing link wrapped around the image
|
||||
if ( imageData.linkUrl ) {
|
||||
dom.setAttribs( imageNode.parentNode, linkAttrs );
|
||||
} else {
|
||||
dom.remove( imageNode.parentNode, true );
|
||||
}
|
||||
} else if ( imageData.linkUrl ) {
|
||||
if ( linkNode = dom.getParent( imageNode, 'a' ) ) {
|
||||
// The image is inside a link together with other nodes,
|
||||
// or is nested in another node, move it out
|
||||
dom.insertAfter( imageNode, linkNode );
|
||||
}
|
||||
|
||||
// Add link wrapped around the image
|
||||
linkNode = dom.create( 'a', linkAttrs );
|
||||
imageNode.parentNode.insertBefore( linkNode, imageNode );
|
||||
linkNode.appendChild( imageNode );
|
||||
}
|
||||
|
||||
captionNode = editor.dom.getParent( imageNode, '.mceTemp' );
|
||||
|
||||
if ( imageNode.parentNode && imageNode.parentNode.nodeName === 'A' && ! hasTextContent( imageNode.parentNode ) ) {
|
||||
node = imageNode.parentNode;
|
||||
} else {
|
||||
node = imageNode;
|
||||
}
|
||||
|
||||
if ( imageData.caption ) {
|
||||
imageData.caption = verifyHTML( imageData.caption );
|
||||
|
||||
id = imageData.attachment_id ? 'attachment_' + imageData.attachment_id : null;
|
||||
align = 'align' + ( imageData.align || 'none' );
|
||||
className = 'wp-caption ' + align;
|
||||
|
||||
if ( imageData.captionClassName ) {
|
||||
className += ' ' + imageData.captionClassName.replace( /[<>&]+/g, '' );
|
||||
}
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width = parseInt( width, 10 );
|
||||
width += 10;
|
||||
}
|
||||
|
||||
if ( captionNode ) {
|
||||
dl = dom.select( 'dl.wp-caption', captionNode );
|
||||
|
||||
if ( dl.length ) {
|
||||
dom.setAttribs( dl, {
|
||||
id: id,
|
||||
'class': className,
|
||||
style: 'width: ' + width + 'px'
|
||||
} );
|
||||
}
|
||||
|
||||
dd = dom.select( '.wp-caption-dd', captionNode );
|
||||
|
||||
if ( dd.length ) {
|
||||
dom.setHTML( dd[0], imageData.caption );
|
||||
}
|
||||
|
||||
} else {
|
||||
id = id ? 'id="'+ id +'" ' : '';
|
||||
|
||||
// should create a new function for generating the caption markup
|
||||
html = '<dl ' + id + 'class="' + className +'" style="width: '+ width +'px">' +
|
||||
'<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ imageData.caption +'</dd></dl>';
|
||||
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
|
||||
if ( parent = dom.getParent( node, 'p' ) ) {
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
} else {
|
||||
node.parentNode.insertBefore( wrap, node );
|
||||
}
|
||||
|
||||
editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node );
|
||||
|
||||
if ( parent && dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
}
|
||||
} else if ( captionNode ) {
|
||||
// Remove the caption wrapper and place the image in new paragraph
|
||||
parent = dom.create( 'p' );
|
||||
captionNode.parentNode.insertBefore( parent, captionNode );
|
||||
parent.appendChild( node );
|
||||
dom.remove( captionNode );
|
||||
}
|
||||
|
||||
if ( wp.media.events ) {
|
||||
wp.media.events.trigger( 'editor:image-update', {
|
||||
editor: editor,
|
||||
metadata: imageData,
|
||||
image: imageNode
|
||||
} );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
|
||||
function editImage( img ) {
|
||||
var frame, callback, metadata;
|
||||
|
||||
if ( typeof wp === 'undefined' || ! wp.media ) {
|
||||
editor.execCommand( 'mceImage' );
|
||||
return;
|
||||
}
|
||||
|
||||
dom = editor.dom,
|
||||
wptm_table = dom.getAttrib( img, 'data-wptmtable' );
|
||||
if (wptm_table !== null && wptm_table != '') {
|
||||
var wptm_btn = document.getElementById('wptmlaunch');
|
||||
wptm_btn.click();
|
||||
return true;
|
||||
}
|
||||
|
||||
metadata = extractImageData( img );
|
||||
|
||||
// Manipulate the metadata by reference that is fed into the PostImage model used in the media modal
|
||||
wp.media.events.trigger( 'editor:image-edit', {
|
||||
editor: editor,
|
||||
metadata: metadata,
|
||||
image: img
|
||||
} );
|
||||
|
||||
frame = wp.media({
|
||||
frame: 'image',
|
||||
state: 'image-details',
|
||||
metadata: metadata
|
||||
} );
|
||||
|
||||
wp.media.events.trigger( 'editor:frame-create', { frame: frame } );
|
||||
|
||||
callback = function( imageData ) {
|
||||
editor.focus();
|
||||
editor.undoManager.transact( function() {
|
||||
updateImage( img, imageData );
|
||||
} );
|
||||
frame.detach();
|
||||
};
|
||||
|
||||
frame.state('image-details').on( 'update', callback );
|
||||
frame.state('replace-image').on( 'replace', callback );
|
||||
frame.on( 'close', function() {
|
||||
editor.focus();
|
||||
frame.detach();
|
||||
});
|
||||
|
||||
frame.open();
|
||||
}
|
||||
|
||||
function removeImage( node ) {
|
||||
var wrap = editor.dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( ! wrap && node.nodeName === 'IMG' ) {
|
||||
wrap = editor.dom.getParent( node, 'a' );
|
||||
}
|
||||
|
||||
if ( wrap ) {
|
||||
if ( wrap.nextSibling ) {
|
||||
editor.selection.select( wrap.nextSibling );
|
||||
} else if ( wrap.previousSibling ) {
|
||||
editor.selection.select( wrap.previousSibling );
|
||||
} else {
|
||||
editor.selection.select( wrap.parentNode );
|
||||
}
|
||||
|
||||
editor.selection.collapse( true );
|
||||
editor.dom.remove( wrap );
|
||||
} else {
|
||||
editor.dom.remove( node );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
editor.undoManager.add();
|
||||
}
|
||||
|
||||
editor.on( 'init', function() {
|
||||
var dom = editor.dom,
|
||||
captionClass = editor.getParam( 'wpeditimage_html5_captions' ) ? 'html5-captions' : 'html4-captions';
|
||||
|
||||
dom.addClass( editor.getBody(), captionClass );
|
||||
|
||||
// Add caption field to the default image dialog
|
||||
editor.on( 'wpLoadImageForm', function( event ) {
|
||||
if ( editor.getParam( 'wpeditimage_disable_captions' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
var captionField = {
|
||||
type: 'textbox',
|
||||
flex: 1,
|
||||
name: 'caption',
|
||||
minHeight: 60,
|
||||
multiline: true,
|
||||
scroll: true,
|
||||
label: 'Image caption'
|
||||
};
|
||||
|
||||
event.data.splice( event.data.length - 1, 0, captionField );
|
||||
});
|
||||
|
||||
// Fix caption parent width for images added from URL
|
||||
editor.on( 'wpNewImageRefresh', function( event ) {
|
||||
var parent, captionWidth;
|
||||
|
||||
if ( parent = dom.getParent( event.node, 'dl.wp-caption' ) ) {
|
||||
if ( ! parent.style.width ) {
|
||||
captionWidth = parseInt( event.node.clientWidth, 10 ) + 10;
|
||||
captionWidth = captionWidth ? captionWidth + 'px' : '50%';
|
||||
dom.setStyle( parent, 'width', captionWidth );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'wpImageFormSubmit', function( event ) {
|
||||
var data = event.imgData.data,
|
||||
imgNode = event.imgData.node,
|
||||
caption = event.imgData.caption,
|
||||
captionId = '',
|
||||
captionAlign = '',
|
||||
captionWidth = '',
|
||||
wrap, parent, node, html, imgId;
|
||||
|
||||
// Temp image id so we can find the node later
|
||||
data.id = '__wp-temp-img-id';
|
||||
// Cancel the original callback
|
||||
event.imgData.cancel = true;
|
||||
|
||||
if ( ! data.style ) {
|
||||
data.style = null;
|
||||
}
|
||||
|
||||
if ( ! data.src ) {
|
||||
// Delete the image and the caption
|
||||
if ( imgNode ) {
|
||||
if ( wrap = dom.getParent( imgNode, 'div.mceTemp' ) ) {
|
||||
dom.remove( wrap );
|
||||
} else if ( imgNode.parentNode.nodeName === 'A' ) {
|
||||
dom.remove( imgNode.parentNode );
|
||||
} else {
|
||||
dom.remove( imgNode );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ( caption ) {
|
||||
caption = caption.replace( /\r\n|\r/g, '\n' ).replace( /<\/?[a-zA-Z0-9]+( [^<>]+)?>/g, function( a ) {
|
||||
// No line breaks inside HTML tags
|
||||
return a.replace( /[\r\n\t]+/, ' ' );
|
||||
});
|
||||
|
||||
// Convert remaining line breaks to <br>
|
||||
caption = caption.replace( /(<br[^>]*>)\s*\n\s*/g, '$1' ).replace( /\s*\n\s*/g, '<br />' );
|
||||
caption = verifyHTML( caption );
|
||||
}
|
||||
|
||||
if ( ! imgNode ) {
|
||||
// New image inserted
|
||||
html = dom.createHTML( 'img', data );
|
||||
|
||||
if ( caption ) {
|
||||
node = editor.selection.getNode();
|
||||
|
||||
if ( data.width ) {
|
||||
captionWidth = parseInt( data.width, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
captionWidth += 10;
|
||||
}
|
||||
|
||||
captionWidth = ' style="width: ' + captionWidth + 'px"';
|
||||
}
|
||||
|
||||
html = '<dl class="wp-caption alignnone"' + captionWidth + '>' +
|
||||
'<dt class="wp-caption-dt">'+ html +'</dt><dd class="wp-caption-dd">'+ caption +'</dd></dl>';
|
||||
|
||||
if ( node.nodeName === 'P' ) {
|
||||
parent = node;
|
||||
} else {
|
||||
parent = dom.getParent( node, 'p' );
|
||||
}
|
||||
|
||||
if ( parent && parent.nodeName === 'P' ) {
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
editor.selection.select( wrap );
|
||||
editor.nodeChanged();
|
||||
|
||||
if ( dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
} else {
|
||||
editor.selection.setContent( '<div class="mceTemp">' + html + '</div>' );
|
||||
}
|
||||
} else {
|
||||
editor.selection.setContent( html );
|
||||
}
|
||||
} else {
|
||||
// Edit existing image
|
||||
|
||||
// Store the original image id if any
|
||||
imgId = imgNode.id || null;
|
||||
// Update the image node
|
||||
dom.setAttribs( imgNode, data );
|
||||
wrap = dom.getParent( imgNode, 'dl.wp-caption' );
|
||||
|
||||
if ( caption ) {
|
||||
if ( wrap ) {
|
||||
if ( parent = dom.select( 'dd.wp-caption-dd', wrap )[0] ) {
|
||||
parent.innerHTML = caption;
|
||||
}
|
||||
} else {
|
||||
if ( imgNode.className ) {
|
||||
captionId = imgNode.className.match( /wp-image-([0-9]+)/ );
|
||||
captionAlign = imgNode.className.match( /align(left|right|center|none)/ );
|
||||
}
|
||||
|
||||
if ( captionAlign ) {
|
||||
captionAlign = captionAlign[0];
|
||||
imgNode.className = imgNode.className.replace( /align(left|right|center|none)/g, '' );
|
||||
} else {
|
||||
captionAlign = 'alignnone';
|
||||
}
|
||||
|
||||
captionAlign = ' class="wp-caption ' + captionAlign + '"';
|
||||
|
||||
if ( captionId ) {
|
||||
captionId = ' id="attachment_' + captionId[1] + '"';
|
||||
}
|
||||
|
||||
captionWidth = data.width || imgNode.clientWidth;
|
||||
|
||||
if ( captionWidth ) {
|
||||
captionWidth = parseInt( captionWidth, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
captionWidth += 10;
|
||||
}
|
||||
|
||||
captionWidth = ' style="width: '+ captionWidth +'px"';
|
||||
}
|
||||
|
||||
if ( imgNode.parentNode && imgNode.parentNode.nodeName === 'A' ) {
|
||||
node = imgNode.parentNode;
|
||||
} else {
|
||||
node = imgNode;
|
||||
}
|
||||
|
||||
html = '<dl ' + captionId + captionAlign + captionWidth + '>' +
|
||||
'<dt class="wp-caption-dt"></dt><dd class="wp-caption-dd">'+ caption +'</dd></dl>';
|
||||
|
||||
wrap = dom.create( 'div', { 'class': 'mceTemp' }, html );
|
||||
|
||||
if ( parent = dom.getParent( node, 'p' ) ) {
|
||||
parent.parentNode.insertBefore( wrap, parent );
|
||||
} else {
|
||||
node.parentNode.insertBefore( wrap, node );
|
||||
}
|
||||
|
||||
editor.$( wrap ).find( 'dt.wp-caption-dt' ).append( node );
|
||||
|
||||
if ( parent && dom.isEmpty( parent ) ) {
|
||||
dom.remove( parent );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( wrap ) {
|
||||
// Remove the caption wrapper and place the image in new paragraph
|
||||
if ( imgNode.parentNode.nodeName === 'A' ) {
|
||||
html = dom.getOuterHTML( imgNode.parentNode );
|
||||
} else {
|
||||
html = dom.getOuterHTML( imgNode );
|
||||
}
|
||||
|
||||
parent = dom.create( 'p', {}, html );
|
||||
dom.insertAfter( parent, wrap.parentNode );
|
||||
editor.selection.select( parent );
|
||||
editor.nodeChanged();
|
||||
dom.remove( wrap.parentNode );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
imgNode = dom.get('__wp-temp-img-id');
|
||||
dom.setAttrib( imgNode, 'id', imgId );
|
||||
event.imgData.node = imgNode;
|
||||
});
|
||||
|
||||
editor.on( 'wpLoadImageData', function( event ) {
|
||||
var parent,
|
||||
data = event.imgData.data,
|
||||
imgNode = event.imgData.node;
|
||||
|
||||
if ( parent = dom.getParent( imgNode, 'dl.wp-caption' ) ) {
|
||||
parent = dom.select( 'dd.wp-caption-dd', parent )[0];
|
||||
|
||||
if ( parent ) {
|
||||
data.caption = editor.serializer.serialize( parent )
|
||||
.replace( /<br[^>]*>/g, '$&\n' ).replace( /^<p>/, '' ).replace( /<\/p>$/, '' );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dom.bind( editor.getDoc(), 'dragstart', function( event ) {
|
||||
var node = editor.selection.getNode();
|
||||
|
||||
// Prevent dragging images out of the caption elements
|
||||
if ( node.nodeName === 'IMG' && dom.getParent( node, '.wp-caption' ) ) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// Prevent IE11 from making dl.wp-caption resizable
|
||||
if ( tinymce.Env.ie && tinymce.Env.ie > 10 ) {
|
||||
// The 'mscontrolselect' event is supported only in IE11+
|
||||
dom.bind( editor.getBody(), 'mscontrolselect', function( event ) {
|
||||
if ( event.target.nodeName === 'IMG' && dom.getParent( event.target, '.wp-caption' ) ) {
|
||||
// Hide the thick border with resize handles around dl.wp-caption
|
||||
editor.getBody().focus(); // :(
|
||||
} else if ( event.target.nodeName === 'DL' && dom.hasClass( event.target, 'wp-caption' ) ) {
|
||||
// Trigger the thick border with resize handles...
|
||||
// This will make the caption text editable.
|
||||
event.target.focus();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'ObjectResized', function( event ) {
|
||||
var node = event.target;
|
||||
|
||||
if ( node.nodeName === 'IMG' ) {
|
||||
editor.undoManager.transact( function() {
|
||||
var parent, width,
|
||||
dom = editor.dom;
|
||||
|
||||
node.className = node.className.replace( /\bsize-[^ ]+/, '' );
|
||||
|
||||
if ( parent = dom.getParent( node, '.wp-caption' ) ) {
|
||||
width = event.width || dom.getAttrib( node, 'width' );
|
||||
|
||||
if ( width ) {
|
||||
width = parseInt( width, 10 );
|
||||
|
||||
if ( ! editor.getParam( 'wpeditimage_html5_captions' ) ) {
|
||||
width += 10;
|
||||
}
|
||||
|
||||
dom.setStyle( parent, 'width', width + 'px' );
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'BeforeExecCommand', function( event ) {
|
||||
var node, p, DL, align, replacement,
|
||||
cmd = event.command,
|
||||
dom = editor.dom;
|
||||
|
||||
if ( cmd === 'mceInsertContent' ) {
|
||||
// When inserting content, if the caret is inside a caption create new paragraph under
|
||||
// and move the caret there
|
||||
if ( node = dom.getParent( editor.selection.getNode(), 'div.mceTemp' ) ) {
|
||||
p = dom.create( 'p' );
|
||||
dom.insertAfter( p, node );
|
||||
editor.selection.setCursorLocation( p, 0 );
|
||||
editor.nodeChanged();
|
||||
}
|
||||
} else if ( cmd === 'JustifyLeft' || cmd === 'JustifyRight' || cmd === 'JustifyCenter' || cmd === 'wpAlignNone' ) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'keydown', function( event ) {
|
||||
var node, wrap, P, spacer,
|
||||
selection = editor.selection,
|
||||
keyCode = event.keyCode,
|
||||
dom = editor.dom,
|
||||
VK = tinymce.util.VK;
|
||||
|
||||
if ( keyCode === VK.ENTER ) {
|
||||
// When pressing Enter inside a caption move the caret to a new parapraph under it
|
||||
node = selection.getNode();
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
|
||||
if ( wrap ) {
|
||||
dom.events.cancel( event ); // Doesn't cancel all :(
|
||||
|
||||
// Remove any extra dt and dd cleated on pressing Enter...
|
||||
tinymce.each( dom.select( 'dt, dd', wrap ), function( element ) {
|
||||
if ( dom.isEmpty( element ) ) {
|
||||
dom.remove( element );
|
||||
}
|
||||
});
|
||||
|
||||
spacer = tinymce.Env.ie && tinymce.Env.ie < 11 ? '' : '<br data-mce-bogus="1" />';
|
||||
P = dom.create( 'p', null, spacer );
|
||||
|
||||
if ( node.nodeName === 'DD' ) {
|
||||
dom.insertAfter( P, wrap );
|
||||
} else {
|
||||
wrap.parentNode.insertBefore( P, wrap );
|
||||
}
|
||||
|
||||
editor.nodeChanged();
|
||||
selection.setCursorLocation( P, 0 );
|
||||
}
|
||||
} else if ( keyCode === VK.DELETE || keyCode === VK.BACKSPACE ) {
|
||||
node = selection.getNode();
|
||||
|
||||
if ( node.nodeName === 'DIV' && dom.hasClass( node, 'mceTemp' ) ) {
|
||||
wrap = node;
|
||||
} else if ( node.nodeName === 'IMG' || node.nodeName === 'DT' || node.nodeName === 'A' ) {
|
||||
wrap = dom.getParent( node, 'div.mceTemp' );
|
||||
}
|
||||
|
||||
if ( wrap ) {
|
||||
dom.events.cancel( event );
|
||||
removeImage( node );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// After undo/redo FF seems to set the image height very slowly when it is set to 'auto' in the CSS.
|
||||
// This causes image.getBoundingClientRect() to return wrong values and the resize handles are shown in wrong places.
|
||||
// Collapse the selection to remove the resize handles.
|
||||
if ( tinymce.Env.gecko ) {
|
||||
editor.on( 'undo redo', function() {
|
||||
if ( editor.selection.getNode().nodeName === 'IMG' ) {
|
||||
editor.selection.collapse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
editor.wpSetImgCaption = function( content ) {
|
||||
return parseShortcode( content );
|
||||
};
|
||||
|
||||
editor.wpGetImgCaption = function( content ) {
|
||||
return getShortcode( content );
|
||||
};
|
||||
|
||||
editor.on( 'BeforeSetContent', function( event ) {
|
||||
if ( event.format !== 'raw' ) {
|
||||
event.content = editor.wpSetImgCaption( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
editor.on( 'PostProcess', function( event ) {
|
||||
if ( event.get ) {
|
||||
event.content = editor.wpGetImgCaption( event.content );
|
||||
}
|
||||
});
|
||||
|
||||
// Add to editor.wp
|
||||
editor.wp = editor.wp || {};
|
||||
editor.wp.isPlaceholder = isPlaceholder;
|
||||
|
||||
// Back-compat.
|
||||
return {
|
||||
_do_shcode: parseShortcode,
|
||||
_get_shcode: getShortcode
|
||||
};
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
tinymce.PluginManager.add('wpmedia', function(editor, url) {
|
||||
// Add a button that opens a window
|
||||
editor.addButton('wpmedia', {
|
||||
title: 'WP Image',
|
||||
icon: 'wp-media-library',
|
||||
onclick: function() {
|
||||
if ( wp && wp.media && wp.media.editor ) {
|
||||
wp.media.editor.open( editor.id );
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
@@ -0,0 +1,811 @@
|
||||
<?php
|
||||
/**
|
||||
* CSSTidy - CSS Parser and Optimiser
|
||||
*
|
||||
* CSS Optimising Class
|
||||
* This class optimises CSS data generated by csstidy.
|
||||
*
|
||||
* This file is part of CSSTidy.
|
||||
*
|
||||
* CSSTidy is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CSSTidy is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CSSTidy; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @package csstidy
|
||||
* @author Florian Schmitz (floele at gmail dot com) 2005-2006
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
/**
|
||||
* CSS Optimising Class
|
||||
*
|
||||
* This class optimises CSS data generated by csstidy.
|
||||
*
|
||||
* @package csstidy
|
||||
* @author Florian Schmitz (floele at gmail dot com) 2005-2006
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class csstidy_optimise
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
* @param array $css contains the class csstidy
|
||||
* @access private
|
||||
* @version 1.0
|
||||
*/
|
||||
function __construct(&$css)
|
||||
{
|
||||
$this->parser =& $css;
|
||||
$this->css =& $css->css;
|
||||
$this->sub_value =& $css->sub_value;
|
||||
$this->at =& $css->at;
|
||||
$this->selector =& $css->selector;
|
||||
$this->property =& $css->property;
|
||||
$this->value =& $css->value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimises $css after parsing
|
||||
* @access public
|
||||
* @version 1.0
|
||||
*/
|
||||
function postparse()
|
||||
{
|
||||
if ($this->parser->get_cfg('preserve_css')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->parser->get_cfg('merge_selectors') == 2)
|
||||
{
|
||||
foreach ($this->css as $medium => $value)
|
||||
{
|
||||
$this->merge_selectors($this->css[$medium]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->parser->get_cfg('optimise_shorthands') > 0)
|
||||
{
|
||||
foreach ($this->css as $medium => $value)
|
||||
{
|
||||
foreach ($value as $selector => $value1)
|
||||
{
|
||||
$this->css[$medium][$selector] = csstidy_optimise::merge_4value_shorthands($this->css[$medium][$selector]);
|
||||
|
||||
if ($this->parser->get_cfg('optimise_shorthands') < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->css[$medium][$selector] = csstidy_optimise::merge_bg($this->css[$medium][$selector]);
|
||||
if (empty($this->css[$medium][$selector])) {
|
||||
unset($this->css[$medium][$selector]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimises values
|
||||
* @access public
|
||||
* @version 1.0
|
||||
*/
|
||||
function value()
|
||||
{
|
||||
$shorthands =& $GLOBALS['csstidy']['shorthands'];
|
||||
|
||||
// optimise shorthand properties
|
||||
if(isset($shorthands[$this->property]))
|
||||
{
|
||||
$temp = csstidy_optimise::shorthand($this->value); // FIXME - move
|
||||
if($temp != $this->value)
|
||||
{
|
||||
$this->parser->log('Optimised shorthand notation ('.$this->property.'): Changed "'.$this->value.'" to "'.$temp.'"','Information');
|
||||
}
|
||||
$this->value = $temp;
|
||||
}
|
||||
|
||||
// Remove whitespace at ! important
|
||||
if($this->value != $this->compress_important($this->value))
|
||||
{
|
||||
$this->parser->log('Optimised !important','Information');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimises shorthands
|
||||
* @access public
|
||||
* @version 1.0
|
||||
*/
|
||||
function shorthands()
|
||||
{
|
||||
$shorthands =& $GLOBALS['csstidy']['shorthands'];
|
||||
|
||||
if(!$this->parser->get_cfg('optimise_shorthands') || $this->parser->get_cfg('preserve_css')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($this->property == 'background' && $this->parser->get_cfg('optimise_shorthands') > 1)
|
||||
{
|
||||
unset($this->css[$this->at][$this->selector]['background']);
|
||||
$this->parser->merge_css_blocks($this->at,$this->selector,csstidy_optimise::dissolve_short_bg($this->value));
|
||||
}
|
||||
if(isset($shorthands[$this->property]))
|
||||
{
|
||||
$this->parser->merge_css_blocks($this->at,$this->selector,csstidy_optimise::dissolve_4value_shorthands($this->property,$this->value));
|
||||
if(is_array($shorthands[$this->property]))
|
||||
{
|
||||
unset($this->css[$this->at][$this->selector][$this->property]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Optimises a sub-value
|
||||
* @access public
|
||||
* @version 1.0
|
||||
*/
|
||||
function subvalue()
|
||||
{
|
||||
$replace_colors =& $GLOBALS['csstidy']['replace_colors'];
|
||||
|
||||
$this->sub_value = trim($this->sub_value);
|
||||
if($this->sub_value == '') // caution : '0'
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$important = '';
|
||||
if(csstidy::is_important($this->sub_value))
|
||||
{
|
||||
$important = '!important';
|
||||
}
|
||||
$this->sub_value = csstidy::gvw_important($this->sub_value);
|
||||
|
||||
// Compress font-weight
|
||||
if($this->property == 'font-weight' && $this->parser->get_cfg('compress_font-weight'))
|
||||
{
|
||||
if($this->sub_value == 'bold')
|
||||
{
|
||||
$this->sub_value = '700';
|
||||
$this->parser->log('Optimised font-weight: Changed "bold" to "700"','Information');
|
||||
}
|
||||
else if($this->sub_value == 'normal')
|
||||
{
|
||||
$this->sub_value = '400';
|
||||
$this->parser->log('Optimised font-weight: Changed "normal" to "400"','Information');
|
||||
}
|
||||
}
|
||||
|
||||
$temp = $this->compress_numbers($this->sub_value);
|
||||
if($temp != $this->sub_value)
|
||||
{
|
||||
if(strlen($temp) > strlen($this->sub_value)) {
|
||||
$this->parser->log('Fixed invalid number: Changed "'.$this->sub_value.'" to "'.$temp.'"','Warning');
|
||||
} else {
|
||||
$this->parser->log('Optimised number: Changed "'.$this->sub_value.'" to "'.$temp.'"','Information');
|
||||
}
|
||||
$this->sub_value = $temp;
|
||||
}
|
||||
if($this->parser->get_cfg('compress_colors'))
|
||||
{
|
||||
$temp = $this->cut_color($this->sub_value);
|
||||
if($temp !== $this->sub_value)
|
||||
{
|
||||
if(isset($replace_colors[$this->sub_value])) {
|
||||
$this->parser->log('Fixed invalid color name: Changed "'.$this->sub_value.'" to "'.$temp.'"','Warning');
|
||||
} else {
|
||||
$this->parser->log('Optimised color: Changed "'.$this->sub_value.'" to "'.$temp.'"','Information');
|
||||
}
|
||||
$this->sub_value = $temp;
|
||||
}
|
||||
}
|
||||
$this->sub_value .= $important;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compresses shorthand values. Example: margin:1px 1px 1px 1px -> margin:1px
|
||||
* @param string $value
|
||||
* @access public
|
||||
* @return string
|
||||
* @version 1.0
|
||||
*/
|
||||
function shorthand($value)
|
||||
{
|
||||
$important = '';
|
||||
if(csstidy::is_important($value))
|
||||
{
|
||||
$values = csstidy::gvw_important($value);
|
||||
$important = '!important';
|
||||
}
|
||||
else $values = $value;
|
||||
|
||||
$values = explode(' ',$values);
|
||||
switch(count($values))
|
||||
{
|
||||
case 4:
|
||||
if($values[0] == $values[1] && $values[0] == $values[2] && $values[0] == $values[3])
|
||||
{
|
||||
return $values[0].$important;
|
||||
}
|
||||
elseif($values[1] == $values[3] && $values[0] == $values[2])
|
||||
{
|
||||
return $values[0].' '.$values[1].$important;
|
||||
}
|
||||
elseif($values[1] == $values[3])
|
||||
{
|
||||
return $values[0].' '.$values[1].' '.$values[2].$important;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if($values[0] == $values[1] && $values[0] == $values[2])
|
||||
{
|
||||
return $values[0].$important;
|
||||
}
|
||||
elseif($values[0] == $values[2])
|
||||
{
|
||||
return $values[0].' '.$values[1].$important;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if($values[0] == $values[1])
|
||||
{
|
||||
return $values[0].$important;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes unnecessary whitespace in ! important
|
||||
* @param string $string
|
||||
* @return string
|
||||
* @access public
|
||||
* @version 1.1
|
||||
*/
|
||||
function compress_important(&$string)
|
||||
{
|
||||
if(csstidy::is_important($string))
|
||||
{
|
||||
$string = csstidy::gvw_important($string) . '!important';
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Color compression function. Converts all rgb() values to #-values and uses the short-form if possible. Also replaces 4 color names by #-values.
|
||||
* @param string $color
|
||||
* @return string
|
||||
* @version 1.1
|
||||
*/
|
||||
function cut_color($color)
|
||||
{
|
||||
$replace_colors =& $GLOBALS['csstidy']['replace_colors'];
|
||||
|
||||
// rgb(0,0,0) -> #000000 (or #000 in this case later)
|
||||
if(strtolower(substr($color,0,4)) == 'rgb(')
|
||||
{
|
||||
$color_tmp = substr($color,4,strlen($color)-5);
|
||||
$color_tmp = explode(',',$color_tmp);
|
||||
for ( $i = 0; $i < count($color_tmp); $i++ )
|
||||
{
|
||||
$color_tmp[$i] = trim ($color_tmp[$i]);
|
||||
if(substr($color_tmp[$i],-1) == '%')
|
||||
{
|
||||
$color_tmp[$i] = round((255*$color_tmp[$i])/100);
|
||||
}
|
||||
if($color_tmp[$i]>255) $color_tmp[$i] = 255;
|
||||
}
|
||||
$color = '#';
|
||||
for ($i = 0; $i < 3; $i++ )
|
||||
{
|
||||
if($color_tmp[$i]<16) {
|
||||
$color .= '0' . dechex($color_tmp[$i]);
|
||||
} else {
|
||||
$color .= dechex($color_tmp[$i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Fix bad color names
|
||||
if(isset($replace_colors[strtolower($color)]))
|
||||
{
|
||||
$color = $replace_colors[strtolower($color)];
|
||||
}
|
||||
|
||||
// #aabbcc -> #abc
|
||||
if(strlen($color) == 7)
|
||||
{
|
||||
$color_temp = strtolower($color);
|
||||
if($color_temp{0} == '#' && $color_temp{1} == $color_temp{2} && $color_temp{3} == $color_temp{4} && $color_temp{5} == $color_temp{6})
|
||||
{
|
||||
$color = '#'.$color{1}.$color{3}.$color{5};
|
||||
}
|
||||
}
|
||||
|
||||
switch(strtolower($color))
|
||||
{
|
||||
/* color name -> hex code */
|
||||
case 'black': return '#000';
|
||||
case 'fuchsia': return '#F0F';
|
||||
case 'white': return '#FFF';
|
||||
case 'yellow': return '#FF0';
|
||||
|
||||
/* hex code -> color name */
|
||||
case '#800000': return 'maroon';
|
||||
case '#ffa500': return 'orange';
|
||||
case '#808000': return 'olive';
|
||||
case '#800080': return 'purple';
|
||||
case '#008000': return 'green';
|
||||
case '#000080': return 'navy';
|
||||
case '#008080': return 'teal';
|
||||
case '#c0c0c0': return 'silver';
|
||||
case '#808080': return 'gray';
|
||||
case '#f00': return 'red';
|
||||
}
|
||||
|
||||
return $color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compresses numbers (ie. 1.0 becomes 1 or 1.100 becomes 1.1 )
|
||||
* @param string $subvalue
|
||||
* @return string
|
||||
* @version 1.2
|
||||
*/
|
||||
function compress_numbers($subvalue)
|
||||
{
|
||||
$units =& $GLOBALS['csstidy']['units'];
|
||||
$unit_values =& $GLOBALS['csstidy']['unit_values'];
|
||||
$color_values =& $GLOBALS['csstidy']['color_values'];
|
||||
|
||||
// for font:1em/1em sans-serif...;
|
||||
if($this->property == 'font')
|
||||
{
|
||||
$temp = explode('/',$subvalue);
|
||||
}
|
||||
else
|
||||
{
|
||||
$temp = array($subvalue);
|
||||
}
|
||||
for ($l = 0; $l < count($temp); $l++)
|
||||
{
|
||||
// continue if no numeric value
|
||||
if (!(strlen($temp[$l]) > 0 && ( is_numeric($temp[$l]{0}) || $temp[$l]{0} == '+' || $temp[$l]{0} == '-' ) ))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Fix bad colors
|
||||
if (in_array($this->property, $color_values))
|
||||
{
|
||||
$temp[$l] = '#'.$temp[$l];
|
||||
}
|
||||
|
||||
if (floatval($temp[$l]) == 0)
|
||||
{
|
||||
$temp[$l] = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
$unit_found = FALSE;
|
||||
for ($m = 0, $size_4 = count($units); $m < $size_4; $m++)
|
||||
{
|
||||
if (strpos(strtolower($temp[$l]),$units[$m]) !== FALSE)
|
||||
{
|
||||
$temp[$l] = floatval($temp[$l]).$units[$m];
|
||||
$unit_found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!$unit_found && in_array($this->property,$unit_values,TRUE))
|
||||
{
|
||||
$temp[$l] = floatval($temp[$l]).'px';
|
||||
}
|
||||
else if (!$unit_found)
|
||||
{
|
||||
$temp[$l] = floatval($temp[$l]);
|
||||
}
|
||||
// Remove leading zero
|
||||
if (abs(floatval($temp[$l])) < 1) {
|
||||
if (floatval($temp[$l]) < 0) {
|
||||
$temp[$l] = '-' . substr($temp[$l], 2);
|
||||
} else {
|
||||
$temp[$l] = substr($temp[$l], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ((count($temp) > 1) ? $temp[0].'/'.$temp[1] : $temp[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges selectors with same properties. Example: a{color:red} b{color:red} -> a,b{color:red}
|
||||
* Very basic and has at least one bug. Hopefully there is a replacement soon.
|
||||
* @param array $array
|
||||
* @return array
|
||||
* @access public
|
||||
* @version 1.2
|
||||
*/
|
||||
function merge_selectors(&$array)
|
||||
{
|
||||
$css = $array;
|
||||
foreach($css as $key => $value)
|
||||
{
|
||||
if(!isset($css[$key]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$newsel = '';
|
||||
|
||||
// Check if properties also exist in another selector
|
||||
$keys = array();
|
||||
// PHP bug (?) without $css = $array; here
|
||||
foreach($css as $selector => $vali)
|
||||
{
|
||||
if($selector == $key)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if($css[$key] === $vali)
|
||||
{
|
||||
$keys[] = $selector;
|
||||
}
|
||||
}
|
||||
|
||||
if(!empty($keys))
|
||||
{
|
||||
$newsel = $key;
|
||||
unset($css[$key]);
|
||||
foreach($keys as $selector)
|
||||
{
|
||||
unset($css[$selector]);
|
||||
$newsel .= ','.$selector;
|
||||
}
|
||||
$css[$newsel] = $value;
|
||||
}
|
||||
}
|
||||
$array = $css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dissolves properties like padding:10px 10px 10px to padding-top:10px;padding-bottom:10px;...
|
||||
* @param string $property
|
||||
* @param string $value
|
||||
* @return array
|
||||
* @version 1.0
|
||||
* @see merge_4value_shorthands()
|
||||
*/
|
||||
function dissolve_4value_shorthands($property,$value)
|
||||
{
|
||||
$shorthands =& $GLOBALS['csstidy']['shorthands'];
|
||||
if(!is_array($shorthands[$property]))
|
||||
{
|
||||
$return[$property] = $value;
|
||||
return $return;
|
||||
}
|
||||
|
||||
$important = '';
|
||||
if(csstidy::is_important($value))
|
||||
{
|
||||
$value = csstidy::gvw_important($value);
|
||||
$important = '!important';
|
||||
}
|
||||
$values = explode(' ',$value);
|
||||
|
||||
|
||||
$return = array();
|
||||
if(count($values) == 4)
|
||||
{
|
||||
for($i=0;$i<4;$i++)
|
||||
{
|
||||
$return[$shorthands[$property][$i]] = $values[$i].$important;
|
||||
}
|
||||
}
|
||||
elseif(count($values) == 3)
|
||||
{
|
||||
$return[$shorthands[$property][0]] = $values[0].$important;
|
||||
$return[$shorthands[$property][1]] = $values[1].$important;
|
||||
$return[$shorthands[$property][3]] = $values[1].$important;
|
||||
$return[$shorthands[$property][2]] = $values[2].$important;
|
||||
}
|
||||
elseif(count($values) == 2)
|
||||
{
|
||||
for($i=0;$i<4;$i++)
|
||||
{
|
||||
$return[$shorthands[$property][$i]] = (($i % 2 != 0)) ? $values[1].$important : $values[0].$important;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for($i=0;$i<4;$i++)
|
||||
{
|
||||
$return[$shorthands[$property][$i]] = $values[0].$important;
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Explodes a string as explode() does, however, not if $sep is escaped or within a string.
|
||||
* @param string $sep seperator
|
||||
* @param string $string
|
||||
* @return array
|
||||
* @version 1.0
|
||||
*/
|
||||
function explode_ws($sep,$string)
|
||||
{
|
||||
$status = 'st';
|
||||
$to = '';
|
||||
|
||||
$output = array();
|
||||
$num = 0;
|
||||
for($i = 0, $len = strlen($string);$i < $len; $i++)
|
||||
{
|
||||
switch($status)
|
||||
{
|
||||
case 'st':
|
||||
if($string{$i} == $sep && !csstidy::escaped($string,$i))
|
||||
{
|
||||
++$num;
|
||||
}
|
||||
elseif($string{$i} == '"' || $string{$i} == '\'' || $string{$i} == '(' && !csstidy::escaped($string,$i))
|
||||
{
|
||||
$status = 'str';
|
||||
$to = ($string{$i} == '(') ? ')' : $string{$i};
|
||||
(isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i};
|
||||
}
|
||||
else
|
||||
{
|
||||
(isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i};
|
||||
}
|
||||
break;
|
||||
|
||||
case 'str':
|
||||
if($string{$i} == $to && !csstidy::escaped($string,$i))
|
||||
{
|
||||
$status = 'st';
|
||||
}
|
||||
(isset($output[$num])) ? $output[$num] .= $string{$i} : $output[$num] = $string{$i};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($output[0]))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
else
|
||||
{
|
||||
return array($output);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges Shorthand properties again, the opposite of dissolve_4value_shorthands()
|
||||
* @param array $array
|
||||
* @return array
|
||||
* @version 1.2
|
||||
* @see dissolve_4value_shorthands()
|
||||
*/
|
||||
function merge_4value_shorthands($array)
|
||||
{
|
||||
$return = $array;
|
||||
$shorthands =& $GLOBALS['csstidy']['shorthands'];
|
||||
|
||||
foreach($shorthands as $key => $value)
|
||||
{
|
||||
if(isset($array[$value[0]]) && isset($array[$value[1]])
|
||||
&& isset($array[$value[2]]) && isset($array[$value[3]]) && $value !== 0)
|
||||
{
|
||||
$return[$key] = '';
|
||||
|
||||
$important = '';
|
||||
for($i = 0; $i < 4; $i++)
|
||||
{
|
||||
$val = $array[$value[$i]];
|
||||
if(csstidy::is_important($val))
|
||||
{
|
||||
$important = '!important';
|
||||
$return[$key] .= csstidy::gvw_important($val).' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$return[$key] .= $val.' ';
|
||||
}
|
||||
unset($return[$value[$i]]);
|
||||
}
|
||||
$return[$key] = csstidy_optimise::shorthand(trim($return[$key].$important));
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dissolve background property
|
||||
* @param string $str_value
|
||||
* @return array
|
||||
* @version 1.0
|
||||
* @see merge_bg()
|
||||
* @todo full CSS 3 compliance
|
||||
*/
|
||||
function dissolve_short_bg($str_value)
|
||||
{
|
||||
$background_prop_default =& $GLOBALS['csstidy']['background_prop_default'];
|
||||
$repeat = array('repeat','repeat-x','repeat-y','no-repeat','space');
|
||||
$attachment = array('scroll','fixed','local');
|
||||
$clip = array('border','padding');
|
||||
$origin = array('border','padding','content');
|
||||
$pos = array('top','center','bottom','left','right');
|
||||
$important = '';
|
||||
$return = array('background-image' => NULL,'background-size' => NULL,'background-repeat' => NULL,'background-position' => NULL,'background-attachment'=>NULL,'background-clip' => NULL,'background-origin' => NULL,'background-color' => NULL);
|
||||
|
||||
if(csstidy::is_important($str_value))
|
||||
{
|
||||
$important = ' !important';
|
||||
$str_value = csstidy::gvw_important($str_value);
|
||||
}
|
||||
|
||||
$str_value = csstidy_optimise::explode_ws(',',$str_value);
|
||||
for($i = 0; $i < count($str_value); $i++)
|
||||
{
|
||||
$have['clip'] = FALSE; $have['pos'] = FALSE;
|
||||
$have['color'] = FALSE; $have['bg'] = FALSE;
|
||||
|
||||
$str_value[$i] = csstidy_optimise::explode_ws(' ',trim($str_value[$i]));
|
||||
|
||||
for($j = 0; $j < count($str_value[$i]); $j++)
|
||||
{
|
||||
if($have['bg'] === FALSE && (substr($str_value[$i][$j],0,4) == 'url(' || $str_value[$i][$j] === 'none'))
|
||||
{
|
||||
$return['background-image'] .= $str_value[$i][$j].',';
|
||||
$have['bg'] = TRUE;
|
||||
}
|
||||
elseif(in_array($str_value[$i][$j],$repeat,TRUE))
|
||||
{
|
||||
$return['background-repeat'] .= $str_value[$i][$j].',';
|
||||
}
|
||||
elseif(in_array($str_value[$i][$j],$attachment,TRUE))
|
||||
{
|
||||
$return['background-attachment'] .= $str_value[$i][$j].',';
|
||||
}
|
||||
elseif(in_array($str_value[$i][$j],$clip,TRUE) && !$have['clip'])
|
||||
{
|
||||
$return['background-clip'] .= $str_value[$i][$j].',';
|
||||
$have['clip'] = TRUE;
|
||||
}
|
||||
elseif(in_array($str_value[$i][$j],$origin,TRUE))
|
||||
{
|
||||
$return['background-origin'] .= $str_value[$i][$j].',';
|
||||
}
|
||||
elseif($str_value[$i][$j]{0} == '(')
|
||||
{
|
||||
$return['background-size'] .= substr($str_value[$i][$j],1,-1).',';
|
||||
}
|
||||
elseif(in_array($str_value[$i][$j],$pos,TRUE) || is_numeric($str_value[$i][$j]{0}) || $str_value[$i][$j]{0} === NULL)
|
||||
{
|
||||
$return['background-position'] .= $str_value[$i][$j];
|
||||
if(!$have['pos']) $return['background-position'] .= ' '; else $return['background-position'].= ',';
|
||||
$have['pos'] = TRUE;
|
||||
}
|
||||
elseif(!$have['color'])
|
||||
{
|
||||
$return['background-color'] .= $str_value[$i][$j].',';
|
||||
$have['color'] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach($background_prop_default as $bg_prop => $default_value)
|
||||
{
|
||||
if($return[$bg_prop] !== NULL)
|
||||
{
|
||||
$return[$bg_prop] = substr($return[$bg_prop],0,-1).$important;
|
||||
}
|
||||
else $return[$bg_prop] = $default_value.$important;
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges all background properties
|
||||
* @param array $input_css
|
||||
* @return array
|
||||
* @version 1.0
|
||||
* @see dissolve_short_bg()
|
||||
* @todo full CSS 3 compliance
|
||||
*/
|
||||
function merge_bg($input_css)
|
||||
{
|
||||
$background_prop_default =& $GLOBALS['csstidy']['background_prop_default'];
|
||||
// Max number of background images. CSS3 not yet fully implemented
|
||||
$number_of_values = @max(count(csstidy_optimise::explode_ws(',',$input_css['background-image'])),count(csstidy_optimise::explode_ws(',',$input_css['background-color'])),1);
|
||||
// Array with background images to check if BG image exists
|
||||
$bg_img_array = @csstidy_optimise::explode_ws(',',csstidy::gvw_important($input_css['background-image']));
|
||||
$new_bg_value = '';
|
||||
$important = '';
|
||||
|
||||
for($i = 0; $i < $number_of_values; $i++)
|
||||
{
|
||||
foreach($background_prop_default as $bg_property => $default_value)
|
||||
{
|
||||
// Skip if property does not exist
|
||||
if(!isset($input_css[$bg_property]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$cur_value = $input_css[$bg_property];
|
||||
|
||||
// Skip some properties if there is no background image
|
||||
if((!isset($bg_img_array[$i]) || $bg_img_array[$i] === 'none')
|
||||
&& ($bg_property === 'background-size' || $bg_property === 'background-position'
|
||||
|| $bg_property === 'background-attachment' || $bg_property === 'background-repeat'))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove !important
|
||||
if(csstidy::is_important($cur_value))
|
||||
{
|
||||
$important = ' !important';
|
||||
$cur_value = csstidy::gvw_important($cur_value);
|
||||
}
|
||||
|
||||
// Do not add default values
|
||||
if($cur_value === $default_value)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$temp = csstidy_optimise::explode_ws(',',$cur_value);
|
||||
|
||||
if(isset($temp[$i]))
|
||||
{
|
||||
if($bg_property == 'background-size')
|
||||
{
|
||||
$new_bg_value .= '('.$temp[$i].') ';
|
||||
}
|
||||
else
|
||||
{
|
||||
$new_bg_value .= $temp[$i].' ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$new_bg_value = trim($new_bg_value);
|
||||
if($i != $number_of_values-1) $new_bg_value .= ',';
|
||||
}
|
||||
|
||||
// Delete all background-properties
|
||||
foreach($background_prop_default as $bg_property => $default_value)
|
||||
{
|
||||
unset($input_css[$bg_property]);
|
||||
}
|
||||
|
||||
// Add new background property
|
||||
if($new_bg_value !== '') $input_css['background'] = $new_bg_value.$important;
|
||||
|
||||
return $input_css;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,351 @@
|
||||
<?php
|
||||
/**
|
||||
* CSSTidy - CSS Parser and Optimiser
|
||||
*
|
||||
* CSS Printing class
|
||||
* This class prints CSS data generated by csstidy.
|
||||
*
|
||||
* This file is part of CSSTidy.
|
||||
*
|
||||
* CSSTidy is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CSSTidy is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CSSTidy; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @package csstidy
|
||||
* @author Florian Schmitz (floele at gmail dot com) 2005-2006
|
||||
*/
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
/**
|
||||
* CSS Printing class
|
||||
*
|
||||
* This class prints CSS data generated by csstidy.
|
||||
*
|
||||
* @package csstidy
|
||||
* @author Florian Schmitz (floele at gmail dot com) 2005-2006
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class csstidy_print
|
||||
{
|
||||
/**
|
||||
* Saves the input CSS string
|
||||
* @var string
|
||||
* @access private
|
||||
*/
|
||||
var $input_css = '';
|
||||
|
||||
/**
|
||||
* Saves the formatted CSS string
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $output_css = '';
|
||||
|
||||
/**
|
||||
* Saves the formatted CSS string (plain text)
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $output_css_plain = '';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param array $css contains the class csstidy
|
||||
* @access private
|
||||
* @version 1.0
|
||||
*/
|
||||
function __construct(&$css)
|
||||
{
|
||||
$this->parser =& $css;
|
||||
$this->css =& $css->css;
|
||||
$this->template =& $css->template;
|
||||
$this->tokens =& $css->tokens;
|
||||
$this->charset =& $css->charset;
|
||||
$this->import =& $css->import;
|
||||
$this->namespace =& $css->namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets output_css and output_css_plain (new css code)
|
||||
* @access private
|
||||
* @version 1.0
|
||||
*/
|
||||
function _reset()
|
||||
{
|
||||
$this->output_css = '';
|
||||
$this->output_css_plain = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the CSS code as plain text
|
||||
* @return string
|
||||
* @access public
|
||||
* @version 1.0
|
||||
*/
|
||||
function plain()
|
||||
{
|
||||
$this->_print(true);
|
||||
return $this->output_css_plain;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formatted CSS code
|
||||
* @return string
|
||||
* @access public
|
||||
* @version 1.0
|
||||
*/
|
||||
function formatted()
|
||||
{
|
||||
$this->_print(false);
|
||||
return $this->output_css;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the formatted CSS Code and saves it into $this->output_css and $this->output_css_plain
|
||||
* @param bool $plain plain text or not
|
||||
* @access private
|
||||
* @version 2.0
|
||||
*/
|
||||
function _print($plain = false)
|
||||
{
|
||||
if ($this->output_css && $this->output_css_plain) {
|
||||
return;
|
||||
}
|
||||
|
||||
$output = '';
|
||||
if (!$this->parser->get_cfg('preserve_css')) {
|
||||
$this->_convert_raw_css();
|
||||
}
|
||||
|
||||
$template =& $this->template;
|
||||
|
||||
if ($plain) {
|
||||
$template = array_map('strip_tags', $template);
|
||||
}
|
||||
|
||||
if ($this->parser->get_cfg('timestamp')) {
|
||||
array_unshift($this->tokens, array(COMMENT, ' CSSTidy ' . $this->parser->version . ': ' . date('r') . ' '));
|
||||
}
|
||||
|
||||
if (!empty($this->charset)) {
|
||||
$output .= $template[0].'@charset '.$template[5].$this->charset.$template[6];
|
||||
}
|
||||
|
||||
if (!empty($this->import)) {
|
||||
for ($i = 0, $size = count($this->import); $i < $size; $i ++) {
|
||||
$output .= $template[0].'@import '.$template[5].$this->import[$i].$template[6];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->namespace)) {
|
||||
$output .= $template[0].'@namespace '.$template[5].$this->namespace.$template[6];
|
||||
}
|
||||
|
||||
$output .= $template[13];
|
||||
$in_at_out = '';
|
||||
$out =& $output;
|
||||
|
||||
foreach ($this->tokens as $key => $token)
|
||||
{
|
||||
switch ($token[0])
|
||||
{
|
||||
case AT_START:
|
||||
$out .= $template[0].$this->_htmlsp($token[1], $plain).$template[1];
|
||||
$out =& $in_at_out;
|
||||
break;
|
||||
|
||||
case SEL_START:
|
||||
if($this->parser->get_cfg('lowercase_s')) $token[1] = strtolower($token[1]);
|
||||
$out .= ($token[1]{0} !== '@') ? $template[2].$this->_htmlsp($token[1], $plain) : $template[0].$this->_htmlsp($token[1], $plain);
|
||||
$out .= $template[3];
|
||||
break;
|
||||
|
||||
case PROPERTY:
|
||||
if($this->parser->get_cfg('case_properties') == 2) $token[1] = strtoupper($token[1]);
|
||||
if($this->parser->get_cfg('case_properties') == 1) $token[1] = strtolower($token[1]);
|
||||
$out .= $template[4] . $this->_htmlsp($token[1], $plain) . ':' . $template[5];
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
$out .= $this->_htmlsp($token[1], $plain);
|
||||
if($this->_seeknocomment($key, 1) == SEL_END && $this->parser->get_cfg('remove_last_;')) {
|
||||
$out .= str_replace(';', '', $template[6]);
|
||||
} else {
|
||||
$out .= $template[6];
|
||||
}
|
||||
break;
|
||||
|
||||
case SEL_END:
|
||||
$out .= $template[7];
|
||||
if($this->_seeknocomment($key, 1) != AT_END) $out .= $template[8];
|
||||
break;
|
||||
|
||||
case AT_END:
|
||||
$out =& $output;
|
||||
$out .= $template[10] . str_replace("\n", "\n" . $template[10], $in_at_out);
|
||||
$in_at_out = '';
|
||||
$out .= $template[9];
|
||||
break;
|
||||
|
||||
case COMMENT:
|
||||
$out .= $template[11] . '/*' . $this->_htmlsp($token[1], $plain) . '*/' . $template[12];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$output = trim($output);
|
||||
|
||||
if (!$plain) {
|
||||
$this->output_css = $output;
|
||||
$this->_print(true);
|
||||
} else {
|
||||
$this->output_css_plain = $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the next token type which is $move away from $key, excluding comments
|
||||
* @param integer $key current position
|
||||
* @param integer $move move this far
|
||||
* @return mixed a token type
|
||||
* @access private
|
||||
* @version 1.0
|
||||
*/
|
||||
function _seeknocomment($key, $move) {
|
||||
$go = ($move > 0) ? 1 : -1;
|
||||
for ($i = $key + 1; abs($key-$i)-1 < abs($move); $i += $go) {
|
||||
if (!isset($this->tokens[$i])) {
|
||||
return;
|
||||
}
|
||||
if ($this->tokens[$i][0] == COMMENT) {
|
||||
$move += 1;
|
||||
continue;
|
||||
}
|
||||
return $this->tokens[$i][0];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts $this->css array to a raw array ($this->tokens)
|
||||
* @access private
|
||||
* @version 1.0
|
||||
*/
|
||||
function _convert_raw_css()
|
||||
{
|
||||
$this->tokens = array();
|
||||
|
||||
foreach ($this->css as $medium => $val)
|
||||
{
|
||||
if ($this->parser->get_cfg('sort_selectors')) ksort($val);
|
||||
if ($medium != DEFAULT_AT) {
|
||||
$this->parser->_add_token(AT_START, $medium, true);
|
||||
}
|
||||
|
||||
foreach ($val as $selector => $vali)
|
||||
{
|
||||
if ($this->parser->get_cfg('sort_properties')) ksort($vali);
|
||||
$this->parser->_add_token(SEL_START, $selector, true);
|
||||
|
||||
foreach ($vali as $property => $valj)
|
||||
{
|
||||
$this->parser->_add_token(PROPERTY, $property, true);
|
||||
$this->parser->_add_token(VALUE, $valj, true);
|
||||
}
|
||||
|
||||
$this->parser->_add_token(SEL_END, $selector, true);
|
||||
}
|
||||
|
||||
if ($medium != DEFAULT_AT) {
|
||||
$this->parser->_add_token(AT_END, $medium, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as htmlspecialchars, only that chars are not replaced if $plain !== true. This makes print_code() cleaner.
|
||||
* @param string $string
|
||||
* @param bool $plain
|
||||
* @return string
|
||||
* @see csstidy_print::_print()
|
||||
* @access private
|
||||
* @version 1.0
|
||||
*/
|
||||
function _htmlsp($string, $plain)
|
||||
{
|
||||
if (!$plain) {
|
||||
return htmlspecialchars($string);
|
||||
}
|
||||
return $string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get compression ratio
|
||||
* @access public
|
||||
* @return float
|
||||
* @version 1.2
|
||||
*/
|
||||
function get_ratio()
|
||||
{
|
||||
if (!$this->output_css_plain) {
|
||||
$this->formatted();
|
||||
}
|
||||
return round((strlen($this->input_css) - strlen($this->output_css_plain)) / strlen($this->input_css), 3) * 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get difference between the old and new code in bytes and prints the code if necessary.
|
||||
* @access public
|
||||
* @return string
|
||||
* @version 1.1
|
||||
*/
|
||||
function get_diff()
|
||||
{
|
||||
if (!$this->output_css_plain) {
|
||||
$this->formatted();
|
||||
}
|
||||
|
||||
$diff = strlen($this->output_css_plain) - strlen($this->input_css);
|
||||
|
||||
if ($diff > 0) {
|
||||
return '+' . $diff;
|
||||
} elseif ($diff == 0) {
|
||||
return '+-' . $diff;
|
||||
}
|
||||
|
||||
return $diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of either input or output CSS in KB
|
||||
* @param string $loc default is "output"
|
||||
* @access public
|
||||
* @return integer
|
||||
* @version 1.0
|
||||
*/
|
||||
function size($loc = 'output')
|
||||
{
|
||||
if ($loc == 'output' && !$this->output_css) {
|
||||
$this->formatted();
|
||||
}
|
||||
|
||||
if ($loc == 'input') {
|
||||
return (strlen($this->input_css) / 1000);
|
||||
} else {
|
||||
return (strlen($this->output_css_plain) / 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,474 @@
|
||||
<?php
|
||||
/**
|
||||
* Various CSS Data for CSSTidy
|
||||
*
|
||||
* This file is part of CSSTidy.
|
||||
*
|
||||
* CSSTidy is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* CSSTidy is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with CSSTidy; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
|
||||
* @package csstidy
|
||||
* @author Florian Schmitz (floele at gmail dot com) 2005
|
||||
*/
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
define('AT_START', 1);
|
||||
define('AT_END', 2);
|
||||
define('SEL_START', 3);
|
||||
define('SEL_END', 4);
|
||||
define('PROPERTY', 5);
|
||||
define('VALUE', 6);
|
||||
define('COMMENT', 7);
|
||||
define('DEFAULT_AT', 41);
|
||||
|
||||
/**
|
||||
* All whitespace allowed in CSS
|
||||
*
|
||||
* @global array $GLOBALS['csstidy']['whitespace']
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['whitespace'] = array(' ',"\n","\t","\r","\x0B");
|
||||
|
||||
/**
|
||||
* All CSS tokens used by csstidy
|
||||
*
|
||||
* @global string $GLOBALS['csstidy']['tokens']
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['tokens'] = '/@}{;:=\'"(,\\!$%&)*+.<>?[]^`|~';
|
||||
|
||||
/**
|
||||
* All CSS units (CSS 3 units included)
|
||||
*
|
||||
* @see compress_numbers()
|
||||
* @global array $GLOBALS['csstidy']['units']
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['units'] = array('in','cm','mm','pt','pc','px','rem','em','%','ex','gd','vw','vh','vm','deg','grad','rad','ms','s','khz','hz');
|
||||
|
||||
/**
|
||||
* Available at-rules
|
||||
*
|
||||
* @global array $GLOBALS['csstidy']['at_rules']
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['at_rules'] = array('page' => 'is','font-face' => 'is','charset' => 'iv', 'import' => 'iv','namespace' => 'iv','media' => 'at');
|
||||
|
||||
/**
|
||||
* Properties that need a value with unit
|
||||
*
|
||||
* @todo CSS3 properties
|
||||
* @see compress_numbers();
|
||||
* @global array $GLOBALS['csstidy']['unit_values']
|
||||
* @version 1.2
|
||||
*/
|
||||
$GLOBALS['csstidy']['unit_values'] = array ('background', 'background-position', 'border', 'border-top', 'border-right', 'border-bottom', 'border-left', 'border-width',
|
||||
'border-top-width', 'border-right-width', 'border-left-width', 'border-bottom-width', 'bottom', 'border-spacing', 'font-size',
|
||||
'height', 'left', 'margin', 'margin-top', 'margin-right', 'margin-bottom', 'margin-left', 'max-height', 'max-width',
|
||||
'min-height', 'min-width', 'outline-width', 'padding', 'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
|
||||
'position', 'right', 'top', 'text-indent', 'letter-spacing', 'word-spacing', 'width');
|
||||
|
||||
/**
|
||||
* Properties that allow <color> as value
|
||||
*
|
||||
* @todo CSS3 properties
|
||||
* @see compress_numbers();
|
||||
* @global array $GLOBALS['csstidy']['color_values']
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['color_values'] = array();
|
||||
$GLOBALS['csstidy']['color_values'][] = 'background-color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'border-color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'border-top-color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'border-right-color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'border-bottom-color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'border-left-color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'color';
|
||||
$GLOBALS['csstidy']['color_values'][] = 'outline-color';
|
||||
|
||||
|
||||
/**
|
||||
* Default values for the background properties
|
||||
*
|
||||
* @todo Possibly property names will change during CSS3 development
|
||||
* @global array $GLOBALS['csstidy']['background_prop_default']
|
||||
* @see dissolve_short_bg()
|
||||
* @see merge_bg()
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['background_prop_default'] = array();
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-image'] = 'none';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-size'] = 'auto';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-repeat'] = 'repeat';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-position'] = '0 0';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-attachment'] = 'scroll';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-clip'] = 'border';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-origin'] = 'padding';
|
||||
$GLOBALS['csstidy']['background_prop_default']['background-color'] = 'transparent';
|
||||
|
||||
/**
|
||||
* A list of non-W3C color names which get replaced by their hex-codes
|
||||
*
|
||||
* @global array $GLOBALS['csstidy']['replace_colors']
|
||||
* @see cut_color()
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['replace_colors'] = array();
|
||||
$GLOBALS['csstidy']['replace_colors']['aliceblue'] = '#F0F8FF';
|
||||
$GLOBALS['csstidy']['replace_colors']['antiquewhite'] = '#FAEBD7';
|
||||
$GLOBALS['csstidy']['replace_colors']['aquamarine'] = '#7FFFD4';
|
||||
$GLOBALS['csstidy']['replace_colors']['azure'] = '#F0FFFF';
|
||||
$GLOBALS['csstidy']['replace_colors']['beige'] = '#F5F5DC';
|
||||
$GLOBALS['csstidy']['replace_colors']['bisque'] = '#FFE4C4';
|
||||
$GLOBALS['csstidy']['replace_colors']['blanchedalmond'] = '#FFEBCD';
|
||||
$GLOBALS['csstidy']['replace_colors']['blueviolet'] = '#8A2BE2';
|
||||
$GLOBALS['csstidy']['replace_colors']['brown'] = '#A52A2A';
|
||||
$GLOBALS['csstidy']['replace_colors']['burlywood'] = '#DEB887';
|
||||
$GLOBALS['csstidy']['replace_colors']['cadetblue'] = '#5F9EA0';
|
||||
$GLOBALS['csstidy']['replace_colors']['chartreuse'] = '#7FFF00';
|
||||
$GLOBALS['csstidy']['replace_colors']['chocolate'] = '#D2691E';
|
||||
$GLOBALS['csstidy']['replace_colors']['coral'] = '#FF7F50';
|
||||
$GLOBALS['csstidy']['replace_colors']['cornflowerblue'] = '#6495ED';
|
||||
$GLOBALS['csstidy']['replace_colors']['cornsilk'] = '#FFF8DC';
|
||||
$GLOBALS['csstidy']['replace_colors']['crimson'] = '#DC143C';
|
||||
$GLOBALS['csstidy']['replace_colors']['cyan'] = '#00FFFF';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkblue'] = '#00008B';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkcyan'] = '#008B8B';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkgoldenrod'] = '#B8860B';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkgray'] = '#A9A9A9';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkgreen'] = '#006400';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkkhaki'] = '#BDB76B';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkmagenta'] = '#8B008B';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkolivegreen'] = '#556B2F';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkorange'] = '#FF8C00';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkorchid'] = '#9932CC';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkred'] = '#8B0000';
|
||||
$GLOBALS['csstidy']['replace_colors']['darksalmon'] = '#E9967A';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkseagreen'] = '#8FBC8F';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkslateblue'] = '#483D8B';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkslategray'] = '#2F4F4F';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkturquoise'] = '#00CED1';
|
||||
$GLOBALS['csstidy']['replace_colors']['darkviolet'] = '#9400D3';
|
||||
$GLOBALS['csstidy']['replace_colors']['deeppink'] = '#FF1493';
|
||||
$GLOBALS['csstidy']['replace_colors']['deepskyblue'] = '#00BFFF';
|
||||
$GLOBALS['csstidy']['replace_colors']['dimgray'] = '#696969';
|
||||
$GLOBALS['csstidy']['replace_colors']['dodgerblue'] = '#1E90FF';
|
||||
$GLOBALS['csstidy']['replace_colors']['feldspar'] = '#D19275';
|
||||
$GLOBALS['csstidy']['replace_colors']['firebrick'] = '#B22222';
|
||||
$GLOBALS['csstidy']['replace_colors']['floralwhite'] = '#FFFAF0';
|
||||
$GLOBALS['csstidy']['replace_colors']['forestgreen'] = '#228B22';
|
||||
$GLOBALS['csstidy']['replace_colors']['gainsboro'] = '#DCDCDC';
|
||||
$GLOBALS['csstidy']['replace_colors']['ghostwhite'] = '#F8F8FF';
|
||||
$GLOBALS['csstidy']['replace_colors']['gold'] = '#FFD700';
|
||||
$GLOBALS['csstidy']['replace_colors']['goldenrod'] = '#DAA520';
|
||||
$GLOBALS['csstidy']['replace_colors']['greenyellow'] = '#ADFF2F';
|
||||
$GLOBALS['csstidy']['replace_colors']['honeydew'] = '#F0FFF0';
|
||||
$GLOBALS['csstidy']['replace_colors']['hotpink'] = '#FF69B4';
|
||||
$GLOBALS['csstidy']['replace_colors']['indianred'] = '#CD5C5C';
|
||||
$GLOBALS['csstidy']['replace_colors']['indigo'] = '#4B0082';
|
||||
$GLOBALS['csstidy']['replace_colors']['ivory'] = '#FFFFF0';
|
||||
$GLOBALS['csstidy']['replace_colors']['khaki'] = '#F0E68C';
|
||||
$GLOBALS['csstidy']['replace_colors']['lavender'] = '#E6E6FA';
|
||||
$GLOBALS['csstidy']['replace_colors']['lavenderblush'] = '#FFF0F5';
|
||||
$GLOBALS['csstidy']['replace_colors']['lawngreen'] = '#7CFC00';
|
||||
$GLOBALS['csstidy']['replace_colors']['lemonchiffon'] = '#FFFACD';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightblue'] = '#ADD8E6';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightcoral'] = '#F08080';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightcyan'] = '#E0FFFF';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightgoldenrodyellow'] = '#FAFAD2';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightgrey'] = '#D3D3D3';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightgreen'] = '#90EE90';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightpink'] = '#FFB6C1';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightsalmon'] = '#FFA07A';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightseagreen'] = '#20B2AA';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightskyblue'] = '#87CEFA';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightslateblue'] = '#8470FF';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightslategray'] = '#778899';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightsteelblue'] = '#B0C4DE';
|
||||
$GLOBALS['csstidy']['replace_colors']['lightyellow'] = '#FFFFE0';
|
||||
$GLOBALS['csstidy']['replace_colors']['limegreen'] = '#32CD32';
|
||||
$GLOBALS['csstidy']['replace_colors']['linen'] = '#FAF0E6';
|
||||
$GLOBALS['csstidy']['replace_colors']['magenta'] = '#FF00FF';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumaquamarine'] = '#66CDAA';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumblue'] = '#0000CD';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumorchid'] = '#BA55D3';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumpurple'] = '#9370D8';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumseagreen'] = '#3CB371';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumslateblue'] = '#7B68EE';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumspringgreen'] = '#00FA9A';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumturquoise'] = '#48D1CC';
|
||||
$GLOBALS['csstidy']['replace_colors']['mediumvioletred'] = '#C71585';
|
||||
$GLOBALS['csstidy']['replace_colors']['midnightblue'] = '#191970';
|
||||
$GLOBALS['csstidy']['replace_colors']['mintcream'] = '#F5FFFA';
|
||||
$GLOBALS['csstidy']['replace_colors']['mistyrose'] = '#FFE4E1';
|
||||
$GLOBALS['csstidy']['replace_colors']['moccasin'] = '#FFE4B5';
|
||||
$GLOBALS['csstidy']['replace_colors']['navajowhite'] = '#FFDEAD';
|
||||
$GLOBALS['csstidy']['replace_colors']['oldlace'] = '#FDF5E6';
|
||||
$GLOBALS['csstidy']['replace_colors']['olivedrab'] = '#6B8E23';
|
||||
$GLOBALS['csstidy']['replace_colors']['orangered'] = '#FF4500';
|
||||
$GLOBALS['csstidy']['replace_colors']['orchid'] = '#DA70D6';
|
||||
$GLOBALS['csstidy']['replace_colors']['palegoldenrod'] = '#EEE8AA';
|
||||
$GLOBALS['csstidy']['replace_colors']['palegreen'] = '#98FB98';
|
||||
$GLOBALS['csstidy']['replace_colors']['paleturquoise'] = '#AFEEEE';
|
||||
$GLOBALS['csstidy']['replace_colors']['palevioletred'] = '#D87093';
|
||||
$GLOBALS['csstidy']['replace_colors']['papayawhip'] = '#FFEFD5';
|
||||
$GLOBALS['csstidy']['replace_colors']['peachpuff'] = '#FFDAB9';
|
||||
$GLOBALS['csstidy']['replace_colors']['peru'] = '#CD853F';
|
||||
$GLOBALS['csstidy']['replace_colors']['pink'] = '#FFC0CB';
|
||||
$GLOBALS['csstidy']['replace_colors']['plum'] = '#DDA0DD';
|
||||
$GLOBALS['csstidy']['replace_colors']['powderblue'] = '#B0E0E6';
|
||||
$GLOBALS['csstidy']['replace_colors']['rosybrown'] = '#BC8F8F';
|
||||
$GLOBALS['csstidy']['replace_colors']['royalblue'] = '#4169E1';
|
||||
$GLOBALS['csstidy']['replace_colors']['saddlebrown'] = '#8B4513';
|
||||
$GLOBALS['csstidy']['replace_colors']['salmon'] = '#FA8072';
|
||||
$GLOBALS['csstidy']['replace_colors']['sandybrown'] = '#F4A460';
|
||||
$GLOBALS['csstidy']['replace_colors']['seagreen'] = '#2E8B57';
|
||||
$GLOBALS['csstidy']['replace_colors']['seashell'] = '#FFF5EE';
|
||||
$GLOBALS['csstidy']['replace_colors']['sienna'] = '#A0522D';
|
||||
$GLOBALS['csstidy']['replace_colors']['skyblue'] = '#87CEEB';
|
||||
$GLOBALS['csstidy']['replace_colors']['slateblue'] = '#6A5ACD';
|
||||
$GLOBALS['csstidy']['replace_colors']['slategray'] = '#708090';
|
||||
$GLOBALS['csstidy']['replace_colors']['snow'] = '#FFFAFA';
|
||||
$GLOBALS['csstidy']['replace_colors']['springgreen'] = '#00FF7F';
|
||||
$GLOBALS['csstidy']['replace_colors']['steelblue'] = '#4682B4';
|
||||
$GLOBALS['csstidy']['replace_colors']['tan'] = '#D2B48C';
|
||||
$GLOBALS['csstidy']['replace_colors']['thistle'] = '#D8BFD8';
|
||||
$GLOBALS['csstidy']['replace_colors']['tomato'] = '#FF6347';
|
||||
$GLOBALS['csstidy']['replace_colors']['turquoise'] = '#40E0D0';
|
||||
$GLOBALS['csstidy']['replace_colors']['violet'] = '#EE82EE';
|
||||
$GLOBALS['csstidy']['replace_colors']['violetred'] = '#D02090';
|
||||
$GLOBALS['csstidy']['replace_colors']['wheat'] = '#F5DEB3';
|
||||
$GLOBALS['csstidy']['replace_colors']['whitesmoke'] = '#F5F5F5';
|
||||
$GLOBALS['csstidy']['replace_colors']['yellowgreen'] = '#9ACD32';
|
||||
|
||||
|
||||
/**
|
||||
* A list of all shorthand properties that are devided into four properties and/or have four subvalues
|
||||
*
|
||||
* @global array $GLOBALS['csstidy']['shorthands']
|
||||
* @todo Are there new ones in CSS3?
|
||||
* @see dissolve_4value_shorthands()
|
||||
* @see merge_4value_shorthands()
|
||||
* @version 1.0
|
||||
*/
|
||||
$GLOBALS['csstidy']['shorthands'] = array();
|
||||
$GLOBALS['csstidy']['shorthands']['border-color'] = array('border-top-color','border-right-color','border-bottom-color','border-left-color');
|
||||
$GLOBALS['csstidy']['shorthands']['border-style'] = array('border-top-style','border-right-style','border-bottom-style','border-left-style');
|
||||
$GLOBALS['csstidy']['shorthands']['border-width'] = array('border-top-width','border-right-width','border-bottom-width','border-left-width');
|
||||
$GLOBALS['csstidy']['shorthands']['margin'] = array('margin-top','margin-right','margin-bottom','margin-left');
|
||||
$GLOBALS['csstidy']['shorthands']['padding'] = array('padding-top','padding-right','padding-bottom','padding-left');
|
||||
$GLOBALS['csstidy']['shorthands']['-moz-border-radius'] = 0;
|
||||
|
||||
/**
|
||||
* All CSS Properties. Needed for csstidy::property_is_next()
|
||||
*
|
||||
* @global array $GLOBALS['csstidy']['all_properties']
|
||||
* @todo Add CSS3 properties
|
||||
* @version 1.0
|
||||
* @see csstidy::property_is_next()
|
||||
*/
|
||||
$GLOBALS['csstidy']['all_properties'] = array();
|
||||
$GLOBALS['csstidy']['all_properties']['background'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['background-color'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['background-image'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['background-repeat'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['background-attachment'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['background-position'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-top'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-right'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-bottom'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-left'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-color'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-top-color'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-bottom-color'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-left-color'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-right-color'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-style'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-top-style'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-right-style'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-left-style'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-bottom-style'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-width'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-top-width'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-right-width'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-left-width'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-bottom-width'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-collapse'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['border-spacing'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['bottom'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['caption-side'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['content'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['clear'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['clip'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['color'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['counter-reset'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['counter-increment'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['cursor'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['empty-cells'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['display'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['direction'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['float'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['font'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['font-family'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['font-style'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['font-variant'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['font-weight'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['font-stretch'] = 'CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['font-size-adjust'] = 'CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['font-size'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['height'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['left'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['line-height'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['list-style'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['list-style-type'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['list-style-image'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['list-style-position'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['margin'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['margin-top'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['margin-right'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['margin-bottom'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['margin-left'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['marks'] = 'CSS1.0,CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['marker-offset'] = 'CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['max-height'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['max-width'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['min-height'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['min-width'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['overflow'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['orphans'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['outline'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['outline-width'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['outline-style'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['outline-color'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['padding'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['padding-top'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['padding-right'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['padding-bottom'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['padding-left'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['page-break-before'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['page-break-after'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['page-break-inside'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['page'] = 'CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['position'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['quotes'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['right'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['size'] = 'CSS1.0,CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['speak-header'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['table-layout'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['top'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['text-indent'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['text-align'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['text-decoration'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['text-shadow'] = 'CSS2.0';
|
||||
$GLOBALS['csstidy']['all_properties']['letter-spacing'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['word-spacing'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['text-transform'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['white-space'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['unicode-bidi'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['vertical-align'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['visibility'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['width'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['widows'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['z-index'] = 'CSS1.0,CSS2.0,CSS2.1';
|
||||
/* Speech */
|
||||
$GLOBALS['csstidy']['all_properties']['volume'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['speak'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['pause'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['pause-before'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['pause-after'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['cue'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['cue-before'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['cue-after'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['play-during'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['azimuth'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['elevation'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['speech-rate'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['voice-family'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['pitch'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['pitch-range'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['stress'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['richness'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['speak-punctuation'] = 'CSS2.0,CSS2.1';
|
||||
$GLOBALS['csstidy']['all_properties']['speak-numeral'] = 'CSS2.0,CSS2.1';
|
||||
|
||||
/**
|
||||
* An array containing all predefined templates.
|
||||
*
|
||||
* @global array $GLOBALS['csstidy']['predefined_templates']
|
||||
* @version 1.0
|
||||
* @see csstidy::load_template()
|
||||
*/
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="at">'; //string before @rule
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>'."\n"; //bracket after @-rule
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="selector">'; //string before selector
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span> <span class="format">{</span>'."\n"; //bracket after selector
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="property">'; //string before property
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="value">'; //string after property+before value
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span><span class="format">;</span>'."\n"; //string after value
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="format">}</span>'; //closing bracket - selector
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n\n"; //space between blocks {...}
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n".'<span class="format">}</span>'. "\n\n"; //closing bracket @-rule
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = ''; //indent in @-rule
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '<span class="comment">'; // before comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = '</span>'."\n"; // after comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['default'][] = "\n"; // after last line @-rule
|
||||
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="at">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span> <span class="format">{</span>'."\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="selector">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="format">{</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="property">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="value">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span><span class="format">;</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="format">}</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n". '<span class="format">}'."\n".'</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '';
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '<span class="comment">'; // before comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = '</span>'; // after comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['high_compression'][] = "\n";
|
||||
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="at">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="format">{</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="selector">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="format">{</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="property">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="value">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span><span class="format">;</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="format">}</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="format">}</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '<span class="comment">'; // before comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '</span>'; // after comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['highest_compression'][] = '';
|
||||
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="at">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span> <span class="format">{</span>'."\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="selector">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n".'<span class="format">{</span>'."\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = ' <span class="property">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="value">';
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span><span class="format">;</span>'."\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="format">}</span>';
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n".'<span class="format">}</span>'."\n\n";
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = ' ';
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '<span class="comment">'; // before comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = '</span>'."\n"; // after comment
|
||||
$GLOBALS['csstidy']['predefined_templates']['low_compression'][] = "\n";
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('ABSPATH') or die();
|
||||
|
||||
class wptmBase {
|
||||
|
||||
|
||||
public static function loadValue($var,$value,$default=''){
|
||||
if(is_object($var) && isset($var->$value)){
|
||||
return $var->$value;
|
||||
}elseif(is_array($var) && isset($var[$value])){
|
||||
return $var[$value];
|
||||
}
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* method to retrieve the path to the component image directory
|
||||
* @param type $id_category
|
||||
* @return string directory path
|
||||
*/
|
||||
public static function getFilesPath($id_category=null){
|
||||
$upload_dir = wp_upload_dir();
|
||||
if($id_category===null){
|
||||
return $upload_dir['basedir'].DIRECTORY_SEPARATOR.'com_wptm'.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
return $upload_dir['basedir'].DIRECTORY_SEPARATOR.'com_wptm'.DIRECTORY_SEPARATOR.$id_category.DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Controller;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmControllerCategories extends Controller {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Controller;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmControllerCategory extends Controller {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Controller;
|
||||
use Joomunited\WPFramework\v1_0_4\Form;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
use Joomunited\WPFramework\v1_0_4\Factory;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmControllerConfig extends Controller {
|
||||
|
||||
public function saveconfig(){
|
||||
$model = $this->getModel();
|
||||
|
||||
$form = new Form();
|
||||
if(!$form->load('config')){
|
||||
$this->redirect('admin.php?page=wptm-config&error=1');
|
||||
}
|
||||
if(!$form->validate()){
|
||||
$this->redirect('admin.php?page=wptm-config&error=2');
|
||||
}
|
||||
$datas = $form->sanitize();
|
||||
if(!$model->save($datas)){
|
||||
$this->redirect('admin.php?page=wptm-config&error=3');
|
||||
}
|
||||
$this->redirect('admin.php?page=wptm-config');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Controller;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmControllerTable extends Controller {
|
||||
|
||||
public function save() {
|
||||
$id_table = Utilities::getInt('id','POST');
|
||||
$datas = Utilities::getInput('jform','POST','none');
|
||||
$model = $this->getModel();
|
||||
if($model->save($id_table, $datas)){
|
||||
$this->exitStatus(true);
|
||||
}else{
|
||||
$this->exitStatus( __('error while saving table','wp-smart-editor') );
|
||||
}
|
||||
}
|
||||
|
||||
public function add(){
|
||||
$id_category = Utilities::getInt('id_category');
|
||||
$model = $this->getModel();
|
||||
$id = $model->add($id_category);
|
||||
if($id){
|
||||
$this->exitStatus(true,array('id'=> $id ,'title'=>__('New table','wp-smart-editor')));
|
||||
}
|
||||
$this->exitStatus( __('error while adding table','wp-smart-editor') );
|
||||
}
|
||||
|
||||
public function copy(){
|
||||
$id = Utilities::getInt('id');
|
||||
$model = $this->getModel();
|
||||
$newItem = $model->copy($id);
|
||||
if($newItem){
|
||||
$table = $model->getItem($newItem);
|
||||
$this->exitStatus(true,array('id'=>$table->id,'title'=>$table->title) );
|
||||
}
|
||||
$this->exitStatus( __('error while adding table','wp-smart-editor') );
|
||||
}
|
||||
|
||||
public function delete(){
|
||||
$id = Utilities::getInt('id');
|
||||
$model = $this->getModel();
|
||||
$result = $model->delete($id);
|
||||
if($result){
|
||||
$this->exitStatus(true);
|
||||
}
|
||||
$this->exitStatus(__('An error occurred!','wp-smart-editor'));
|
||||
}
|
||||
|
||||
public function setTitle(){
|
||||
$id = Utilities::getInt('id');
|
||||
$new_title = Utilities::getInput('title', 'GET', 'string');
|
||||
$model = $this->getModel();
|
||||
$result = $model->setTitle($id,$new_title);
|
||||
if($result !== false){
|
||||
$this->exitStatus(true);
|
||||
}
|
||||
$this->exitStatus(__('An error occurred!','wp-smart-editor'));
|
||||
}
|
||||
|
||||
public function order(){
|
||||
|
||||
$tables = Utilities::getInput('data', 'GET', 'string');
|
||||
$model = $this->getModel();
|
||||
$result = $model->setPosition($tables);
|
||||
if($result !== false){
|
||||
$this->exitStatus(true);
|
||||
}
|
||||
$this->exitStatus(__('An error occurred!','wp-smart-editor'));
|
||||
}
|
||||
|
||||
|
||||
public function changeCategory(){
|
||||
|
||||
$id_table = Utilities::getInt('id') ;
|
||||
$category = Utilities::getInt('category') ;
|
||||
$model = $this->getModel();
|
||||
$result = $model->setCategory($id_table,$category);
|
||||
if($result !== false){
|
||||
$this->exitStatus(true);
|
||||
}else {
|
||||
$this->exitStatus(__('An error occurred!','wp-smart-editor'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Controller;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmControllerWptm extends Controller {
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
class WptmTablesHelper
|
||||
{
|
||||
/**
|
||||
* Convert an object of files to a multidimentional array
|
||||
* @param array/object $tables
|
||||
*/
|
||||
public static function categoryObject($tables){
|
||||
$ordered = array();
|
||||
foreach ($tables as $table){
|
||||
$ordered[$table->id_category][] = $table;
|
||||
}
|
||||
return $ordered;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Application;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
if (!defined('WPSE_LANG_DIR')) {
|
||||
define('WPSE_LANG_DIR', WP_PLUGIN_DIR . '/wp-smart-editor/languages/');
|
||||
}
|
||||
|
||||
$app = Application::getInstance('wptm');
|
||||
require_once $app->getPath().DIRECTORY_SEPARATOR.$app->getType().DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.'wptmBase.php';
|
||||
|
||||
add_action( 'admin_menu', 'wptm_menu' );
|
||||
add_action( 'wp_ajax_wptm', 'wptm_ajax' );
|
||||
add_action( 'media_buttons_context', 'wptm_button');
|
||||
add_action( 'load-dashboard_page_wptm-foldertree', 'wptm_foldertree_thickbox' );
|
||||
add_action('wp_ajax_wptm_getFolders', 'wptm_getFolders' );
|
||||
|
||||
// Load the heartbeat JS
|
||||
function wptm_heartbeat_enqueue( $hook_suffix ) {
|
||||
// Make sure the JS part of the Heartbeat API is loaded.
|
||||
wp_enqueue_script( 'heartbeat' );
|
||||
add_action( 'admin_print_footer_scripts', 'wptm_heartbeat_footer_js', 20 );
|
||||
}
|
||||
add_action( 'admin_enqueue_scripts', 'wptm_heartbeat_enqueue' );
|
||||
// Inject our JS into the admin footer
|
||||
function wptm_heartbeat_footer_js() {
|
||||
global $pagenow;
|
||||
|
||||
?>
|
||||
<script>
|
||||
(function($){
|
||||
|
||||
// Hook into the heartbeat-send
|
||||
$(document).on('heartbeat-send', function(e, data) {
|
||||
data['wptm_heartbeat'] = 'rendering';
|
||||
});
|
||||
|
||||
// Listen for the custom event "heartbeat-tick" on $(document).
|
||||
$(document).on( 'heartbeat-tick', function(e, data) {
|
||||
// Only proceed if our EDD data is present
|
||||
if ( ! data['wptm-result'] )
|
||||
return;
|
||||
|
||||
});
|
||||
}(jQuery));
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Modify the data that goes back with the heartbeat-tick
|
||||
function wptm_heartbeat_received( $response, $data ) {
|
||||
|
||||
// Make sure we only run our query if the edd_heartbeat key is present
|
||||
if( $data['wptm_heartbeat'] == 'rendering' ) {
|
||||
$app = Application::getInstance('wptm');
|
||||
require_once dirname(WPTML_PLUGIN_FILE).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'site'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR. 'wptmHelper.php';
|
||||
$wptmHelper = new WptmHelper();
|
||||
$modelTables = Model::getInstance('tables');
|
||||
$tables = $modelTables->getItems();
|
||||
if(count($tables)) {
|
||||
foreach ($tables as $table) {
|
||||
$wptmHelper->styleRender($table);
|
||||
$wptmHelper->htmlRender($table);
|
||||
}
|
||||
}
|
||||
|
||||
$modelConfig = Model::getInstance('config');
|
||||
$params = $modelConfig->getConfig();
|
||||
if(isset($params['sync_periodicity']) && $params['sync_periodicity'] != '0'):
|
||||
if(isset($params['last_sync']) && $params['last_sync'] != '0' ) {
|
||||
$last_sync = $params['last_sync'];
|
||||
}else {
|
||||
$last_sync = 0;
|
||||
}
|
||||
$time_now=(int)strtotime(date('Y-m-d H:i:s'));
|
||||
if( ($time_now - $last_sync)/3600 >= $params['sync_periodicity'] ) {
|
||||
//do sync
|
||||
$app->execute('excel.syncSpreadsheet');
|
||||
|
||||
$params['last_sync'] = $time_now ;
|
||||
$modelConfig->save($params);
|
||||
}
|
||||
|
||||
endif;
|
||||
// Send back the number of complete payments
|
||||
$response['wptm-result'] = time();
|
||||
|
||||
}
|
||||
return $response;
|
||||
}
|
||||
|
||||
add_filter( 'heartbeat_received', 'wptm_heartbeat_received', 10, 2 );
|
||||
|
||||
function wptm_menu() {
|
||||
$app = Application::getInstance('wptm');
|
||||
add_menu_page( 'WP Table Manager', 'WP Table Manager', 'edit_posts', 'wptm', 'wptm_call', 'dashicons-screenoptions');
|
||||
}
|
||||
|
||||
function wptm_ajax(){
|
||||
define( 'WPTM_AJAX', 'true');
|
||||
wptm_call();
|
||||
}
|
||||
|
||||
function wptm_call($ref=null,$default_task='wptm.display') {
|
||||
|
||||
if ( !current_user_can( 'edit_posts' ) ) {
|
||||
wp_die( __( 'You do not have sufficient permissions to access this page.','wp-smart-editor' ) );
|
||||
}
|
||||
|
||||
$application = Application::getInstance('wptm');
|
||||
|
||||
wptm_init();
|
||||
|
||||
$application->execute($default_task);
|
||||
}
|
||||
|
||||
function wptm_init(){
|
||||
|
||||
$page = $_REQUEST['page'];
|
||||
$application = Application::getInstance('wptm');
|
||||
load_plugin_textdomain( 'wp-smart-editor', null,WPSE_LANG_DIR);
|
||||
load_plugin_textdomain( 'wp-smart-editor', null, WPSE_LANG_DIR);
|
||||
|
||||
wp_enqueue_script('jquery');
|
||||
wp_enqueue_script('jquery-migrate');
|
||||
wp_enqueue_script('jquery-ui-core');
|
||||
wp_enqueue_script('jquery-ui-draggable');
|
||||
wp_enqueue_script('jquery-ui-droppable');
|
||||
wp_enqueue_script('jquery-ui-sortable');
|
||||
|
||||
wp_enqueue_script('wptm-iris', plugins_url('assets/js/iris.min.js',__FILE__) , array( 'jquery-ui-draggable', 'jquery-ui-slider', 'jquery-touch-punch' ), false,1 );
|
||||
wp_enqueue_script('wptm-color-picker', admin_url('js/color-picker.min.js'), array( 'wptm-iris'), false,1 );
|
||||
wp_localize_script( 'wptm-color-picker', 'wpColorPickerL10n', array(
|
||||
'clear' => __( 'Clear', 'wp-smart-editor' ),
|
||||
'defaultString' => __( 'Default', 'wp-smart-editor'),
|
||||
'pick' => __( 'Select Color' , 'wp-smart-editor'),
|
||||
'current' => __( 'Current Color' , 'wp-smart-editor'),
|
||||
) );
|
||||
wp_enqueue_style( 'wp-color-picker' );
|
||||
|
||||
wp_enqueue_script('wptm-bootstrap',plugins_url('assets/js/bootstrap.min.js',__FILE__), array(), WPTML_VERSION);
|
||||
wp_enqueue_style('wptm-bootstrap',plugins_url('assets/css/bootstrap.min.css',__FILE__), array(), WPTML_VERSION);
|
||||
|
||||
wp_enqueue_script('wptm-touch-punch',plugins_url('assets/js/jquery.ui.touch-punch.min.js',__FILE__), array(), WPTML_VERSION);
|
||||
|
||||
wp_enqueue_style('buttons');
|
||||
wp_enqueue_style('wp-admin');
|
||||
wp_enqueue_style('colors-fresh');
|
||||
|
||||
wp_enqueue_script( 'thickbox' );
|
||||
wp_enqueue_style( 'thickbox' );
|
||||
|
||||
wp_enqueue_style('wptm-style',plugins_url('assets/css/style.css',__FILE__), array(), WPTML_VERSION);
|
||||
wp_enqueue_style('wptm-table-sprites',plugins_url('assets/css/table-sprites.css',__FILE__, array(), WPTML_VERSION));
|
||||
wp_enqueue_style('wptm-handsontable',plugins_url('assets/css/jquery.handsontable.full.css',__FILE__), array(), WPTML_VERSION);
|
||||
wp_enqueue_style('wptm-modal',plugins_url('assets/css/leanmodal.css',__FILE__));
|
||||
wp_enqueue_script('wptm-modal',plugins_url('assets/js/jquery.leanModal.min.js',__FILE__));
|
||||
wp_enqueue_script('less',plugins_url('assets/js/less.js',__FILE__), array(), WPTML_VERSION);
|
||||
wp_enqueue_script('handsontable',plugins_url('assets/js/jquery.handsontable.full.js',__FILE__), array(), WPTML_VERSION);
|
||||
wp_enqueue_script('jquery-textselect',plugins_url('assets/js/jquery.textselect.min.js',__FILE__), array(), WPTML_VERSION);
|
||||
if(!Utilities::getInput('noheader', 'GET', 'bool')){
|
||||
wp_enqueue_script('jquery-nestable',plugins_url('assets/js/jquery.nestable.js',__FILE__), array(), WPTML_VERSION);
|
||||
}
|
||||
wp_enqueue_script('wptm-bootbox',plugins_url('assets/js/bootbox.js',__FILE__), array(), WPTML_VERSION );
|
||||
if($page=='wptm') {
|
||||
wp_enqueue_script('wptm-main',plugins_url('assets/js/wptm.js',__FILE__), array(), WPTML_VERSION);
|
||||
}
|
||||
|
||||
wp_enqueue_script('wptm-handlebars', plugins_url( 'assets/js/handlebars-1.0.0-rc.3.js' , __FILE__ ), array(), WPTML_VERSION);
|
||||
wp_enqueue_script('dropzone',plugins_url('assets/js/dropzone.min.js',__FILE__), array(), WPTML_VERSION);
|
||||
|
||||
if(Utilities::getInput('noheader', 'GET', 'bool')){
|
||||
//remove script loaded in bottom of page
|
||||
wp_dequeue_script( 'sitepress-scripts' );
|
||||
wp_dequeue_script( 'wpml-tm-scripts' );
|
||||
}
|
||||
|
||||
wp_enqueue_media();
|
||||
add_filter('tiny_mce_before_init', 'wptm_tiny_mce_before_init'); // Before tinymce initialization
|
||||
add_filter('mce_external_plugins', 'wptm_mce_external_plugins' );
|
||||
add_editor_style( WP_TABLE_MANAGER_LIGHT_PLUGIN_URL . '/app/admin/assets/css/wptm-editor-style.css' );
|
||||
}
|
||||
|
||||
function wptm_button($context){
|
||||
wp_enqueue_style('wptm-modal',plugins_url('assets/css/leanmodal.css',__FILE__));
|
||||
wp_enqueue_script('wptm-modal',plugins_url('assets/js/jquery.leanModal.min.js',__FILE__));
|
||||
wp_enqueue_script('wptm-modal-init',plugins_url('assets/js/leanmodal.init.js',__FILE__));
|
||||
|
||||
$context .= "<a href='#wptmmodal' class='button wptmlaunch' id='wptmlaunch' title='WP Table Manager'>"
|
||||
. " <span class='dashicons dashicons-screenoptions' style='line-height: inherit;'></span>WP Table Manager</a>";
|
||||
|
||||
return $context;
|
||||
}
|
||||
|
||||
function wptm_mce_external_plugins($plugins) {
|
||||
$plugins['code'] = WP_TABLE_MANAGER_LIGHT_PLUGIN_URL . '/app/admin/assets/plugins/code/plugin.min.js';
|
||||
$plugins['wpmedia'] = WP_TABLE_MANAGER_LIGHT_PLUGIN_URL . '/app/admin/assets/plugins/wpmedia/plugin.js';
|
||||
return $plugins;
|
||||
}
|
||||
|
||||
function wptm_tiny_mce_before_init($init) {
|
||||
// Initialize table ability
|
||||
if (isset($init['tools'])) {
|
||||
$init['tools'] = $init['tools'].',inserttable';
|
||||
} else {
|
||||
$init['tools'] = 'inserttable';
|
||||
}
|
||||
|
||||
if (isset($init['toolbar2'])) {
|
||||
$init['toolbar2'] = $init['toolbar2'].',code,wpmedia';
|
||||
}else {
|
||||
$init['toolbar1'] = $init['toolbar1'].',code,wpmedia';
|
||||
}
|
||||
$init['height'] = "500";
|
||||
|
||||
return $init;
|
||||
}
|
||||
|
||||
function wptm_folderTree() {
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
function wptm_foldertree_thickbox() {
|
||||
if(!defined('IFRAME_REQUEST')) {
|
||||
define('IFRAME_REQUEST',true);
|
||||
}
|
||||
iframe_header();
|
||||
global $wp_scripts, $wp_styles;
|
||||
|
||||
wp_enqueue_script('wptm-jaofiletree',plugins_url('assets/js/jaofiletree.js',__FILE__), array(), WPTML_VERSION );
|
||||
wp_enqueue_style('wptm-jaofiletree',plugins_url('assets/css/jaofiletree.css',__FILE__), array(), WPTML_VERSION);
|
||||
|
||||
//$include_folders = 'wp-content/uploads';
|
||||
//$selected_folders = explode(',',$include_folders );
|
||||
?>
|
||||
<div style="padding-top: 10px;">
|
||||
<div class="pull-left" style="float: left">
|
||||
<div id="wptm_foldertree"></div>
|
||||
</div>
|
||||
<div class="pull-right" style="float: right;margin-right: 10px;">
|
||||
<button class="button button-primary" type="button" onclick="selectFile()"><?php echo __('OK', 'wp-smart-editor') ?></button>
|
||||
<button class="button" type="button" onclick="window.parent.tb_remove();"><?php echo __('Cancel', 'wp-smart-editor') ?></button>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
|
||||
#wptm_foldertree input[type="checkbox"] {
|
||||
width: 16px;
|
||||
height:16px;
|
||||
}
|
||||
#wptm_foldertree input[type="checkbox"]:checked:before {
|
||||
font-size: 20px;
|
||||
line-height: 20px;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
|
||||
jQuery(document).ready(function($) {
|
||||
wptm_site_url ='<?php echo get_site_url();?>';
|
||||
selectFile = function() {
|
||||
selected_file = "";
|
||||
$('#wptm_foldertree').find('input:checked + a').each(function(){
|
||||
selected_file = $(this).attr('data-file');
|
||||
})
|
||||
|
||||
window.parent.document.getElementById('jform_spreadsheet_url').value = wptm_site_url + selected_file;
|
||||
window.parent.jQuery("#jform_spreadsheet_url").change();
|
||||
window.parent.tb_remove();
|
||||
}
|
||||
|
||||
|
||||
$('#wptm_foldertree').jaofiletree({
|
||||
script : ajaxurl ,
|
||||
usecheckboxes : 'files',
|
||||
showroot : '/',
|
||||
oncheck: function(elem,checked,type,file){
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
})
|
||||
</script>
|
||||
<?php
|
||||
iframe_footer();
|
||||
exit; //Die to prevent the page continueing loading and adding the admin menu's etc.
|
||||
}
|
||||
function wptm_getFolders() {
|
||||
|
||||
//$include_folders = 'wp-content/uploads';
|
||||
// $selected_folders = explode(',', $include_folders);
|
||||
$path = ABSPATH.DIRECTORY_SEPARATOR;
|
||||
$dir = $_REQUEST['dir'];
|
||||
$allowed_ext = array('xls','xlsx');
|
||||
$return = $dirs = $fi = array();
|
||||
if( file_exists($path.$dir) ) {
|
||||
$files = scandir($path.$dir);
|
||||
|
||||
natcasesort($files);
|
||||
if( count($files) > 2 ) { // The 2 counts for . and ..
|
||||
// All dirs
|
||||
$baseDir = ltrim(rtrim(str_replace(DIRECTORY_SEPARATOR, '/', $dir),'/'),'/');
|
||||
if($baseDir != '') $baseDir .= '/';
|
||||
foreach( $files as $file ) {
|
||||
if( file_exists($path . $dir . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..' && is_dir($path . $dir. DIRECTORY_SEPARATOR . $file) ) {
|
||||
$dirs[] = array('type'=>'dir','dir'=>$dir,'file'=>$file);
|
||||
}elseif( file_exists($path . $dir . DIRECTORY_SEPARATOR . $file) && $file != '.' && $file != '..' && !is_dir($path . $dir . DIRECTORY_SEPARATOR . $file) ) {
|
||||
$dot = strrpos($file, '.') + 1;
|
||||
$file_ext = strtolower( substr($file, $dot) ); //var_dump($file_ext);
|
||||
if( in_array($file_ext, $allowed_ext) ) {
|
||||
$fi[] = array('type'=>'file','dir'=>$dir,'file'=>$file,'ext'=>$file_ext);
|
||||
}
|
||||
}
|
||||
}
|
||||
$return = array_merge($dirs,$fi);
|
||||
}
|
||||
}
|
||||
echo json_encode( $return );
|
||||
die();
|
||||
}
|
||||
@@ -0,0 +1,254 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelCategories extends Model {
|
||||
|
||||
|
||||
public function getCategories() {
|
||||
global $wpdb;
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_categories as c WHERE c.level >0 ORDER BY c.lft ASC';
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
return stripslashes_deep($wpdb->get_results($query,OBJECT));
|
||||
}
|
||||
|
||||
public function delete($nodeId){
|
||||
global $wpdb;
|
||||
$wpdb->query('START TRANSACTION');
|
||||
if(!$this->_delete($nodeId)){
|
||||
$wpdb->query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
$wpdb->query('COMMIT');
|
||||
return true;
|
||||
}
|
||||
|
||||
private function _delete($nodeId){
|
||||
global $wpdb;
|
||||
$query = 'SELECT rgt,lft,level FROM '.$wpdb->prefix.'wptm_categories WHERE id='.(int)$nodeId;
|
||||
$nodeInfos = $wpdb->get_row($query);
|
||||
if($nodeInfos===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$width = $nodeInfos->rgt - $nodeInfos->lft + 1;
|
||||
|
||||
//Delete node
|
||||
$query = 'DELETE FROM '.$wpdb->prefix.'wptm_categories WHERE
|
||||
lft >= '.$nodeInfos->lft.' AND
|
||||
rgt <= '.$nodeInfos->rgt;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Update right brothers
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
lft = lft - '.$width.',
|
||||
rgt = rgt - '.$width.'
|
||||
WHERE
|
||||
lft > '.$nodeInfos->rgt.' AND
|
||||
rgt > '.$nodeInfos->rgt;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Update parents
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
|
||||
rgt = rgt - '.$width.'
|
||||
WHERE
|
||||
lft < '.$nodeInfos->lft.' AND
|
||||
rgt > '.$nodeInfos->rgt;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global type $wpdb
|
||||
* @param int $nodeTo id to the reference node
|
||||
* @param array $nodes array of nodes to insert ordered by left asc
|
||||
* @param type $where
|
||||
* @return boolean
|
||||
*/
|
||||
private function _insert($nodeTo,$nodes,$where='first-child',$refInfos=null){
|
||||
global $wpdb;
|
||||
$query = 'SELECT rgt,lft,level,parent_id FROM '.$wpdb->prefix.'wptm_categories WHERE id='.(int)$nodeTo;
|
||||
$nodeToInfos = $wpdb->get_row($query);
|
||||
if($nodeToInfos===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
//Get the node width
|
||||
$maxRgt = 0;
|
||||
$minLft = $nodes[0]->lft;
|
||||
foreach ($nodes as $node) {
|
||||
$minLft = min($node->lft, $minLft);
|
||||
$maxRgt = max($node->rgt, $maxRgt);
|
||||
}
|
||||
$width = $maxRgt - $minLft +1;
|
||||
|
||||
//Update parents
|
||||
if($where=='first-child'){
|
||||
//Update right brothers
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
lft = lft + '.$width.',
|
||||
rgt = rgt + '.$width.'
|
||||
WHERE
|
||||
lft > '.$nodeToInfos->lft.' AND
|
||||
rgt > '.$nodeToInfos->lft;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
//insert at first position
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
|
||||
rgt = rgt + '.$width.'
|
||||
WHERE
|
||||
lft <= '.$nodeToInfos->lft.' AND
|
||||
rgt >= '.$nodeToInfos->rgt;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
//new position left
|
||||
$leftTo = $nodeToInfos->lft+1;
|
||||
$diffLevel = $nodeToInfos->level + 1 - $nodes[0]->level;
|
||||
}else{
|
||||
//Update right brothers
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
lft = lft + '.$width.',
|
||||
rgt = rgt + '.$width.'
|
||||
WHERE
|
||||
lft > '.$nodeToInfos->rgt.' AND
|
||||
rgt > '.$nodeToInfos->rgt;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
//insert after element
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
|
||||
rgt = rgt + '.($width).'
|
||||
WHERE
|
||||
lft <= '.$nodeToInfos->lft.' AND
|
||||
rgt > '.$nodeToInfos->rgt;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
//new position left
|
||||
$leftTo = $nodeToInfos->rgt+1;
|
||||
$diffLevel = $nodeToInfos->level - $nodes[0]->level;
|
||||
}
|
||||
|
||||
$diff = $minLft;
|
||||
//prepare and insert old nodes
|
||||
foreach ($nodes as $NodeElement){
|
||||
$NodeElement->lft += $leftTo-$diff;
|
||||
$NodeElement->rgt += $leftTo-$diff;
|
||||
$NodeElement->level += $diffLevel;
|
||||
$keys = array();
|
||||
$values = array();
|
||||
foreach ($NodeElement as $key => $value){
|
||||
$keys[] = '`'.$key.'`';
|
||||
$values[] = '"'.addslashes($value).'"';
|
||||
}
|
||||
$query = 'INSERT INTO '.$wpdb->prefix.'wptm_categories ('.implode(',', $keys).') VALUES ('.implode(',',$values).')';
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//update parent value
|
||||
if($where=='first-child'){
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
parent_id = '.$refInfos->id.'
|
||||
WHERE
|
||||
id = '.(int)$nodes[0]->id;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
$query = 'UPDATE '.$wpdb->prefix.'wptm_categories SET
|
||||
parent_id = '.$refInfos->parent_id.'
|
||||
WHERE
|
||||
id = '.(int)$nodes[0]->id;
|
||||
if($wpdb->query($query)===false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function move($node,$ref,$position='first-child'){
|
||||
global $wpdb;
|
||||
$wpdb->query('START TRANSACTION');
|
||||
if(!$this->_move($node,$ref,$position)){
|
||||
$wpdb->query('ROLLBACK');
|
||||
return false;
|
||||
}
|
||||
$wpdb->query('COMMIT');
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Move a node $node to the $position of $ref element
|
||||
* @param int $node
|
||||
* @param int $ref
|
||||
* @param string $position
|
||||
*/
|
||||
private function _move($node,$ref,$position='first-child'){
|
||||
global $wpdb;
|
||||
|
||||
$query = 'SELECT rgt,lft,level FROM '.$wpdb->prefix.'wptm_categories WHERE id='.(int)$node;
|
||||
|
||||
$nodeInfos = $wpdb->get_row($query);
|
||||
if($nodeInfos===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = 'SELECT id,rgt,lft,level,parent_id FROM '.$wpdb->prefix.'wptm_categories WHERE ';
|
||||
if($ref=='0'){
|
||||
//case ROOT
|
||||
$query .= 'level=0 LIMIT 0,1';
|
||||
}else{
|
||||
$query .= 'id='.(int)$ref;
|
||||
}
|
||||
$refInfos = $wpdb->get_row($query);
|
||||
if($refInfos===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
$query = 'SELECT * FROM '.$wpdb->prefix.'wptm_categories WHERE lft >= '.(int)$nodeInfos->lft.' AND rgt <= '.(int)$nodeInfos->rgt.' ORDER BY lft ASC';
|
||||
$nodes = $wpdb->get_results($query);
|
||||
if($nodes===false){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!$this->_delete($node)){
|
||||
return false;
|
||||
}
|
||||
if(!$this->_insert($ref,$nodes,$position,$refInfos)){
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelCategory extends Model {
|
||||
|
||||
function isCategoryExist($id_category) {
|
||||
global $wpdb;
|
||||
$query = 'SELECT c.id FROM '.$wpdb->prefix.'wptm_categories as c WHERE c.id='.(int)$id_category;
|
||||
$result = $wpdb->query($query);
|
||||
if(!$result){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
use Joomunited\WPFramework\v1_0_4\Factory;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelConfig extends Model {
|
||||
|
||||
public function getConfig(){
|
||||
|
||||
$defaultConfig = array('enable_import_excel'=>1,'export_excel_format'=>'xlsx','enable_tooltip'=> 0, 'enable_autosave'=> 1, 'sync_periodicity' => 0 ,'enable_frontend'=>0);
|
||||
$config = (array)get_option('_wptm_global_config', $defaultConfig);
|
||||
$config = array_merge($defaultConfig, $config);
|
||||
|
||||
return $config;
|
||||
}
|
||||
|
||||
public function save($datas){
|
||||
$config = get_option('_wptm_global_config');
|
||||
foreach ($datas as $key => $value) {
|
||||
$config[$key]= $value;
|
||||
}
|
||||
|
||||
$result = update_option('_wptm_global_config', $config);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelStyle extends Model {
|
||||
|
||||
public function getItem($id) {
|
||||
global $wpdb;
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_styles as c WHERE c.id='.(int)$id;
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
return stripslashes_deep($wpdb->get_row($query,OBJECT));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelStyles extends Model {
|
||||
|
||||
|
||||
public function getStyles() {
|
||||
global $wpdb;
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_styles as c ORDER BY c.ordering ASC';
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
return stripslashes_deep($wpdb->get_results($query,OBJECT));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelTable extends Model {
|
||||
|
||||
public function save($id_table,$datas) {
|
||||
global $wpdb;
|
||||
$hash = md5($datas['style'].$datas['css']);
|
||||
|
||||
if(empty($datas['datas']) ) {
|
||||
$result = $wpdb->update( $wpdb->prefix."wptm_tables" ,
|
||||
array( 'style'=>$datas['style'],'css'=>$datas['css'],'hash'=> $hash ),
|
||||
array( 'ID' => (int)$id_table ) );
|
||||
}else {
|
||||
$result = $wpdb->update( $wpdb->prefix."wptm_tables" ,
|
||||
array( 'datas' => $datas['datas'],'style'=>$datas['style'],'css'=>$datas['css'],'hash'=> $hash, 'params'=>json_encode($datas['params']) ),
|
||||
array( 'ID' => (int)$id_table ) );
|
||||
}
|
||||
|
||||
|
||||
if($result===false) {
|
||||
echo $wpdb->last_query ;
|
||||
exit();
|
||||
}
|
||||
if($result==0) {
|
||||
$result = $id_table;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function add($id_category) {
|
||||
global $wpdb;
|
||||
|
||||
$query = 'SELECT MAX(c.position) AS lastPos FROM '.$wpdb->prefix.'wptm_tables as c WHERE c.id_category='.(int)$id_category;
|
||||
$lastPos = (int)$wpdb->get_var($query);
|
||||
$lastPos++;
|
||||
$wpdb->query( $wpdb->prepare(
|
||||
"
|
||||
INSERT INTO ".$wpdb->prefix."wptm_tables (id_category, title, created_time, modified_time, author, position) VALUES
|
||||
( %d,%s,%s,%s,%d,%d)
|
||||
",
|
||||
$id_category,__('New table','wp-smart-editor'),date("Y-m-d H:i:s"),date("Y-m-d H:i:s"),get_current_user_id(), $lastPos
|
||||
) );
|
||||
return $wpdb->insert_id;
|
||||
}
|
||||
public function copy($id_table) {
|
||||
global $wpdb;
|
||||
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_tables as c WHERE c.id='.(int)$id_table;
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
$table = $wpdb->get_row($query,OBJECT);
|
||||
$wpdb->query( $wpdb->prepare(
|
||||
"
|
||||
INSERT INTO ".$wpdb->prefix."wptm_tables (id_category, title,datas,style,css,hash,params,created_time, modified_time, author, position) VALUES
|
||||
( %d,%s,%s,%s,%s,%s,%s,%s,%s,%d,%d)
|
||||
",
|
||||
$table->id_category,$table->title. __(" (copy)", 'wp-smart-editor'),$table->datas,$table->style,$table->css,$table->hash,$table->params,date("Y-m-d H:i:s"),date("Y-m-d H:i:s"),get_current_user_id(),$table->position
|
||||
) );
|
||||
return $wpdb->insert_id;
|
||||
}
|
||||
public function delete($id) {
|
||||
global $wpdb;
|
||||
$result = $wpdb->delete( $wpdb->prefix."wptm_tables" , array( 'id' => (int)$id ) );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setTitle($id, $title) {
|
||||
global $wpdb;
|
||||
$result = $wpdb->update( $wpdb->prefix."wptm_tables" , array( 'title' => $title ), array( 'id' => (int)$id ) );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function getItem($id) {
|
||||
global $wpdb;
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_tables as c WHERE c.id='.(int)$id;
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
$item = $wpdb->get_row($query,OBJECT);
|
||||
|
||||
$item->params = str_replace(array("\n\r","\r\n", "\n", "\r", " "), " ",$item->params );
|
||||
$params = json_decode( $item->params);
|
||||
if (!isset($params->query)){
|
||||
$params->query = '';
|
||||
}
|
||||
$item->params = $params;
|
||||
$params->query = str_replace(array("\n\r","\r\n", "\n", "\r", " "), " ",$params->query );
|
||||
if( $params->query) {
|
||||
$tableData = $this->getTableData($params->query . " Limit 50");
|
||||
$cols = array_keys($tableData[0] );
|
||||
$headerCols = array();
|
||||
$i= 0;
|
||||
foreach ($cols as $col) {
|
||||
$headerCols[$col] = $params->custom_titles[$i];
|
||||
$i++;
|
||||
}
|
||||
array_unshift($tableData, $headerCols);
|
||||
$item->datas = json_encode($tableData);
|
||||
$item->query = $params->query;
|
||||
}
|
||||
return stripslashes_deep($item);
|
||||
}
|
||||
|
||||
public function setPosition($tables) {
|
||||
global $wpdb;
|
||||
$i = 1;
|
||||
$ids = explode(",",$tables);
|
||||
foreach ($ids as $id) {
|
||||
$result = $wpdb->update( $wpdb->prefix."wptm_tables" , array( 'position' => $i ), array( 'id' => (int)$id ) );
|
||||
$i++;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function setCategory($id,$category) {
|
||||
global $wpdb;
|
||||
$result = $wpdb->update( $wpdb->prefix."wptm_tables" , array( 'id_category' => $category, 'position' => 0 ), array( 'id' => (int)$id ) );
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
// get result data of build query
|
||||
public function getTableData($query) {
|
||||
global $wpdb;
|
||||
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
return $wpdb->get_results($query, ARRAY_A);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmModelTables extends Model {
|
||||
|
||||
|
||||
public function getItems() {
|
||||
global $wpdb;
|
||||
$show_all = true;
|
||||
$user_id = get_current_user_id();
|
||||
if (!user_can($user_id, 'edit_others_posts')) {
|
||||
$show_all = false;
|
||||
}
|
||||
|
||||
if($show_all) {
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_tables as c ORDER BY c.id_category ASC, c.position ASC ';
|
||||
}else {
|
||||
$query = 'SELECT c.* FROM '.$wpdb->prefix.'wptm_tables as c WHERE c.author = '.$user_id.' ORDER BY c.id_category ASC, c.position ASC ';
|
||||
}
|
||||
$result = $wpdb->query($query);
|
||||
if($result===false){
|
||||
return false;
|
||||
}
|
||||
return stripslashes_deep($wpdb->get_results($query,OBJECT));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmViewStyle extends View {
|
||||
public function render($tpl = null) {
|
||||
|
||||
$id= Utilities::getInt('id');
|
||||
$model = $this->getModel('style');
|
||||
$item = $model->getItem($id);
|
||||
header("Content-Type: application/json; charset=utf-8", true);
|
||||
echo json_encode($item);
|
||||
die();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Factory;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
// No direct access.
|
||||
defined( 'ABSPATH' ) || die();
|
||||
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmViewTable extends View {
|
||||
public function render($tpl = null) {
|
||||
|
||||
$id= Utilities::getInt('id');
|
||||
$model = $this->getModel('table');
|
||||
$item = $model->getItem($id);
|
||||
echo json_encode($item);
|
||||
die();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0W
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\Factory;
|
||||
use Joomunited\WPFramework\v1_0_4\Utilities;
|
||||
use Joomunited\WPFramework\v1_0_4\Model;
|
||||
|
||||
// No direct access.
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
wp_localize_script('wptm-main','wptmText',array(
|
||||
'Delete'=>__('Delete','wp-smart-editor'),
|
||||
'Edit'=>__('Edit','wp-smart-editor'),
|
||||
'Cancel'=>__('Cancel','wp-smart-editor'),
|
||||
'Ok'=>__('Ok','wp-smart-editor'),
|
||||
'Confirm'=>__('Confirm','wp-smart-editor'),
|
||||
'Save'=>__('Save','wp-smart-editor'),
|
||||
'GOT_IT'=>__('Got it!','wp-smart-editor'),
|
||||
'LAYOUT_WPTM_SELECT_ONE' => __('Please select a table a create a new one', 'wp-smart-editor') ,
|
||||
'VIEW_WPTM_TABLE_ADD' => __('Add new table', 'wp-smart-editor') ,
|
||||
'JS_WANT_DELETE' => __('Do you really want to delete ', 'wp-smart-editor') ,
|
||||
'CHANGE_INVALID_CHART_DATA' => __('Invalid chart data', 'wp-smart-editor') ,
|
||||
'CHART_INVALID_DATA'=>__('Invalid data, please make a new data range selection with at least one row or column with only numeric data, thanks!','wp-smart-editor'),
|
||||
'CHOOSE_EXCEL_FIE_TYPE' => __('Please choose a file with type of xls or xlsx.', 'wp-smart-editor') ,
|
||||
'WARNING_CHANGE_THEME' => __('Warning - all data and styles will be removed & replaced on theme switch', 'wp-smart-editor') ,
|
||||
'Your browser does not support HTML5 file uploads'=>__('Your browser does not support HTML5 file uploads','wp-smart-editor'),
|
||||
'Too many files'=>__('Too many files','wp-smart-editor'),
|
||||
'is too large'=>__('is too large','wp-smart-editor'),
|
||||
'Only images are allowed'=>__('Only images are allowed','wp-smart-editor'),
|
||||
'Do you want to delete "'=>__('Do you want to delete "','wp-smart-editor'),
|
||||
'Select files'=>__('Select files','wp-smart-editor'),
|
||||
'Image parameters'=>__('Image parameters','wp-smart-editor'),
|
||||
'notice_msg_table_syncable'=>__('This spreadsheet is currently sync with an external file, you may lose content in case of modification','wp-smart-editor'),
|
||||
'notice_msg_table_database'=>__('Table data are from database, only the 50 first rows are displayed for performance reason.','wp-smart-editor'),
|
||||
|
||||
));
|
||||
wp_localize_script('wptm-bootbox','wptmCmd',array(
|
||||
'Delete'=>__('Delete','wp-smart-editor'),
|
||||
'Edit'=>__('Edit','wp-smart-editor'),
|
||||
'CANCEL'=>__('Cancel','wp-smart-editor'),
|
||||
'OK'=>__('Ok','wp-smart-editor'),
|
||||
'CONFIRM'=>__('Confirm','wp-smart-editor'),
|
||||
'Save'=>__('Save','wp-smart-editor'),
|
||||
));
|
||||
|
||||
if (isset($_GET['noheader'])){
|
||||
global $hook_suffix;
|
||||
_wp_admin_html_begin();
|
||||
do_action( 'admin_enqueue_scripts', $hook_suffix );
|
||||
do_action( "admin_print_scripts-$hook_suffix" );
|
||||
do_action( 'admin_print_scripts' );
|
||||
}
|
||||
|
||||
$alone = '';
|
||||
|
||||
$editor_id = 'wptmditor';
|
||||
$editor_args = array(
|
||||
'tabfocus_elements' => 'content-html,save-post',
|
||||
'quicktags' => true,
|
||||
'media_buttons' => false,
|
||||
'editor_height' => 400,
|
||||
'tinymce' => array(
|
||||
'resize' => true,
|
||||
'wp_autoresize_on' => true,
|
||||
'add_unload_trigger' => false
|
||||
)
|
||||
);
|
||||
wp_editor( '<p></p><p></p>', $editor_id,$editor_args );
|
||||
|
||||
|
||||
$editor_args1 = $editor_args;
|
||||
$editor_args1['quicktags'] = false;
|
||||
$editor_args1['tinymce'] = array(
|
||||
'setup' => 'function (ed) {
|
||||
ed.on("keyup", function (e) {
|
||||
// ed.save();
|
||||
//wptm_tooltipChange();
|
||||
|
||||
});
|
||||
ed.on("change", function(e) {
|
||||
// ed.save();
|
||||
//wptm_tooltipChange();
|
||||
});
|
||||
}',
|
||||
);
|
||||
wp_editor('', 'wptm_tooltip', $editor_args1);
|
||||
?>
|
||||
<style>
|
||||
#wp-wptmditor-wrap, #wp-wptm_tooltip-wrap { display: none}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>';
|
||||
wptm_ajaxurl = "<?php echo Factory::getApplication('wptm')->getAjaxUrl(); ?>";
|
||||
wptm_dir = "<?php echo Factory::getApplication('wptm')->getBaseUrl(); ?>";
|
||||
<?php if(Utilities::getInput('caninsert','GET','bool')): ?>
|
||||
gcaninsert=true;
|
||||
<?php $alone = 'wptmalone wp-core-ui '; ?>
|
||||
<?php else: ?>
|
||||
gcaninsert=false;
|
||||
<?php endif; ?>
|
||||
|
||||
var Wptm = {};
|
||||
if(typeof(addLoadEvent)==='undefined'){addLoadEvent = function(func){if(typeof jQuery!="undefined")jQuery(document).ready(func);else if(typeof wpOnload!='function'){wpOnload=func;}else{var oldonload=wpOnload;wpOnload=function(){oldonload();func();}}};};
|
||||
</script>
|
||||
<style>
|
||||
<?php if(Utilities::getInput('caninsert','GET','bool')): ?>
|
||||
html.wp-toolbar {padding-top: 0 !important}
|
||||
<?php endif; ?>
|
||||
</style>
|
||||
<div id="mybootstrap" class="<?php echo $alone; ?>">
|
||||
|
||||
<div id="mycategories">
|
||||
<div class="categories-toggle" id="cats-toggle"><span class="dashicons-before dashicons-arrow-left-alt"></span></div>
|
||||
|
||||
<div class="nested dd">
|
||||
<ol id="categorieslist" class="dd-list nav bs-docs-sidenav2 ">
|
||||
<?php if(!empty($this->categories)){
|
||||
$content = '';
|
||||
$previouslevel = 1;
|
||||
for ($index = 0; $index < count($this->categories); $index++) {
|
||||
if($index+1!=count($this->categories)){
|
||||
$nextlevel = $this->categories[$index+1]->level;
|
||||
}else{
|
||||
$nextlevel = 0;
|
||||
}
|
||||
$content .= openItem($this->categories[$index],$index);
|
||||
$content .= '<ul class="wptm-tables-list">';
|
||||
if($this->categories[$index]->id == $this->dbtable_cat) {
|
||||
$tableType = 'mysql';
|
||||
}else {
|
||||
$tableType = '';
|
||||
}
|
||||
if(isset($this->tables[$this->categories[$index]->id])){
|
||||
foreach ($this->tables[$this->categories[$index]->id] as $table) {
|
||||
$content .= '<li class="wptmtable" data-id-table="'.$table->id.'" data-table-type="'.$tableType.'">';
|
||||
$content .= '<a href="#"><i class="icon-database"></i> <span class="title">'.$table->title.'</span></a>';
|
||||
$content .= ' <a class="edit"><i class="icon-edit"></i></a>';
|
||||
$content .= ' <a class="copy"><i class="icon-copy"></i></a>';
|
||||
$content .= ' <a class="trash"><i class="icon-trash"></i></a>';
|
||||
$content .= '</li>';
|
||||
}
|
||||
}
|
||||
if($tableType != 'mysql') {
|
||||
$content .= '<li><a class="newTable" href="#"><i class="dashicons dashicons-plus-alt"></i> '. __('New table','wp-smart-editor').'</a></li>';
|
||||
}
|
||||
$content .= '</ul>';
|
||||
|
||||
if($nextlevel>$this->categories[$index]->level){
|
||||
$content .= openlist($this->categories[$index]);
|
||||
}elseif($nextlevel==$this->categories[$index]->level){
|
||||
$content .= closeItem($this->categories[$index]);
|
||||
}else{
|
||||
$c = '';
|
||||
$c .= closeItem($this->categories[$index]);
|
||||
$c .= closeList($this->categories[$index]);
|
||||
$content .= str_repeat($c,$this->categories[$index]->level-$nextlevel);
|
||||
}
|
||||
$previouslevel = $this->categories[$index]->level;
|
||||
}
|
||||
}
|
||||
if (!isset($content))
|
||||
{
|
||||
$content ='';
|
||||
}
|
||||
echo $content;
|
||||
?>
|
||||
</ol>
|
||||
<input type="hidden" id="categoryToken" name="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="rightcol" class="">
|
||||
<?php if(Utilities::getInput('caninsert', 'GET', 'bool')): ?>
|
||||
<a id="inserttable" class="button button-primary button-big" href="javascript:void(0)" onclick="if (window.parent) insertTable();"><?php _e('Insert this table','wp-smart-editor'); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if(isset($this->params['enable_autosave']) && $this->params['enable_autosave'] == '0'): ?>
|
||||
<div class="control-group">
|
||||
<label id="jform_saveTable-lbl">
|
||||
<a id="saveTable" class="button button-primary button-big" title="<?php _e('Save modifications','wp-smart-editor'); ?>" ><?php _e('Save modifications','wp-smart-editor');?></a>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div>
|
||||
<ul class="nav nav-tabs" id="configTable">
|
||||
<li class="referCell"><a data-toggle="tab" href="#cell"><?php _e('Format','wp-smart-editor'); ?></a></li>
|
||||
</ul>
|
||||
<div class="tab-content" id="tableTabContent">
|
||||
<!-- Cell -->
|
||||
<div id="cell" class="tab-pane ">
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label id="jform_cell_type-lbl" for="jform_cell_type">
|
||||
<?php _e('Cell type','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<select class="chzn-select observeChanges" name="jform[jform_cell_type]" id="jform_cell_type">
|
||||
<option value=""><?php _e('Default','wp-smart-editor');?></option>
|
||||
<option value="html"><?php _e('Html','wp-smart-editor');?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label id="jform_cell_background_color-lbl" for="jform_cell_background_color">
|
||||
<?php _e('Cell background color','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input class="minicolors minicolors-input observeChanges" data-position="left" data-control="hue" type="text" name="jform[jform_cell_background_color]" id="jform_cell_background_color" value="" size="7" />
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label id="jform_cell_border_type-lbl" for="jform_cell_border_type">
|
||||
<?php _e('Borders','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="clr"></div>
|
||||
<div class="controls">
|
||||
<div>
|
||||
<select class="chzn-select" name="jform[jform_cell_border_type]" id="jform_cell_border_type">
|
||||
<option value="solid"><?php _e('Solid','wp-smart-editor');?></option>
|
||||
<option value="dashed"><?php _e('Dashed','wp-smart-editor');?></option>
|
||||
<option value="dotted"><?php _e('Dotted','wp-smart-editor');?></option>
|
||||
<option value="none"><?php _e('No border','wp-smart-editor');?></option>
|
||||
</select>
|
||||
<div class="form-inline">
|
||||
<div class="input-append">
|
||||
<input type="text" name="jform[jform_cell_border_width]" id="jform_cell_border_width" value="1"/>
|
||||
<button class="btn" type="button" id="cell_border_width_incr">+</button>
|
||||
<button class="btn" type="button" id="cell_border_width_decr">-</button>
|
||||
</div>
|
||||
</div>
|
||||
<input class="minicolors minicolors-input observeChanges" data-position="left" data-control="hue" type="text" name="jform[jform_cell_border_color]" id="jform_cell_border_color" value="#CCCCCC" size="7" />
|
||||
</div>
|
||||
<div class="aglobuttons">
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_top]" type="button"><span class="sprite sprite_border_top"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_right]" type="button"><span class="sprite sprite_border_right"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_bottom]" type="button"><span class="sprite sprite_border_bottom"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_left]" type="button"><span class="sprite sprite_border_left"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_all]" type="button"><span class="sprite sprite_border_all"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_inside]" type="button"><span class="sprite sprite_border_inside"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_outline]" type="button"><span class="sprite sprite_border_outline"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_horizontal]" type="button"><span class="sprite sprite_border_horizontal"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_vertical]" type="button"><span class="sprite sprite_border_vertical"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_border_remove]" type="button"><span class="sprite sprite_border_remove"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label id="jform_cell_font_family-lbl" for="jform_cell_font_family">
|
||||
<?php _e('Font','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<select class="chzn-select observeChanges" name="jform[jform_cell_font_family]" id="jform_cell_font_family">
|
||||
<option value="Arial">Arial</option>
|
||||
<option value="Arial Black">Arial Black</option>
|
||||
<option value="Comic Sans MS">Comic Sans MS</option>
|
||||
<option value="Courier New">Courier New</option>
|
||||
<option value="Georgia">Georgia</option>
|
||||
<option value="Impact">Impact</option>
|
||||
<option value="Times New Roman">Times New Roman</option>
|
||||
<option value="Trebuchet MS">Trebuchet MS</option>
|
||||
<option value="Verdana">Verdana</option>
|
||||
</select>
|
||||
<div class="form-inline">
|
||||
<div class="input-append">
|
||||
<input class="observeChanges" type="text" name="jform[jform_cell_font_size]" id="jform_cell_font_size" value="13"/>
|
||||
<button class="btn" type="button" id="cell_font_size_incr">+</button>
|
||||
<button class="btn" type="button" id="cell_font_size_decr">-</button>
|
||||
</div>
|
||||
</div>
|
||||
<input class="minicolors minicolors-input observeChanges" data-position="left" data-control="hue" type="text" name="jform[jform_cell_font_color]" id="jform_cell_font_color" value="#000000" size="7" />
|
||||
<div class="aglobuttons">
|
||||
<button class="btn observeChanges" name="jform[jform_cell_font_bold]" type="button"><span class="sprite sprite_text_bold"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_font_underline]" type="button"><span class="sprite sprite_text_underline"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_font_italic]" type="button"><span class="sprite sprite_text_italic"></span></button>
|
||||
<br/>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_align_left]" type="button"><span class="sprite sprite_text_align_left"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_align_center]" type="button"><span class="sprite sprite_text_align_center"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_align_right]" type="button"><span class="sprite sprite_text_align_right"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_align_justify]" type="button"><span class="sprite sprite_text_align_justify"></span></button>
|
||||
<br/>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_vertical_align_top]" type="button"><span class="sprite sprite_vertical_align_top"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_vertical_align_middle]" type="button"><span class="sprite sprite_vertical_align_middle"></span></button>
|
||||
<button class="btn observeChanges" name="jform[jform_cell_vertical_align_bottom]" type="button"><span class="sprite sprite_vertical_align_bottom"></span></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<hr/>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label id="jform_row_height-lbl" for="jform_row_height">
|
||||
<?php _e('Row height','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input class="observeChanges input-mini" type="text" name="jform[jform_row_height]" id="jform_row_height" value="" size="7" />
|
||||
</div>
|
||||
<div class="control-label">
|
||||
<label id="jform_col_width-lbl" for="jform_col_width">
|
||||
<?php _e('Column width','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input class="observeChanges input-mini" type="text" name="jform[jform_col_width]" id="jform_col_width" value="" size="7" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if(isset($this->params['enable_tooltip']) && $this->params['enable_tooltip'] == '1'): ?>
|
||||
<div class="control-group">
|
||||
<label id="jform_tooltip_content-lbl" for="jform_tooltip_content">
|
||||
<a id="editToolTip" class="button button-primary button-big" title="<?php _e('Edit','wp-smart-editor'); ?>" href="#wptm_editToolTip"><?php _e('Edit Tooltip','wp-smart-editor');?></a>
|
||||
</label>
|
||||
|
||||
<div id="wptm_editToolTip" style="display:none">
|
||||
<div id="tooltip_editor">
|
||||
<textarea id="tooltip_content" name="tooltip_content" class="observeChanges"></textarea>
|
||||
<a id="saveToolTipbtn" class="button button-primary button-large" title="<?php _e('Save','wp-smart-editor'); ?>" href="javascript:void(0)"><?php _e('Save','wp-smart-editor');?></a>
|
||||
<a id="cancelToolTipbtn" class="button button-large" title="<?php _e('Cancel','wp-smart-editor'); ?>" href="javascript:void(0)"><?php _e('Cancel','wp-smart-editor');?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-label">
|
||||
<label id="jform_tooltip_width-lbl" for="jform_tooltip_width">
|
||||
<?php _e('Tooltip width (in px)','wp-smart-editor');?> :
|
||||
</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<input class="observeChanges input-mini" type="text" name="jform[jform_tooltip_width]" id="jform_tooltip_width" value="" size="7" />
|
||||
</div>
|
||||
</div>
|
||||
<?php endif ?>
|
||||
</div>
|
||||
<!-- More tab -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="pwrapper">
|
||||
<div id="wpreview">
|
||||
<div id="preview">
|
||||
<span id="savedInfo" style="display:none;"><?php _e('All modifications were saved','wp-smart-editor'); ?></span>
|
||||
<ul class="nav nav-tabs" id="mainTable">
|
||||
<li class="active"><a data-toggle="tab" href="#dataTable"><?php _e('Table','wp-smart-editor'); ?></a></li>
|
||||
</ul>
|
||||
<div id="mainTabContent" class="tab-content">
|
||||
<div id="dataTable" class="tab-pane active">
|
||||
<div>
|
||||
<h3 id="tableTitle"></h3>
|
||||
<div class="clearfix"></div>
|
||||
<div id="tableContainer" style="overflow:scroll;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="id_category" value="" />
|
||||
|
||||
<?php if (!isset($_COOKIE['WPTM_hide_upgrade'])) : ?>
|
||||
<div id="updateGroup">
|
||||
<div id="updateInfo">
|
||||
<p style="text-transform: uppercase; font-weight: bold; font-size: 16px"><?php _e('WP Table Manager Full Version', 'wp-smart-editor') ?></p>
|
||||
<p id="updateDesc"><?php _e('Save time using WP Table Manager full version to manage table themes, charts, cell tooltips, Excel Import/Export/Synchronization and many more ...', 'wp-smart-editor') ?></p>
|
||||
</div>
|
||||
<button type="button" class="updateHideBtn"><i class="dashicons dashicons-dismiss" ></i></button>
|
||||
<a class="updateBtn" href="https://www.joomunited.com/wordpress-products/wp-table-manager" target="_blank" title="<?php _e('WP Table Manager Full Version', 'wp-smart-editor') ?>"><?php _e('More Information','wp-smart-editor') ?></a>
|
||||
<a class="updateBtn updateHideTxt" href="#" onclick="return false" title="<?php _e('Hide','wp-smart-editor') ?>"><?php _e('Close Notification','wp-smart-editor') ?></a>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
var wptm_isAdmin = <?php echo (int)current_user_can( 'manage_options' ); ?>;
|
||||
jQuery(document).ready(function($) {
|
||||
var myOptions = {
|
||||
width: 220,
|
||||
// a callback to fire whenever the color changes to a valid color
|
||||
change: function(event, ui){
|
||||
|
||||
var hexcolor = $( this ).wpColorPicker( 'color' );
|
||||
$(event.target).val(hexcolor);
|
||||
$(event.target).trigger('change');
|
||||
}
|
||||
};
|
||||
|
||||
$('.minicolors').wpColorPicker(myOptions);
|
||||
});
|
||||
|
||||
var wptmChangeWait;
|
||||
function wptm_tooltipChange() {
|
||||
clearTimeout(wptmChangeWait);
|
||||
wptmChangeWait = setTimeout(function() {
|
||||
jQuery("#tooltip_content").trigger("change");
|
||||
}, 1000);
|
||||
}
|
||||
var enable_autosave = true;
|
||||
<?php if(isset($this->params['enable_autosave']) && $this->params['enable_autosave'] == '0'): ?>
|
||||
enable_autosave = false;
|
||||
<?php endif;?>
|
||||
|
||||
<?php
|
||||
$id_table = Utilities::getInt('id_table'); ?>
|
||||
var idTable = <?php echo $id_table;?> ;
|
||||
</script>
|
||||
|
||||
<?php
|
||||
function openItem($category,$key){
|
||||
return '<li class="dd-item dd3-item '.($key?'':'active').'" data-id-category="'.$category->id.'">';
|
||||
}
|
||||
|
||||
function closeItem($category){
|
||||
return '</li>';
|
||||
}
|
||||
|
||||
function itemContent($category){
|
||||
return '<div class="dd-handle dd3-handle"></div>
|
||||
<div class="dd-content dd3-content"
|
||||
<i class="icon-chevron-right"></i>
|
||||
<a class="edit"><i class="icon-edit"></i></a>
|
||||
<a href="" class="t">
|
||||
<span class="title">'.$category->title.'</span>
|
||||
</a>
|
||||
</div>';
|
||||
}
|
||||
|
||||
function openlist($category){
|
||||
return '<ol class="dd-list">';
|
||||
}
|
||||
|
||||
function closelist($category){
|
||||
return '</ol>';
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* WP Table Manager
|
||||
*
|
||||
* @package WP Table Manager
|
||||
* @author Joomunited
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
use Joomunited\WPFramework\v1_0_4\View;
|
||||
|
||||
defined( 'ABSPATH' ) || die();
|
||||
|
||||
class wptmViewWptm extends View {
|
||||
public function render($tpl = null) {
|
||||
$modelCat = $this->getModel('categories');
|
||||
$this->categories = $modelCat->getCategories();
|
||||
|
||||
$modelTables = $this->getModel('tables');
|
||||
$this->tables = $modelTables->getItems();
|
||||
require_once plugin_dir_path(WPTML_PLUGIN_FILE).DIRECTORY_SEPARATOR.'app'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.'helpers'.DIRECTORY_SEPARATOR.'tables.php';
|
||||
$this->tables = WptmTablesHelper::categoryObject($this->tables);
|
||||
|
||||
$modelStyles = $this->getModel('styles');
|
||||
$this->styles = $modelStyles->getStyles();
|
||||
|
||||
$modelConfig = $this->getModel('config');
|
||||
$this->params = $modelConfig->getConfig();
|
||||
|
||||
$this->dbtable_cat = (int)get_option('_wptm_dbtable_cat',0);
|
||||
|
||||
parent::render($tpl);
|
||||
}
|
||||
}
|
||||