first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

File diff suppressed because one or more lines are too long

View 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; }

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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;}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 703 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1 @@
<!DOCTYPE html><title></title>

Binary file not shown.

After

Width:  |  Height:  |  Size: 603 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 618 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 579 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 651 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 582 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 734 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 633 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 385 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 591 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 588 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 856 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 673 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 623 B

View 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'>&times;</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;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View 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);

View File

@@ -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 );

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
});

File diff suppressed because one or more lines are too long

View File

@@ -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})});

View File

@@ -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
};
});

View File

@@ -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 );
}
}
});
});