import from la bonne adresse and first refactoring for ouidade.com

This commit is contained in:
Bachir Soussi Chiadmi
2017-06-19 11:25:19 +02:00
commit 344dae1543
2240 changed files with 288691 additions and 0 deletions
@@ -0,0 +1,527 @@
var getState = function(){
var loadValues = [],
ignoreNames = ['page-filter', 'page-search'];
$('input, select, textarea').each(function(index, element){
var name = $(element).prop('name'),
value = $(element).val();
if (name && !~ignoreNames.indexOf(name)) loadValues.push(name + '|' + value);
});
return loadValues.toString();
};
var bytesToSize = function(bytes) {
var sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB'];
if (bytes == 0) return '0 Byte';
var i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)));
return Math.round(bytes / Math.pow(1024, i), 2) + ' ' + sizes[i];
};
var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
var keepAlive = function keepAlive() {
$.post(GravAdmin.config.base_url_relative + '/task' + GravAdmin.config.param_sep + 'keepAlive');
};
$(function () {
jQuery.substitute = function(str, sub) {
return str.replace(/\{(.+?)\}/g, function($0, $1) {
return $1 in sub ? sub[$1] : $0;
});
};
// // selectize
// $('select.fancy:not(.create)').selectize({
// createOnBlur: true,
// });
// // selectize with create
// $('select.fancy.create').selectize({
// createOnBlur: true,
// persist: false,
// create: function (input) {
// return {
// value: input,
// text: input
// }
// }
// });
// $('input.fancy').selectize({
// delimiter: ',',
// persist: false,
// create: function (input) {
// return {
// value: input,
// text: input
// }
// }
// });
// Set Toastr defaults
toastr.options = {
"positionClass": "toast-top-right"
}
// dashboard
var chart = $('.updates-chart'), UpdatesChart;
if (chart.length) {
var data = {
series: [100, 0]
};
var options = {
donut: true,
donutWidth: 10,
startAngle: 0,
total: 100,
showLabel: false,
height: 150,
chartPadding: !isFirefox ? 5 : 10
};
UpdatesChart = Chartist.Pie('.updates-chart .ct-chart', data, options);
UpdatesChart.on('draw', function(data){
if (data.index) { return; }
chart.find('.numeric span').text(Math.round(data.value) + '%');
var text = translations.PLUGIN_ADMIN.UPDATES_AVAILABLE;
if (data.value == 100) {
text = translations.PLUGIN_ADMIN.FULLY_UPDATED;
}
$('.js__updates-available-description').html(text)
$('.updates-chart .hidden').removeClass('hidden');
});
}
// Cache Clear
$('[data-clear-cache]').on('click', function(e) {
$(this).attr('disabled','disabled').find('> .fa').removeClass('fa-trash').addClass('fa-refresh fa-spin');
var url = $(this).data('clearCache');
GravAjax({
dataType: "json",
url: url,
toastErrors: true,
success: function(result, status) {
toastr.success(result.message);
}
}).always(function() {
$('[data-clear-cache]').removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin').addClass('fa-trash');
});
});
// Plugins list details sliders
$('.gpm-name, .gpm-actions').on('click', function(e){
var target = $(e.target);
if (target.prop('tagName') == 'A' || target.parent('a').length) { return true; }
var wrapper = $(this).siblings('.gpm-details').find('.table-wrapper');
wrapper.slideToggle({
duration: 350,
complete: function(){
var isVisible = wrapper.is(':visible');
wrapper
.closest('tr')
.find('.gpm-details-expand i')
.removeClass('fa-chevron-' + (isVisible ? 'down' : 'up'))
.addClass('fa-chevron-' + (isVisible ? 'up' : 'down'));
}
});
});
// Update plugins/themes
$(document).on('click', '[data-maintenance-update]', function(e) {
$(this).attr('disabled','disabled').find('> .fa').removeClass('fa-cloud-download').addClass('fa-refresh fa-spin');
var url = $(this).data('maintenanceUpdate');
var task = 'task' + GravAdmin.config.param_sep;
GravAjax({
dataType: "json",
url: url,
toastErrors: true,
success: function(result, status) {
if (url.indexOf(task + 'updategrav') !== -1) {
if (result.status == 'success') {
$('[data-gpm-grav]').remove();
toastr.success(result.message + window.grav_available_version);
$('#footer .grav-version').html(window.grav_available_version);
/*// hide the update button after successfull update and update the badges
$('[data-maintenance-update]').fadeOut();
$('.badges.with-updates').removeClass('with-updates').find('.badge.updates').remove();*/
} else {
toastr.success(result.message);
}
} else {
toastr.success(result.message);
}
}
}).always(function() {
GPMRefresh();
$('[data-maintenance-update]').removeAttr('disabled').find('> .fa').removeClass('fa-refresh fa-spin').addClass('fa-cloud-download');
});
});
// Update plugins/themes
$('[data-ajax]').on('click', function(e) {
var button = $(this),
icon = button.find('> .fa'),
url = button.data('ajax');
var iconClasses = [],
helperClasses = [ 'fa-lg', 'fa-2x', 'fa-3x', 'fa-4x', 'fa-5x',
'fa-fw', 'fa-ul', 'fa-li', 'fa-border',
'fa-rotate-90', 'fa-rotate-180', 'fa-rotate-270',
'fa-flip-horizontal', 'fa-flip-vertical' ];
// Disable button
button.attr('disabled','disabled');
// Swap fontawesome icon to loader
$.each(icon.attr('class').split(/\s+/), function (i, classname) {
if (classname.indexOf('fa-') === 0 && $.inArray(classname, helperClasses) === -1) {
iconClasses.push(classname);
icon.removeClass(classname);
}
});
icon.addClass('fa-refresh fa-spin');
GravAjax({
dataType: "json",
url: url,
toastErrors: true,
success: function(result, status) {
var task = 'task' + GravAdmin.config.param_sep;
var toastrBackup = {};
if (result.toastr) {
for (var setting in result.toastr) { if (result.toastr.hasOwnProperty(setting)) {
toastrBackup[setting] = toastr.options[setting];
toastr.options[setting] = result.toastr[setting];
}
}
}
toastr.success(result.message || translations.PLUGIN_ADMIN.TASK_COMPLETED);
for (var setting in toastrBackup) { if (toastrBackup.hasOwnProperty(setting)) {
toastr.options[setting] = toastrBackup[setting];
}
}
if (url.indexOf(task + 'backup') !== -1) {
//Reset backup days count
$('.backups-chart .numeric').html("0 <em>" + translations.PLUGIN_ADMIN.DAYS + "</em>");
var data = {
series: [0,100]
};
var options = {
donut: true,
donutWidth: 10,
startAngle: 0,
total: 100,
showLabel: false,
height: 150
};
Chartist.Pie('.backups-chart .ct-chart', data, options);
}
}
}).always(function() {
// Restore button
button.removeAttr('disabled');
icon.removeClass('fa-refresh fa-spin').addClass(iconClasses.join(' '));
});
});
$('[data-gpm-checkupdates]').on('click', function(){
var element = $(this);
element.find('i').addClass('fa-spin');
GPMRefresh({
flush: true,
callback: function(response) {
var payload = response.status == 'success' ? response.payload : false;
element.find('i').removeClass('fa-spin');
if (payload) {
if (!payload.grav.isUpdatable && !payload.resources.total) {
toastr.success(translations.PLUGIN_ADMIN.EVERYTHING_UP_TO_DATE);
} else {
var grav = payload.grav.isUpdatable ? 'Grav v' + payload.grav.available : '';
var resources = payload.resources.total ? payload.resources.total + ' ' + translations.PLUGIN_ADMIN.UPDATES_ARE_AVAILABLE: '';
if (!resources) { grav += ' ' + translations.PLUGIN_ADMIN.IS_AVAILABLE_FOR_UPDATE }
toastr.info(grav + (grav && resources ? ' ' + translations.PLUGIN_ADMIN.AND + ' ' : '') + resources);
}
}
}
});
});
var GPMRefresh = function (options) {
options = options || {};
var data = {
task: 'GPM',
action: 'getUpdates'
};
if (options.flush) { data.flush = true; }
GravAjax({
dataType: "JSON",
url: window.location.href,
method: "POST",
data: data,
toastErrors: true,
success: function (response) {
var grav = response.payload.grav,
installed = response.payload.installed,
resources = response.payload.resources,
task = 'task' + GravAdmin.config.param_sep;
// grav updatable
if (grav.isUpdatable) {
var icon = '<i class="fa fa-bullhorn"></i> ';
content = 'Grav <b>v{available}</b> ' + translations.PLUGIN_ADMIN.IS_NOW_AVAILABLE + '! <span class="less">(' + translations.PLUGIN_ADMIN.CURRENT + ': v{version})</span> ',
button = '<button data-maintenance-update="' + GravAdmin.config.base_url_relative + '/update.json/' + task + 'updategrav" class="button button-small secondary" id="grav-update-button">' + translations.PLUGIN_ADMIN.UPDATE_GRAV_NOW + '</button>';
if (grav.isSymlink) {
button = '<span class="hint--left" style="float: right;" data-hint="' + translations.PLUGIN_ADMIN.GRAV_SYMBOLICALLY_LINKED + '"><i class="fa fa-fw fa-link"></i></span>';
}
content = jQuery.substitute(content, {available: grav.available, version: grav.version});
$('[data-gpm-grav]').addClass('grav').html('<p>' + icon + content + button + '</p>');
window.grav_available_version = grav.available;
}
$('#grav-update-button').on('click', function() {
$(this).html(translations.PLUGIN_ADMIN.UPDATING_PLEASE_WAIT + ' ' + bytesToSize(grav.assets['grav-update'].size) + '..');
});
// dashboard
if ($('.updates-chart').length) {
var missing = (resources.total + (grav.isUpdatable ? 1 : 0)) * 100 / (installed + (grav.isUpdatable ? 1 : 0)),
updated = 100 - missing;
UpdatesChart.update({series: [updated, missing]});
if (resources.total) {
$('#updates [data-maintenance-update]').fadeIn();
}
}
if (!resources.total) {
$('#updates [data-maintenance-update]').fadeOut();
$('.badges.with-updates').removeClass('with-updates').find('.badge.updates').remove();
} else {
var length,
icon = '<i class="fa fa-bullhorn"></i>',
content = '{updates} ' + translations.PLUGIN_ADMIN.OF_YOUR + ' {type} ' + translations.PLUGIN_ADMIN.HAVE_AN_UPDATE_AVAILABLE,
button = '<a href="{location}/' + task + 'update" class="button button-small secondary">' + translations.PLUGIN_ADMIN.UPDATE + ' {Type}</a>',
plugins = $('.grav-update.plugins'),
themes = $('.grav-update.themes'),
sidebar = {plugins: $('#admin-menu a[href$="/plugins"]'), themes: $('#admin-menu a[href$="/themes"]')};
// sidebar
if (sidebar.plugins.length || sidebar.themes.length) {
var length, badges;
if (sidebar.plugins.length && (length = Object.keys(resources.plugins).length)) {
badges = sidebar.plugins.find('.badges');
badges.addClass('with-updates');
badges.find('.badge.updates').text(length);
}
if (sidebar.themes.length && (length = Object.keys(resources.themes).length)) {
badges = sidebar.themes.find('.badges');
badges.addClass('with-updates');
badges.find('.badge.updates').text(length);
}
}
// list page
if (plugins[0] && (length = Object.keys(resources.plugins).length)) {
content = jQuery.substitute(content, {updates: length, type: 'plugins'});
button = jQuery.substitute(button, {Type: 'All Plugins', location: GravAdmin.config.base_url_relative + '/plugins'});
plugins.html('<p>' + icon + content + button + '</p>');
var plugin, url;
$.each(resources.plugins, function (key, value) {
plugin = $('[data-gpm-plugin="' + key + '"] .gpm-name');
url = plugin.find('a');
if (!plugin.find('.badge.update').length) {
plugin.append('<a class="plugin-update-button" href="' + url.attr('href') + '"><span class="badge update">' + translations.PLUGIN_ADMIN.UPDATE_AVAILABLE + '!</span></a>');
}
});
}
if (themes[0] && (length = Object.keys(resources.themes).length)) {
content = jQuery.substitute(content, {updates: length, type: 'themes'});
button = jQuery.substitute(button, {Type: 'All Themes', location: GravAdmin.config.base_url_relative + '/themes'});
themes.html('<p>' + icon + content + button + '</p>');
var theme, url;
$.each(resources.themes, function (key, value) {
theme = $('[data-gpm-theme="' + key + '"]');
url = theme.find('.gpm-name a');
theme.append('<div class="gpm-ribbon"><a href="' + url.attr('href') + '">' + translations.PLUGIN_ADMIN.UPDATE.toUpperCase() + '</a></div>');
});
}
// details page
var type = 'plugin',
details = $('.grav-update.plugin')[0];
if (!details) {
details = $('.grav-update.theme')[0];
type = 'theme';
}
if (details){
var slug = $('[data-gpm-' + type + ']').data('gpm-' + type),
Type = type.charAt(0).toUpperCase() + type.substring(1),
resource = resources[type + 's'][slug];
if (resource) {
content = '<strong>v{available}</strong> ' + translations.PLUGIN_ADMIN.OF_THIS + ' ' + type + ' ' + translations.PLUGIN_ADMIN.IS_NOW_AVAILABLE + '!';
content = jQuery.substitute(content, { available: resource.available });
button = jQuery.substitute(button, {
Type: Type,
location: GravAdmin.config.base_url_relative + '/' + type + 's/' + slug
});
$(details).html('<p>' + icon + content + button + '</p>');
}
}
}
if (options.callback && typeof options.callback == 'function') options.callback(response);
}
});
};
if (GravAdmin.config.enable_auto_updates_check === '1') {
GPMRefresh();
}
function reIndex (collection) {
var holder = collection.find('[data-collection-holder]'),
addBtn = collection.find('[data-action="add"]'),
prefix = holder.data('collection-holder'),
index = 0;
holder.find('[data-collection-item]').each(function () {
var item = $(this),
currentIndex = item.attr('data-collection-key');
if (index != currentIndex) {
var r = new RegExp('^' + prefix.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&") + '[\.\[]' + currentIndex);
item.attr('data-collection-item', item.attr('data-collection-item').replace(r, prefix + '.' + index));
item.attr('data-collection-key', index);
item.find('[name]').each(function () {
$(this).attr('name', $(this).attr('name').replace(r, prefix + '[' + index));
});
}
index++;
});
addBtn.data('key-index', index);
}
// Collections
$('[data-type="collection"]').each(function () {
var el = $(this),
holder = el.find('[data-collection-holder]'),
config = el.find('[data-collection-config]'),
isArray = config.data('collection-array'),
template = el.find('[data-collection-template="new"]').html();
// make sortable
new Sortable(holder[0], {
filter: '.form-input-wrapper',
onUpdate: function () {
if (isArray)
reIndex(el);
}
});
// hook up delete
el.on('click', '[data-action="delete"]', function (e) {
$(this).closest('[data-collection-item]').remove();
if (isArray)
reIndex(el);
});
// hook up add
el.find('[data-action="add"]').on('click', function (e) {
var button = $(this),
key = button.data('key-index'),
newItem = $(template);
newItem.attr('data-collection-item', newItem.attr('data-collection-item').replace('*', key));
newItem.attr('data-collection-key', key);
newItem.find('[name]').each(function () {
$(this).attr('name', $(this).attr('name').replace('*', key));
});
holder.append(newItem);
button.data('key-index', ++key);
});
});
// enable the toggleable checkbox when typing in the corresponding textarea/input element
jQuery(document).on('input propertychange click', '.form-data textarea, .form-data input, .form-data label, .form-data .selectize-input', function() {
var item = this;
var checkbox = $(item).parents('.form-field').find('.toggleable input[type="checkbox"]');
if (checkbox.length > 0) {
checkbox.prop('checked', true);
}
$(this).css('opacity', 1);
$(this).parents('.form-data').css('opacity', 1);
checkbox.css('opacity', 1);
checkbox.prop('checked', true);
checkbox.prop('value', 1);
checkbox.siblings('label').css('opacity', 1);
checkbox.parent().siblings('label').css('opacity', 1);
});
// when clicking the label, click the corresponding checkbox automatically
jQuery(document).on('click', 'label.toggleable', function() {
var input = $(this).siblings('.checkboxes.toggleable').find('input');
var on = !input.is(':checked');
input.prop('checked', on);
input.prop('value', on ? 1 : 0);
$(this).css('opacity', on ? 1 : 0.7);
input.siblings('label').css('opacity', on ? 1 : 0.7);
$(this).parents('.form-label').siblings('.form-data').css('opacity', on ? 1 : 0.7);
});
// Themes Switcher Warning
$(document).on('mousedown', '[data-remodal-target="theme-switch-warn"]', function(e){
var name = $(e.target).closest('[data-gpm-theme]').find('.gpm-name a').text(),
remodal = $('.remodal.theme-switcher');
remodal.find('strong').text(name);
remodal.find('.button.continue').attr('href', $(e.target).attr('href'));
});
// Setup keep-alive on pages that have at least one element with data-grav-keepalive="true" set
if ($(document).find('[data-grav-keepalive="true"]').length > 0) {
setInterval(function() {
keepAlive();
}, (GravAdmin.config.admin_timeout/2)*1000);
}
});
+96
View File
@@ -0,0 +1,96 @@
$(function(){
var root = window || {};
root.GravAjax = function (url, settings) {
settings = typeof settings === 'undefined' ? typeof url === 'string' ? {} : url : settings;
settings.url = typeof settings.url === 'undefined' && typeof url === 'string' ? url : settings.url;
var callbacks = {
success: typeof settings.success !== 'undefined' ? typeof settings.success === 'function' ? [ settings.success ] : settings.success : [],
error: typeof settings.error !== 'undefined' ? typeof settings.error === 'function' ? [ settings.error ] : settings.error : []
};
if (settings.toastErrors) {
callbacks.error.push(root.GravAjax.toastErrorHandler);
delete settings.toastErrors;
}
delete settings.success;
delete settings.error;
var deferred = $.Deferred(),
jqxhr = $.ajax(settings);
jqxhr.done(function (response, status, xhr) {
var responseObject = {
response: response,
status: status,
xhr: xhr
};
switch (response.status) {
case "unauthenticated":
document.location.href = GravAdmin.config.base_url_relative;
throw "Logged out";
break;
case "unauthorized":
responseObject.response.message = responseObject.response.message || "Unauthorized.";
root.GravAjax.errorHandler(deferred, callbacks, responseObject);
break;
case "error":
responseObject.response.message = responseObject.response.message || "Unknown error.";
root.GravAjax.errorHandler(deferred, callbacks, responseObject);
break;
case "success":
root.GravAjax.successHandler(deferred, callbacks, responseObject);
break;
default:
responseObject.response.message = responseObject.response.message || "Invalid AJAX response.";
root.GravAjax.errorHandler(deferred, callbacks, responseObject);
break;
}
});
jqxhr.fail(function (xhr, status, error) {
var response = {
status: 'error',
message: error
};
root.GravAjax.errorHandler(deferred, callbacks, { xhr: xhr, status: status, response: response});
});
root.GravAjax.jqxhr = jqxhr;
return deferred;
};
root.GravAjax.successHandler = function (promise, callbacks, response) {
callbacks = callbacks.success;
for (var i = 0; i < callbacks.length; i++) {
if (typeof callbacks[i] === 'function') {
callbacks[i](response.response, response.status, response.xhr);
}
}
promise.resolve(response.response, response.status, response.xhr);
};
root.GravAjax.errorHandler = function (promise, callbacks, response) {
callbacks = callbacks.error;
for (var i = 0; i < callbacks.length; i++) {
if (typeof callbacks[i] === 'function') {
callbacks[i](response.xhr, response.status, response.response.message);
}
}
promise.reject(response.xhr, response.status, response.response.message);
};
root.GravAjax.toastErrorHandler = function (xhr, status, error) {
if (status !== 'abort') {
toastr.error(error);
}
};
});
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
# Custom build of kendo-ui-core
Compiled by: Gert
Source: https://github.com/telerik/kendo-ui-core
## How to reproduce
1. Checkout source
2. npm install
3. grunt custom:datepicker,datetimepicker
4. Copy `kendo.custom.min.js` from `dist` folder
@@ -0,0 +1,50 @@
$(document).ready(function(){
$('input[data-grav-field-datetime]').each(function() {
var $input = $(this),
min = $input.attr('min'),
max = $input.attr('max'),
regex, match,
userOptions = $input.data('dateFormats') || {},
kendoOptions = { format: "dd-MM-yyyy HH:mm", timeFormat: "HH:mm" };
kendoOptions = $.extend({}, kendoOptions, userOptions);
if (min || max) {
regex = /(\d{2})-(\d{2})-(\d{4}) (\d{2}):(\d{2})/;
}
if (min && (match = regex.exec(min))) {
kendoOptions.min = new Date(
(+match[3]),
(+match[2])-1,
(+match[1]),
(+match[4]),
(+match[5])
);
}
if (max && (match = regex.exec(max))) {
kendoOptions.max = new Date(
(+match[3]),
(+match[2])-1,
(+match[1]),
(+match[4]),
(+match[5])
);
}
$input.kendoDateTimePicker(kendoOptions);
// Reset when user manually types in invalid date
$input.on('change', function () {
$input.css('opacity', 1);
$input.parents('.form-data').css('opacity', 1);
var kWidget = $input.data('kendoDateTimePicker');
if (kWidget && kWidget.value() === null && $input.val()) {
kWidget.value($input.data('kendo-previous') || "");
} else {
$input.data('kendo-previous', kWidget.value() || "");
}
});
});
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,165 @@
/* ========================================================================
* Bootstrap: dropdown.js v3.3.5
* http://getbootstrap.com/javascript/#dropdowns
* ========================================================================
* Copyright 2011-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
+function ($) {
'use strict';
// DROPDOWN CLASS DEFINITION
// =========================
var backdrop = '.dropdown-backdrop'
var toggle = '[data-toggle="dropdown"]'
var Dropdown = function (element) {
$(element).on('click.bs.dropdown', this.toggle)
}
Dropdown.VERSION = '3.3.5'
function getParent($this) {
var selector = $this.attr('data-target')
if (!selector) {
selector = $this.attr('href')
selector = selector && /#[A-Za-z]/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
}
var $parent = selector && $(selector)
return $parent && $parent.length ? $parent : $this.parent()
}
function clearMenus(e) {
if (e && e.which === 3) return
$(backdrop).remove()
$(toggle).each(function () {
var $this = $(this)
var $parent = getParent($this)
var relatedTarget = { relatedTarget: this }
if (!$parent.hasClass('open')) return
if (e && e.type == 'click' && /input|textarea/i.test(e.target.tagName) && $.contains($parent[0], e.target)) return
$parent.trigger(e = $.Event('hide.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this.attr('aria-expanded', 'false')
$parent.removeClass('open').trigger($.Event('hidden.bs.dropdown', relatedTarget))
})
}
Dropdown.prototype.toggle = function (e) {
var $this = $(this)
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement && !$parent.closest('.navbar-nav').length) {
// if mobile we use a backdrop because click events don't delegate
$(document.createElement('div'))
.addClass('dropdown-backdrop')
.insertAfter($(this))
.on('click', clearMenus)
}
var relatedTarget = { relatedTarget: this }
$parent.trigger(e = $.Event('show.bs.dropdown', relatedTarget))
if (e.isDefaultPrevented()) return
$this
.trigger('focus')
.attr('aria-expanded', 'true')
$parent
.toggleClass('open')
.trigger($.Event('shown.bs.dropdown', relatedTarget))
}
return false
}
Dropdown.prototype.keydown = function (e) {
if (!/(38|40|27|32)/.test(e.which) || /input|textarea/i.test(e.target.tagName)) return
var $this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
var $parent = getParent($this)
var isActive = $parent.hasClass('open')
if (!isActive && e.which != 27 || isActive && e.which == 27) {
if (e.which == 27) $parent.find(toggle).trigger('focus')
return $this.trigger('click')
}
var desc = ' li:not(.disabled):visible a'
var $items = $parent.find('.dropdown-menu' + desc)
if (!$items.length) return
var index = $items.index(e.target)
if (e.which == 38 && index > 0) index-- // up
if (e.which == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items.eq(index).trigger('focus')
}
// DROPDOWN PLUGIN DEFINITION
// ==========================
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.dropdown')
if (!data) $this.data('bs.dropdown', (data = new Dropdown(this)))
if (typeof option == 'string') data[option].call($this)
})
}
var old = $.fn.dropdown
$.fn.dropdown = Plugin
$.fn.dropdown.Constructor = Dropdown
// DROPDOWN NO CONFLICT
// ====================
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
return this
}
// APPLY TO STANDARD DROPDOWN ELEMENTS
// ===================================
$(document)
.on('click.bs.dropdown.data-api', clearMenus)
.on('click.bs.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)
.on('keydown.bs.dropdown.data-api', toggle, Dropdown.prototype.keydown)
.on('keydown.bs.dropdown.data-api', '.dropdown-menu', Dropdown.prototype.keydown)
}(jQuery);
File diff suppressed because one or more lines are too long
+8
View File
@@ -0,0 +1,8 @@
/**
* Featherlight - ultra slim jQuery lightbox
* Version 0.4.9 - http://noelboss.github.io/featherlight/
*
* Copyright 2014, Noël Raoul Bossart (http://www.noelboss.com)
* MIT Licensed.
**/
!function(a){"use strict";if("undefined"==typeof a)return void("console"in window&&window.console.info("Too much lightness, Featherlight needs jQuery."));var b=a.featherlight=function(c,d){if(this.constructor===b)this.id=b.id++;else{if("string"==typeof c||!1!=c instanceof a){var e=(new b).setup(c,d);return e.config.open.call(e),e}d=a.extend({},b.defaults,c||{}),a(d.selector,d.context).featherlight()}},c=function(a){if(27===a.keyCode&&!a.isDefaultPrevented()){var c=b.current();c&&c.config.closeOnEsc&&(c.$instance.find("."+c.config.namespace+"-close:first").click(),a.preventDefault())}};a.extend(b,{id:0,defaults:{autostart:!0,namespace:"featherlight",selector:"[data-featherlight]",context:"body",type:{image:!1,ajax:!1},targetAttr:"data-featherlight",variant:null,resetCss:!1,background:null,openTrigger:"click",closeTrigger:"click",openSpeed:250,closeSpeed:250,closeOnClick:"background",closeOnEsc:!0,closeIcon:"&#10005;",beforeOpen:a.noop,beforeClose:a.noop,afterOpen:a.noop,afterClose:a.noop,contentFilters:["jquery","image","html","ajax"],open:function(a){var b=this.config.beforeOpen.call(this,a);return!1!==b&&(b=this.open(a)),!1!==b&&this.config.afterOpen.call(this,a),b},close:function(a){var b=this.config.beforeClose.call(this,a);!1!==b&&this.close(a)}},methods:{setup:function(c,d){"object"!=typeof c||c instanceof a!=!1||d||(d=c,c=void 0),d=a.extend({},b.defaults,d);var e=d.resetCss?d.namespace+"-reset":d.namespace,f=a(d.background||'<div class="'+e+'"><div class="'+e+'-content"><span class="'+e+"-close-icon "+d.namespace+'-close">'+d.closeIcon+"</span></div></div>"),g=this;return a.extend(g,{config:d,target:c,$instance:f.clone().addClass(d.variant)}),g.$instance.on(d.closeTrigger+"."+d.namespace,function(b){var c=a(b.target);("background"===d.closeOnClick&&c.is("."+d.namespace)||"anywhere"===d.closeOnClick||c.is("."+d.namespace+"-close"))&&(b.preventDefault(),d.close.call(g))}),this},attach:function(b,c,d){var e={};return a.each(b[0].attributes,function(){var b=this.name.match(/^data-featherlight-(.*)/);if(b){var c=this.value;try{c=a.parseJSON(c)}catch(d){}e[a.camelCase(b[1])]=c}}),this.$elm=b,this.setup(c,a.extend(e,d)),b.on(this.config.openTrigger+"."+this.config.namespace,a.proxy(this.config.open,this)),this},getContent:function(){var c,d=this,e=d.target||d.$elm.attr(d.config.targetAttr)||"";for(var f in d.config.type)d.config.type[f]===!0&&(c=b.contentFilters[f]);if(!c&&e in b.contentFilters&&(c=b.contentFilters[e],e=d.target&&d.$elm.attr(d.config.targetAttr)),e=e||d.$elm.attr("href")||"",!c){var g=e;if(e=null,a.each(d.config.contentFilters,function(){return c=b.contentFilters[this],c.test&&(e=c.test(g)),!e&&c.regex&&g.match&&g.match(c.regex)&&(e=g),!e}),!e)return"console"in window&&window.console.error("Featherlight: no content filter found "+(g?' for "'+g+'"':" (no target specified)")),!1}return c.process.call(d,e)},setContent:function(b){var c=this;(b.is("iframe")||a("iframe",b).length>0)&&c.$instance.addClass(c.config.namespace+"-iframe"),c.$content=b.clone().addClass(c.config.namespace+"-inner"),c.$instance.find("."+c.config.namespace+"-inner").remove(),c.$instance.find("."+c.config.namespace+"-content").append(c.$content)},open:function(d){var e=this;d&&d.preventDefault();var f=this.getContent();return f?(e.constructor._opened.add(e._openedCallback=function(a){e.$instance.closest("body").length>0&&(a.currentFeatherlight=e)}),this.config.closeOnEsc&&c&&(a(document).bind("keyup."+b.defaults.namespace,c),c=null),this.setContent(f),this.$instance.appendTo("body").fadeIn(this.config.openSpeed),void 0):!1},close:function(a){var b=this;b.constructor._opened.remove(b._openedCallback),b.$instance.fadeOut(b.config.closeSpeed,function(){b.$instance.detach(),b.config.afterClose.call(b,a)})}},contentFilters:{jquery:{regex:/^[#.]\w/,test:function(b){return b instanceof a&&b},process:function(b){return a(b)}},image:{regex:/\.(png|jpg|jpeg|gif|tiff|bmp)(\?\S*)?$/i,process:function(b){return a('<img src="'+b+'" alt="" class="'+this.config.namespace+'-image" />')}},html:{regex:/^\s*<[\w!][^<]*>/,process:function(b){return a(b)}},ajax:{regex:/./,process:function(b){var c=this,d=a("<div></div>").load(b,function(b,e){"error"!==e&&a.featherlight(d.html(),a.extend({},c.config,{type:{html:!0}}))})}}},current:function(){var a={};return this._opened.fire(a),a.currentFeatherlight},close:function(){var a=b.current();a&&a.config.close.call(a)},_opened:a.Callbacks()}),b.prototype=a.extend({constructor:b},b.methods),a.fn.featherlight=function(c,d){return this.each(function(){(new b).attach(a(this),d,c)}),this},a(document).ready(function(){var c=b.defaults;c.autostart&&a(c.selector,c.context).featherlight()})}(jQuery);
@@ -0,0 +1,78 @@
(function($) {
$(function() {
/**
* polyfill for html5 form attr
*/
// detect if browser supports this
var sampleElement = $('[form]').get(0);
var isIE11 = !(window.ActiveXObject) && "ActiveXObject" in window;
if (sampleElement && window.HTMLFormElement && sampleElement.form instanceof HTMLFormElement && !isIE11) {
// browser supports it, no need to fix
return;
}
/**
* Append a field to a form
*
*/
$.fn.appendField = function(data) {
// for form only
if (!this.is('form')) return;
// wrap data
if (!$.isArray(data) && data.name && data.value) {
data = [data];
}
var $form = this;
// attach new params
$.each(data, function(i, item) {
$('<input/>')
.attr('type', 'hidden')
.attr('name', item.name)
.val(item.value).appendTo($form);
});
return $form;
};
/**
* Find all input fields with form attribute point to jQuery object
*
*/
$('form[id]').submit(function(e) {
// serialize data
var data = $('[form=' + this.id + ']').serializeArray();
// append data to form
$(this).appendField(data);
}).each(function() {
var form = this,
$fields = $('[form=' + this.id + ']');
$fields.filter('button, input').filter('[type=reset],[type=submit]').click(function() {
var type = this.type.toLowerCase();
if (type === 'reset') {
// reset form
form.reset();
// for elements outside form
$fields.each(function() {
this.value = this.defaultValue;
this.checked = this.defaultChecked;
}).filter('select').each(function() {
$(this).find('option').each(function() {
this.selected = this.defaultSelected;
});
});
} else if (type.match(/^submit|image$/i)) {
$(form).appendField({
name: this.name,
value: this.value
}).submit();
}
});
});
});
})(jQuery);
@@ -0,0 +1,20 @@
$(function () {
if (typeof window.GravJS === 'undefined' || !window.GravJS.Form) {
console.warn('Dependencies for Grav Forms are not loaded.');
return;
}
// Register all FormFields that were loaded
if (typeof window.GravJS.FormFields === 'object') {
for (var key in window.GravJS.FormFields) { if (window.GravJS.FormFields.hasOwnProperty(key)) {
GravJS.Form.registerFactory(GravJS.FormFields[key]);
}
}
}
window.formInstances = [];
$('[data-grav-form]').each(function () {
window.formInstances.push(new GravJS.Form($(this)));
})
});
@@ -0,0 +1,210 @@
(function () {
var root = window || {};
root = root.GravJS = root.GravJS || {};
root = root.FormFields = root.FormFields || {};
var ArrayField = function (el, form) {
el = $(el);
this.el = el.is('[' + form.fieldIndicator + ']') ? el : el.closest('[' + form.fieldIndicator + ']');
this.el.on('click', '[data-grav-array-action="add"]', this.add.bind(this));
this.el.on('click', '[data-grav-array-action="rem"]', this.remove.bind(this));
this.el.on('click', '[data-grav-array-action="addArrayItem"]', this.addArray.bind(this));
this.el.on('click', '[data-grav-array-action="remArrayItem"]', this.removeArray.bind(this));
this.el.on('keyup', '[data-grav-array-type="key"]', this.update.bind(this));
this.el.on('keyup', '[data-grav-array-type="keyArray"]', this.updateArray.bind(this));
this.el.on('keyup', '[data-grav-array-type="keyArraySubelement"]', this.updateArraySubelement.bind(this));
};
ArrayField.getName = function () {
return 'array';
};
ArrayField.getTypes = function () {
return [ 'array' ];
};
ArrayField.prototype.valid = function() {
return true;
};
ArrayField.prototype.disabled = function() {
return false;
};
ArrayField.prototype.name = function(name) {
if (name && !this.isValueOnly()) {
this.el.data('grav-array-name', name);
return name;
} else {
return '';
}
return this.el.data('grav-array-name')
};
ArrayField.prototype.isValueOnly = function() {
return this.el.find('[data-grav-array-mode="value_only"]').length;
};
ArrayField.prototype.value = function(val) {
if (typeof val === 'object') {
// Remove old
this.el.find('[data-grav-array-type="row"]').remove();
var container = this.el.find('[data-grav-array-type="container"]');
for (var key in val) { if (val.hasOwnProperty(key)) {
container.append(this._getNewField(key, val[key]));
}
}
return val;
}
var values = {};
this.el.find('[data-grav-array-type="value"]').each(function () {
var key = $(this).attr('name'),
value = $(this).val();
values[key] = value;
});
return values;
};
ArrayField.prototype.reset = function() {
this.value('');
};
ArrayField.prototype.formValues = function() {
var values = this.value(),
name = this.name(),
formValues = {};
for (var key in values) { if (values.hasOwnProperty(key)) {
formValues[this.isValueOnly() ? key : name + '[' + key + ']'] = values[key];
}
}
return formValues;
};
ArrayField.prototype.add = function(event) {
$(this._getNewField()).insertAfter($(event.target).closest('[data-grav-array-type="row"]'));
if (this.isValueOnly()) {
this.refreshAll();
}
};
ArrayField.prototype.remove = function(event) {
var row = $(event.target).closest('[data-grav-array-type="row"]');
if (row.siblings().length == 0) {
//on the last item we just clear its values
row.find('input').val('');
return;
}
row.remove();
if (this.isValueOnly()) {
this.refreshAll();
}
};
ArrayField.prototype.addArray = function(event) {
$(this._getNewArrayField()).insertAfter($(event.target).closest('[data-grav-array-type="subrow"]'));
};
ArrayField.prototype.removeArray = function(event) {
if ($(event.target).closest('[data-grav-array-type="subrow"]').siblings().length == 0) {
//disable for the last item
return;
}
$(event.target).closest('[data-grav-array-type="subrow"]').remove();
};
ArrayField.prototype.update = function(event) {
var keyField = $(event.target),
valueField = keyField.closest('[data-grav-array-type="row"]').find('[data-grav-array-type="value"]');
valueField.attr('name', this.getFieldName() + '[' + keyField.val() + ']');
};
ArrayField.prototype.updateArray = function(event) {
var keyField = $(event.target),
row = keyField.closest('[data-grav-array-type="row"]'),
valueFields = row.find('[data-grav-array-type="value"]'),
keyArrayField = row.find('[data-grav-array-type="keyArray"]'),
fieldName = this.getFieldName();
valueFields.each(function() {
$(this).attr('name', fieldName + '[' + keyArrayField.val() + ']' + '[' + $(this).attr('subkey') + ']');
});
};
ArrayField.prototype.updateArraySubelement = function(event) {
var keyField = $(event.target),
row = keyField.closest('[data-grav-array-type="row"]'),
subrow = keyField.closest('[data-grav-array-type="subrow"]'),
valueFields = subrow.find('[data-grav-array-type="value"]'),
keyArrayField = row.find('[data-grav-array-type="keyArray"]'),
fieldName = this.getFieldName();
valueFields.each(function() {
$(this).attr('name', fieldName + '[' + keyArrayField.val() + ']' + '[' + keyField.val() + ']');
});
};
ArrayField.prototype.refreshAll = function() {
var that = this;
this.el.find('[data-grav-array-type="value"]').each(function(index, element){
$(element).attr('name', that.getFieldName() + '[' + index + ']');
});
};
ArrayField.prototype.getFieldName = function(element) {
return this.el.data('grav-array-name');
};
ArrayField.prototype._getNewField = function(key, value) {
var name = this.name(),
value_only = this.isValueOnly(),
placeholder = {
key: this.el.data('grav-array-keyname') || 'Key',
val: this.el.data('grav-array-valuename') || 'Value'
};
key = key || '';
value = value || '';
var output;
if (value_only) {
output = '<div class="form-row array-field-value_only" data-grav-array-type="row">' + "\n" +
'<input data-grav-array-type="value" type="text" value="' + value + '" placeholder="' + placeholder.val + '" />' + "\n";
} else {
output = '<div class="form-row" data-grav-array-type="row">' + "\n" +
'<input data-grav-array-type="key" type="text" value="' + key + '" placeholder="' + placeholder.key + '" />' + "\n" +
'<input data-grav-array-type="value" type="text" name="' + key + '" value="' + value + '" placeholder="' + "\n" + placeholder.val + '" />';
}
output += '<span data-grav-array-action="rem" class="fa fa-minus"></span>' + "\n" +
'<span data-grav-array-action="add" class="fa fa-plus"></span>' + "\n" +
'</div>';
return output;
};
ArrayField.prototype._getNewArrayField = function(key, value) {
var output = '<div class="form-row" data-grav-array-type="subrow">' + "\n" +
'<input data-grav-array-type="keyArraySubelement" type="text" value="" />' + "\n" +
'<input data-grav-array-type="value" type="text" name="" value="" />';
output += '<span data-grav-array-action="remArrayItem" class="fa fa-minus-square"></span>' + "\n" +
'<span data-grav-array-action="addArrayItem" class="fa fa-plus-square"></span>' + "\n" +
'</div>';
return output;
};
root.Array = ArrayField;
})();
@@ -0,0 +1,100 @@
(function () {
var root = window || {};
root = root.GravJS = root.GravJS || {};
root = root.FormFields = root.FormFields || {};
var CheckboxesField = function (el, form) {
el = $(el);
this.el = el.is('[' + form.fieldIndicator + ']') ? el : el.closest('[' + form.fieldIndicator + ']');
this.keys = this.el.data('grav-keys') || false;
this._disabled = this.el.data('grav-disabled') || false;
this._default = this.el.data('grav-default') || '';
};
CheckboxesField.getName = function () {
return 'checkboxes';
};
CheckboxesField.getTypes = function () {
return [ 'checkboxes' ];
};
CheckboxesField.prototype.valid = function() {
return true;
};
CheckboxesField.prototype.disabled = function(state) {
if (typeof state !== 'undefined') {
this._disabled = state ? true : false;
this.el.css('opacity', state ? 0.6 : 1);
}
return this._disabled;
};
CheckboxesField.prototype.name = function(name) {
if (name) {
this.el.data('grav-field-name', name);
return name;
}
return this.el.data('grav-field-name')
};
CheckboxesField.prototype.value = function(val) {
var useKeys = this.keys,
values = useKeys ? {} : [];
if (typeof val !== 'undefined') {
this.el.find('input').each(function () {
var checked = false;
if (useKeys && typeof val[$(this).attr('name')] !== 'undefined') {
checked = val[$(this).attr('name')];
} else if (!useKeys && val.indexOf($(this).val()) !== -1) {
checked = true;
}
$(this).prop('checked', checked);
});
return val;
}
this.el.find('input').each(function () {
if (useKeys) {
values[$(this).attr('name')] = $(this).is(':checked');
} else if ($(this).is(':checked')) {
values.push($(this).val());
}
});
return values;
};
CheckboxesField.prototype.reset = function() {
this.value(this._default);
};
CheckboxesField.prototype.formValues = function() {
var values = this.value(),
name = this.name(),
formValues = {};
for (var key in values) { if (values.hasOwnProperty(key)) {
formValues[key] = values[key] ? '1' : '0';
}
}
return formValues;
};
CheckboxesField.prototype.onChange = function(eh) {
var self = this;
this.el.find('input').on('change', function () { eh.call(self, self.value()); });
};
root.Checkboxes = CheckboxesField;
})();
@@ -0,0 +1,73 @@
(function () {
var root = window || {};
root = root.GravJS = root.GravJS || {};
root = root.FormFields = root.FormFields || {};
var Input = function (el, form) {
el = $(el);
var parent = el.is('[' + form.fieldIndicator + ']') ? el : el.closest('[' + form.fieldIndicator + ']'),
input = parent.prop('tagName').toUpperCase() === 'INPUT' ? parent : parent.find('input'),
type = parent.data(form.fieldIndicator);
this.el = parent;
this.input = input;
this._disabled = parent.data('grav-disabled') || false;
this._default = parent.data('grav-default') || '';
};
Input.getName = function () {
return 'input';
};
Input.getTypes = function () {
return [ 'text', 'hidden' ];
};
Input.prototype.valid = function() {
return true;
};
Input.prototype.disabled = function(state) {
if (typeof state !== 'undefined') {
this._disabled = state ? true : false;
}
return this._disabled;
};
Input.prototype.name = function(name) {
if (name) {
this.input.attr('name', name);
return name;
}
return this.input.attr('name')
};
Input.prototype.value = function(val) {
if (typeof val !== 'undefined') {
this.input.val(val);
}
return this.input.val();
};
Input.prototype.reset = function() {
this.value(this._default);
};
Input.prototype.formValues = function() {
var o = {};
o[this.name()] = this.value();
return o;
};
Input.prototype.onChange = function(eh) {
var self = this;
this.input.on('keyup', function () { eh.call(self, self.value()); });
};
root.Input = Input;
})();
@@ -0,0 +1,71 @@
(function () {
var root = window || {};
root = root.GravJS = root.GravJS || {};
root = root.FormFields = root.FormFields || {};
var SelectizeField = function (el, form) {
el = $(el);
var parent = el.is('[' + form.fieldIndicator + ']') ? el : el.closest('[' + form.fieldIndicator + ']'),
tagName = parent.data('grav-field').toLowerCase() === 'select' ? 'SELECT' : 'INPUT',
input = parent.prop('tagName').toUpperCase() === tagName ? parent : parent.find(tagName),
type = parent.data(form.fieldIndicator);
input.selectize(parent.data('grav-selectize'));
this.el = parent;
this.input = input;
this.selectize = input[0].selectize;
};
SelectizeField.getName = function () {
return 'selectize';
};
SelectizeField.getTypes = function () {
return [ 'selectize', 'select'];
};
SelectizeField.prototype.valid = function() {
return true;
};
SelectizeField.prototype.disabled = function() {
return false;
};
SelectizeField.prototype.name = function(name) {
if (name) {
this.input.attr('name', name);
return name;
}
return this.input.attr('name')
};
SelectizeField.prototype.value = function(val) {
if (typeof val !== 'undefined') {
val = typeof val === 'string' ? val.length ? val.split(',') : [] : val;
for (var i = val.length - 1; i >= 0; i--) {
this.selectize.addOption({ text: val[i], value: val[i] });
}
this.selectize.setValue(val);
}
return this.selectize.items;
};
SelectizeField.prototype.reset = function() {
this.value('');
};
SelectizeField.prototype.formValues = function() {
var o = {};
o[this.name()] = this.value().join(',');
return o;
};
root.Selectize = SelectizeField;
})();
@@ -0,0 +1,59 @@
(function () {
var root = window || {};
root = root.GravJS = root.GravJS || {};
root = root.FormFields = root.FormFields || {};
var ToggleField = function (el, form) {
el = $(el);
this.el = el.is('[' + form.fieldIndicator + ']') ? el : el.closest('[' + form.fieldIndicator + ']');
this._disabled = this.el.data('grav-disabled') || false;
this._default = this.el.data('grav-default') || '';
};
ToggleField.getName = function () {
return 'toggle';
};
ToggleField.getTypes = function () {
return [ 'toggle' ];
};
ToggleField.prototype.valid = function() {
return true;
};
ToggleField.prototype.disabled = function() {
return false;
};
ToggleField.prototype.name = function(name) {
if (name) {
this.el.data('grav-field-name', name);
return name;
}
return this.el.data('grav-field-name')
};
ToggleField.prototype.value = function(val) {
if (typeof val !== 'undefined') {
this.el.find('input').prop('checked', false).filter('[value="' + val + '"]').prop('checked', true);
return val;
}
return this.el.find('input:checked').val();
};
ToggleField.prototype.reset = function() {
this.value(this._default);
};
ToggleField.prototype.formValues = function() {
var o = {};
o[this.name()] = this.value();
return o;
};
root.Toggle = ToggleField;
})();
@@ -0,0 +1,335 @@
(function () {
var root = window || {};
root = root.GravJS = root.GravJS || {};
root.clickedButton = null;
$(document).on('click', 'button.task', function(e) {
root.clickedButton = e.target;
});
function addTypes (form, factory) {
var name = factory.getName(),
types = factory.getTypes();
for (var i = types.length - 1; i >= 0; i--) {
form.types[types[i]] = name;
if (form.scanned) {
scan(form, type);
}
}
}
function scan (form, type) {
for (var i = form.elements.length - 1; i >= 0; i--) {
if (!type || form.elements[i].type === type) {
form.elements.splice(i, 1);
}
}
if (Object.keys(form.types).length === 0 || (type && !form.types[type])) {
return;
}
form.findElements().each(function () {
var el = $(this),
type = el.data(form.dataIndicator);
if (type == 'textarea' || type == 'toggleable' || type == 'datetime') {
var processSpan = function processSpan(element, toggleable) {
var on = true;
if (!toggleable) {
on = $(element).find('input').is(':checked');
}
$(element).find('label').css('opacity', on ? 1 : 0.7);
$(element).siblings('label').css('opacity', on ? 1 : 0.7);
if (!on) {
$(element).find('input').attr('checked', false).prop('value', 0);
} else {
$(element).find('input').attr('checked', true).prop('value', 1);
}
var form_data = $(element).parent().siblings('.form-data');
if (on) {
form_data.addClass('checked');
} else {
form_data.removeClass('checked');
}
form_data.css('opacity', on ? 1 : 0.6);
form_data.find('textarea').css('opacity', on ? 1 : 0.6);
form_data.find('input').css('opacity', on ? 1 : 0.6);
};
var processToggleables = function processToggleables(element) {
var elType = $(element)[0].tagName.toLowerCase();
if (elType == 'checkbox') {
var on = $(element).is(':checked');
$(element).siblings('label').css('opacity', on ? 1 : 0.7);
$(element).parent().siblings('label').css('opacity', on ? 1 : 0.7);
if (!on) {
$(element).attr('checked', false).prop('value', 0);
} else {
$(element).attr('checked', true).prop('value', 1);
}
var form_data = $(element).parent().parent().siblings('.form-data')
form_data.css('opacity', on ? 1 : 0.6);
form_data.find('textarea').css('opacity', on ? 1 : 0.6);
form_data.find('input').css('opacity', on ? 1 : 0.6);
}
if (elType == 'span') {
processSpan(element);
}
};
el.on('change input propertychange', function() {
processToggleables(this);
});
el.find('input').on('change', function() {
processToggleables(this);
});
if ($(el)[0].className == 'checkboxes toggleable') {
var toggles = $(el).parent().siblings('.form-data').find('label');
toggles.on('click', function() {
processSpan(el, true);
});
}
processToggleables(this);
}
if (form.types[type]) {
var factory = form.factories[form.types[type]],
element = new factory(el, form),
name = element.name();
if (typeof form.toggleables[name] !== 'undefined') {
linkToggle(element, form.toggleables[name]);
delete form.toggleables[name];
}
el.data('grav-field-instance', element);
form.elements.push({ type: type, element: element });
}
});
}
function scanToggleable (form) {
form.toggleables = {};
form.findElements('toggleable').each(function () {
var el = $(this);
form.toggleables[el.data('grav-field-name')] = el;
});
}
function linkToggle (element, toggleable) {
$(element).on('change', function (value) {
toggleable.find('input').prop('checked', true);
toggleable.siblings('label').css('opacity', 1);
element.disabled(false);
});
toggleable.find('input').on('change', function () {
var el = $(this),
on = el.is(':checked');
toggleable.siblings('label').css('opacity', on ? 1 : 0.7);
element.disabled(!on);
if (!on) {
element.el.attr('checked', false).prop('value', 0);
} else {
element.el.attr('checked', true).prop('value', 1);
}
});
var on = toggleable.find('input').is(':checked');
toggleable.siblings('label').css('opacity', on ? 1 : 0.7);
element.disabled(!on);
if (!on) {
element.el.attr('checked', false).prop('value', 0);
} else {
element.el.attr('checked', true).prop('value', 1);
}
}
var Form = function (el, options) {
options = options || {};
this.form = $(el);
this.form.data('grav-form-instance', this);
this.form.on('submit', function (e) {
this.submit(this.ajax);
e.preventDefault();
return false;
}.bind(this));
this.scanned = false;
this.fieldIndicator = options.fieldIndicator || 'data-grav-field';
this.dataIndicator = options.dataIndicator || (this.fieldIndicator.indexOf('data-') === 0 ? this.fieldIndicator.substr(5) : 'grav-field');
this.ajax = options.ajax || false;
this.elements = [];
this.factories = {};
this.types = {};
if (typeof options.globalFactories === 'undefined' || options.globalFactories) {
for (var name in Form.factories) { if (Form.factories.hasOwnProperty(name)) {
this.registerFactory(Form.factories[name]);
}
}
}
scanToggleable(this);
scan(this);
this.scanned = true;
//Refresh root.currentValues as toggleables have been initialized
root.currentValues = getState();
};
Form.factories = {};
Form.findElements = function(el, selector, notIn, notSelf) {
el = $(el);
notIn = notIn || selector,
notSelf = notSelf ? true : false;
return el.find(selector).filter(function() {
var parent = notSelf ? $(this) : $(this).parent();
nearestMatch = parent.closest(notIn);
return nearestMatch.length == 0 || el.find(nearestMatch).length == 0;
});
};
Form.registerFactory = function (factory, context) {
context = context || Form.factories;
context[factory.getName()] = factory;
return true;
};
Form.extendFactory = function (parentName, factory, context) {
context = context || Form.factories;
if (!context[parentName]) {
return false;
}
return Form.registerFactory(factory.getName(), $.extend({}, context[parentName], factory));
};
Form.prototype.findElements = function(type) {
var selector = '[' + this.fieldIndicator + (type ? '="' + type + '"' : '') + ']';
return Form.findElements(this.form, selector);
};
Form.prototype.registerFactory = function(factory) {
var registered = Form.registerFactory(factory, this.factories);
if (registered) {
addTypes(this, this.factories[factory.getName()]);
}
};
Form.prototype.extendFactory = function(parentName, factory) {
var registered = Form.extendFactory(parentN, factory, this.factories);
if (registered) {
addTypes(this, this.factories[factory.getName()]);
}
};
Form.prototype.getElements = function() {
if (!this.scanned) {
scan(this);
this.scanned = true;
}
return this.elements;
};
Form.prototype.getValues = function(all) {
var elements = this.getElements(),
values = {};
for (var i = elements.length - 1; i >= 0; i--) {
var e = elements[i].element,
isInDOM = $('body').find(e.el).length;
if (!all && (!isInDOM || !e.valid() || e.disabled())) {
continue;
}
$.extend(values, e.formValues());
}
return values;
};
Form.prototype.submit = function(ajax) {
var action = this.form.attr('action') || document.location,
method = this.form.attr('method') || 'POST',
values = {};
// Get form values that are not handled by JS framework
Form.findElements(this.form, 'input, textarea', '', false).each(function(input) {
var input = $(this),
name = input.attr('name'),
parent = input.parent('[data-grav-disabled]'),
value = input.val();
if (input.is(':disabled') || (parent && parent.data('grav-disabled') == 'true')) { return; }
if (name) {
values[name] = value;
}
});
$.extend(values, this.getValues());
if ($(root.clickedButton).attr('name') == 'task') {
values.task = $(root.clickedButton).attr('value');
if (values.task == 'saveas') {
values.lang = $(root.clickedButton).attr('lang');
}
if (values.task == 'switchlanguage') {
values.lang = $(root.clickedButton).attr('lang');
values.redirect = $(root.clickedButton).attr('redirect');
}
}
if (!values.task) {
values.task = 'save';
}
if (!ajax) {
var form = $('<form>').attr({ method: method, action: action });
for (var name in values) { if (values.hasOwnProperty(name)) {
$('<input>').attr({ type: 'hidden', name: name, value: values[name] }).appendTo(form);
}
}
return form.appendTo('body').submit();
} else {
return $.ajax({ method: method, url: action, data: values });
}
};
root.Form = Form;
})();
@@ -0,0 +1,4 @@
/**
* @preserve HTML5 Shiv prev3.7.1 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=x.elements;return"string"==typeof a?a.split(" "):a}function e(a){var b=w[a[u]];return b||(b={},v++,a[u]=v,w[v]=b),b}function f(a,c,d){if(c||(c=b),p)return c.createElement(a);d||(d=e(c));var f;return f=d.cache[a]?d.cache[a].cloneNode():t.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!f.canHaveChildren||s.test(a)||f.tagUrn?f:d.frag.appendChild(f)}function g(a,c){if(a||(a=b),p)return a.createDocumentFragment();c=c||e(a);for(var f=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)f.createElement(h[g]);return f}function h(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return x.shivMethods?f(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(x,b.frag)}function i(a){a||(a=b);var d=e(a);return!x.shivCSS||o||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),p||h(a,d),a}function j(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(k(b)));return g}function k(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(z+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function l(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+z+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function m(a){for(var b=a.length;b--;)a[b].removeNode()}function n(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,f,g=e(a),h=a.namespaces,i=a.parentWindow;return!A||a.printShived?a:("undefined"==typeof h[z]&&h.add(z),i.attachEvent("onbeforeprint",function(){b();for(var e,g,h,i=a.styleSheets,k=[],m=i.length,n=Array(m);m--;)n[m]=i[m];for(;h=n.pop();)if(!h.disabled&&y.test(h.media)){try{e=h.imports,g=e.length}catch(o){g=0}for(m=0;g>m;m++)n.push(e[m]);try{k.push(h.cssText)}catch(o){}}k=l(k.reverse().join("")),f=j(a),d=c(a,k)}),i.attachEvent("onafterprint",function(){m(f),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var o,p,q="3.7.0",r=a.html5||{},s=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,t=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,u="_html5shiv",v=0,w={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",o="hidden"in a,p=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){o=!0,p=!0}}();var x={elements:r.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:q,shivCSS:r.shivCSS!==!1,supportsUnknownElements:p,shivMethods:r.shivMethods!==!1,type:"default",shivDocument:i,createElement:f,createDocumentFragment:g};a.html5=x,i(b);var y=/^$|\b(?:all|print)\b/,z="html5shiv",A=!p&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();x.type+=" print",x.shivPrint=n,n(b)}(this,document);
File diff suppressed because one or more lines are too long
@@ -0,0 +1,9 @@
/*
* Remodal - v0.2.0
* Flat, responsive, lightweight, easy customizable modal window plugin with declarative state notation and hash tracking.
* http://vodkabears.github.io/remodal/
*
* Made by Ilya Makarov
* Under MIT License
*/
!function(a){"use strict";function b(b,e){this.settings=a.extend({},d,e),this.modal=b,this.buildDOM(),this.addEventListeners(),this.index=a[c].lookup.push(this)-1,this.busy=!1}var c="remodal",d={hashTracking:!0,closeOnConfirm:!0,closeOnCancel:!0};a[c]={lookup:[]};var e,f,g=function(a){var b=a.css("transition-duration")||a.css("-webkit-transition-duration")||a.css("-moz-transition-duration")||a.css("-o-transition-duration")||a.css("-ms-transition-duration")||0,c=a.css("transition-delay")||a.css("-webkit-transition-delay")||a.css("-moz-transition-delay")||a.css("-o-transition-delay")||a.css("-ms-transition-delay")||0;return 1e3*(parseFloat(b)+parseFloat(c))},h=function(){if(a(document.body).height()<=a(window).height())return 0;var b=document.createElement("div");b.style.visibility="hidden",b.style.width="100px",document.body.appendChild(b);var c=b.offsetWidth;b.style.overflow="scroll";var d=document.createElement("div");d.style.width="100%",b.appendChild(d);var e=d.offsetWidth;return b.parentNode.removeChild(b),c-e},i=function(){a(document.body).css("padding-right","+="+h()),a("html, body").addClass(c+"_lock")},j=function(){a(document.body).css("padding-right","-="+h()),a("html, body").removeClass(c+"_lock")},k=function(a){var b,c,d={};b=a.replace(/\s*:\s*/g,":").replace(/\s*,\s*/g,","),c=b.split(",");var e,f,g;for(e=0,f=c.length;f>e;e++)c[e]=c[e].split(":"),g=c[e][1],("string"==typeof g||g instanceof String)&&(g="true"===g||("false"===g?!1:g)),("string"==typeof g||g instanceof String)&&(g=isNaN(g)?g:+g),d[c[e][0]]=g;return d};b.prototype.buildDOM=function(){this.body=a(document.body),this.bg=a("."+c+"-bg"),this.modalClose=a("<a href='#'>").addClass(c+"-close"),this.overlay=a("<div>").addClass(c+"-overlay"),this.modal.hasClass(c)||this.modal.addClass(c),this.modal.css("visibility","visible"),this.modal.append(this.modalClose),this.overlay.append(this.modal),this.body.append(this.overlay),this.confirm=this.modal.find("."+c+"-confirm"),this.cancel=this.modal.find("."+c+"-cancel");var b=g(this.overlay),d=g(this.modal),e=g(this.bg);this.td=d>b?d:b,this.td=e>this.td?e:this.td},b.prototype.addEventListeners=function(){var b=this;this.modalClose.bind("click."+c,function(a){a.preventDefault(),b.close()}),this.cancel.bind("click."+c,function(a){a.preventDefault(),b.modal.trigger("cancel"),b.settings.closeOnCancel&&b.close()}),this.confirm.bind("click."+c,function(a){a.preventDefault(),b.modal.trigger("confirm"),b.settings.closeOnConfirm&&b.close()}),a(document).bind("keyup."+c,function(a){27===a.keyCode&&b.close()}),this.overlay.bind("click."+c,function(d){var e=a(d.target);e.hasClass(c+"-overlay")&&b.close()})},b.prototype.open=function(){if(!this.busy){this.busy=!0,this.modal.trigger("open");var b=this.modal.attr("data-"+c+"-id");b&&this.settings.hashTracking&&(f=a(window).scrollTop(),location.hash=b),e&&e!==this&&(e.overlay.hide(),e.body.removeClass(c+"_active")),e=this,i(),this.overlay.show();var d=this;setTimeout(function(){d.body.addClass(c+"_active"),setTimeout(function(){d.busy=!1,d.modal.trigger("opened")},d.td+50)},25)}},b.prototype.close=function(){if(!this.busy){this.busy=!0,this.modal.trigger("close"),this.settings.hashTracking&&this.modal.attr("data-"+c+"-id")===location.hash.substr(1)&&(location.hash="",a(window).scrollTop(f)),this.body.removeClass(c+"_active");var b=this;setTimeout(function(){b.overlay.hide(),j(),b.busy=!1,b.modal.trigger("closed")},b.td+50)}},a&&(a.fn[c]=function(d){var e;return this.each(function(f,g){var h=a(g);null==h.data(c)&&(e=new b(h,d),h.data(c,e.index),e.settings.hashTracking&&h.attr("data-"+c+"-id")===location.hash.substr(1)&&e.open())}),e}),a(document).ready(function(){a(document).on("click","[data-"+c+"-target]",function(b){b.preventDefault();var d=b.currentTarget,e=d.getAttribute("data-"+c+"-target"),f=a("[data-"+c+"-id="+e+"]");a[c].lookup[f.data(c)].open()}),a(document).find("."+c).each(function(b,d){var e=a(d),f=e.data(c+"-options");f?("string"==typeof f||f instanceof String)&&(f=k(f)):f={},e[c](f)})});var l=function(b,d){var f=location.hash.replace("#","");if("undefined"==typeof d&&(d=!0),f){var g;try{g=a("[data-"+c+"-id="+f.replace(new RegExp("/","g"),"\\/")+"]")}catch(b){}if(g&&g.length){var h=a[c].lookup[g.data(c)];h&&h.settings.hashTracking&&h.open()}}else d&&e&&!e.busy&&e.settings.hashTracking&&e.close()};a(window).bind("hashchange."+c,l)}(window.jQuery||window.Zepto);
@@ -0,0 +1,541 @@
((function(){
var editors = [];
var toolbarIdentifiers = [ 'bold', 'italic', 'strike', 'link', 'image', 'blockquote', 'listUl', 'listOl' ];
if (typeof window.customToolbarElements !== 'undefined') {
window.customToolbarElements.forEach(function(customToolbarElement) {
toolbarIdentifiers.push(customToolbarElement.identifier);
});
}
var toolbarButtons = {
fullscreen: {
title : 'Fullscreen',
label : '<i class="fa fa-fw fa-expand"></i>'
},
bold : {
title : 'Bold',
label : '<i class="fa fa-fw fa-bold"></i>'
},
italic : {
title : 'Italic',
label : '<i class="fa fa-fw fa-italic"></i>'
},
strike : {
title : 'Strikethrough',
label : '<i class="fa fa-fw fa-strikethrough"></i>'
},
blockquote : {
title : 'Blockquote',
label : '<i class="fa fa-fw fa-quote-right"></i>'
},
link : {
title : 'Link',
label : '<i class="fa fa-fw fa-link"></i>'
},
image : {
title : 'Image',
label : '<i class="fa fa-fw fa-picture-o"></i>'
},
listUl : {
title : 'Unordered List',
label : '<i class="fa fa-fw fa-list-ul"></i>'
},
listOl : {
title : 'Ordered List',
label : '<i class="fa fa-fw fa-list-ol"></i>'
}
};
if (typeof window.customToolbarElements !== 'undefined') {
window.customToolbarElements.forEach(function(customToolbarElement) {
toolbarButtons[customToolbarElement.identifier] = customToolbarElement.button;
});
}
var debounce = function(func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) func.apply(context, args);
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) func.apply(context, args);
};
};
var template = [
'<div class="grav-mdeditor clearfix" data-mode="tab" data-active-tab="code">',
'<div class="grav-mdeditor-navbar">',
'<ul class="grav-mdeditor-navbar-nav grav-mdeditor-toolbar"></ul>',
'<div class="grav-mdeditor-navbar-flip">',
'<ul class="grav-mdeditor-navbar-nav">',
'<li class="grav-mdeditor-button-code mdeditor-active"><a>{:lblCodeview}</a></li>',
'<li class="grav-mdeditor-button-preview"><a>{:lblPreview}</a></li>',
'<li><a data-mdeditor-button="fullscreen"><i class="fa fa-fw fa-expand"></i></a></li>',
'</ul>',
'</div>',
'<p class="grav-mdeditor-preview-text" style="display: none;">Preview</p>',
'</div>',
'<div class="grav-mdeditor-content">',
'<div class="grav-mdeditor-code"></div>',
'<div class="grav-mdeditor-preview"><div></div></div>',
'</div>',
'</div>'
].join('');
var MDEditor = function(editor, options){
var tpl = template, $this = this,
task = 'task' + GravAdmin.config.param_sep;
this.defaults = {
markdown : false,
autocomplete : true,
height : 500,
codemirror : { mode: 'htmlmixed', theme: 'paper', lineWrapping: true, dragDrop: true, autoCloseTags: true, matchTags: true, autoCloseBrackets: true, matchBrackets: true, indentUnit: 4, indentWithTabs: false, tabSize: 4, hintOptions: {completionSingle:false}, extraKeys: {"Enter": "newlineAndIndentContinueMarkdownList"} },
toolbar : toolbarIdentifiers,
lblPreview : '<i class="fa fa-fw fa-eye"></i>',
lblCodeview : '<i class="fa fa-fw fa-code"></i>',
lblMarkedview: '<i class="fa fa-fw fa-code"></i>'
}
this.element = $(editor);
this.options = $.extend({}, this.defaults, options);
this.CodeMirror = CodeMirror;
this.buttons = {};
tpl = tpl.replace(/\{:lblPreview\}/g, this.options.lblPreview);
tpl = tpl.replace(/\{:lblCodeview\}/g, this.options.lblCodeview);
this.mdeditor = $(tpl);
this.content = this.mdeditor.find('.grav-mdeditor-content');
this.toolbar = this.mdeditor.find('.grav-mdeditor-toolbar');
this.preview = this.mdeditor.find('.grav-mdeditor-preview').children().eq(0);
this.code = this.mdeditor.find('.grav-mdeditor-code');
this.element.before(this.mdeditor).appendTo(this.code);
this.editor = this.CodeMirror.fromTextArea(this.element[0], this.options.codemirror);
this.editor.mdeditor = this;
if (this.options.markdown) {
this.editor.setOption('mode', 'gfm');
}
this.editor.on('change', debounce(function() { $this.render(); }, 150));
this.editor.on('change', function() { $this.editor.save(); });
this.code.find('.CodeMirror').css('height', this.options.height);
var editor = this.editor;
$("#gravDropzone").delegate('[data-dz-insert]', 'click', function(e) {
var target = $(e.currentTarget).parent('.dz-preview').find('.dz-filename');
editor.focus();
var filename = encodeURI(target.text());
filename = filename.replace(/@3x|@2x|@1x/, '');
filename = filename.replace(/\(/g, '%28');
filename = filename.replace(/\)/g, '%29');
if (filename.match(/\.(jpg|jpeg|png|gif)$/)) {
editor.doc.replaceSelection('![](' + filename + ')');
} else {
editor.doc.replaceSelection('[' + decodeURI(filename) + '](' + filename + ')');
}
});
this.preview.container = this.preview;
this.mdeditor.on('click', '.grav-mdeditor-button-code, .grav-mdeditor-button-preview', function(e) {
var task = 'task' + GravAdmin.config.param_sep;
e.preventDefault();
if ($this.mdeditor.attr('data-mode') == 'tab') {
if ($(this).hasClass('grav-mdeditor-button-preview')) {
GravAjax({
dataType: 'JSON',
url: $this.element.data('grav-urlpreview') + '/' + task + 'processmarkdown',
method: 'post',
data: $this.element.parents('form').serialize(),
toastErrors: true,
success: function (response) {
$this.preview.container.html(response.message);
}
});
}
$this.mdeditor.find('.grav-mdeditor-button-code, .grav-mdeditor-button-preview').removeClass('mdeditor-active').filter(this).addClass('mdeditor-active');
$this.activetab = $(this).hasClass('grav-mdeditor-button-code') ? 'code' : 'preview';
$this.mdeditor.attr('data-active-tab', $this.activetab);
$this.editor.refresh();
if ($this.activetab == 'preview') {
$('.grav-mdeditor-toolbar').fadeOut();
setTimeout(function() {
$('.grav-mdeditor-preview-text').fadeIn();
}, 500);
} else {
$('.grav-mdeditor-preview-text').fadeOut();
setTimeout(function() {
$('.grav-mdeditor-toolbar').fadeIn();
}, 500);
}
}
});
this.mdeditor.on('click', 'a[data-mdeditor-button]', function() {
if (!$this.code.is(':visible')) return;
$this.element.trigger('action.' + $(this).data('mdeditor-button'), [$this.editor]);
});
this.preview.parent().css('height', this.code.height());
// autocomplete
if (this.options.autocomplete && this.CodeMirror.showHint && this.CodeMirror.hint && this.CodeMirror.hint.html) {
this.editor.on('inputRead', debounce(function() {
var doc = $this.editor.getDoc(), POS = doc.getCursor(), mode = $this.CodeMirror.innerMode($this.editor.getMode(), $this.editor.getTokenAt(POS).state).mode.name;
if (mode == 'xml') { //html depends on xml
var cur = $this.editor.getCursor(), token = $this.editor.getTokenAt(cur);
if (token.string.charAt(0) == '<' || token.type == 'attribute') {
$this.CodeMirror.showHint($this.editor, $this.CodeMirror.hint.html, { completeSingle: false });
}
}
}, 100));
}
this.debouncedRedraw = debounce(function () { $this.redraw(); }, 5);
/*this.element.attr('data-grav-check-display', 1).on('grav-check-display', function(e) {
if($this.mdeditor.is(":visible")) $this.fit();
});*/
editors.push(this);
// Methods
this.addButton = function(name, button) {
this.buttons[name] = button;
};
this.addButtons = function(buttons) {
$.extend(this.buttons, buttons);
};
this._buildtoolbar = function() {
if (!(this.options.toolbar && this.options.toolbar.length)) return;
var $this = this, bar = [];
this.toolbar.empty();
this.options.toolbar.forEach(function(button) {
if (!$this.buttons[button]) return;
var title = $this.buttons[button].title ? $this.buttons[button].title : button;
var buttonClass = $this.buttons[button].class ? 'class="' + $this.buttons[button].class + '"' : '';
bar.push('<li><a data-mdeditor-button="'+button+'" title="'+title+'" '+buttonClass+' data-uk-tooltip>'+$this.buttons[button].label+'</a></li>');
});
this.toolbar.html(bar.join('\n'));
};
this.fit = function() {
var mode = this.options.mode;
if (mode == 'split' && this.mdeditor.width() < this.options.maxsplitsize) {
mode = 'tab';
}
if (mode == 'tab') {
if (!this.activetab) {
this.activetab = 'code';
this.mdeditor.attr('data-active-tab', this.activetab);
}
this.mdeditor.find('.grav-mdeditor-button-code, .grav-mdeditor-button-preview').removeClass('uk-active')
.filter(this.activetab == 'code' ? '.grav-mdeditor-button-code' : '.grav-mdeditor-button-preview')
.addClass('uk-active');
}
this.editor.refresh();
this.preview.parent().css('height', this.code.height());
this.mdeditor.attr('data-mode', mode);
};
this.redraw = function() {
this._buildtoolbar();
this.render();
this.fit();
};
this.getMode = function() {
return this.editor.getOption('mode');
};
this.getCursorMode = function() {
var param = { mode: 'html'};
this.element.trigger('cursorMode', [param]);
return param.mode;
};
this.render = function() {
this.currentvalue = this.editor.getValue().replace(/^---([\s\S]*?)---\n{1,}/g, '');
// empty code
if (!this.currentvalue) {
this.element.val('');
this.preview.container.html('');
return;
}
this.element.trigger('render', [this]);
this.element.trigger('renderLate', [this]);
this.preview.container.html(this.currentvalue);
};
this.addShortcut = function(name, callback) {
var map = {};
if (!$.isArray(name)) {
name = [name];
}
name.forEach(function(key) {
map[key] = callback;
});
this.editor.addKeyMap(map);
return map;
};
this.addShortcutAction = function(action, shortcuts) {
var editor = this;
this.addShortcut(shortcuts, function() {
editor.element.trigger('action.' + action, [editor.editor]);
});
};
this.replaceSelection = function(replace, action) {
var text = this.editor.getSelection(),
indexOf = -1,
cur = this.editor.getCursor(),
curLine = this.editor.getLine(cur.line),
start = cur.ch,
end = start;
if (!text.length) {
while (end < curLine.length && /[\w$]+/.test(curLine.charAt(end))) ++end;
while (start && /[\w$]+/.test(curLine.charAt(start - 1))) --start;
var curWord = start != end && curLine.slice(start, end);
if (curWord) {
this.editor.setSelection({ line: cur.line, ch: start}, { line: cur.line, ch: end });
text = curWord;
} else {
indexOf = replace.indexOf('$1');
}
}
var html = replace.replace('$1', text);
this.editor.replaceSelection(html, 'end');
if (indexOf !== -1) {
this.editor.setCursor({ line: cur.line, ch: start + indexOf });
} else {
if (action == 'link' || action == 'image') {
this.editor.setCursor({ line: cur.line, ch: html.length -1 });
}
}
this.editor.focus();
};
this.replaceLine = function(replace, action) {
var pos = this.editor.getDoc().getCursor(),
text = this.editor.getLine(pos.line),
html = replace.replace('$1', text);
this.editor.replaceRange(html , { line: pos.line, ch: 0 }, { line: pos.line, ch: text.length });
this.editor.setCursor({ line: pos.line, ch: html.length });
this.editor.focus();
};
this.save = function() {
this.editor.save();
};
this._initToolbar = function(editor) {
editor.addButtons(toolbarButtons);
addAction('bold', '**$1**');
addAction('italic', '_$1_');
addAction('strike', '~~$1~~');
addAction('blockquote', '> $1', 'replaceLine');
addAction('link', '[$1](http://)');
addAction('image', '![$1](http://)');
editor.element.on('action.listUl', function() {
if (editor.getCursorMode() == 'markdown') {
var cm = editor.editor,
pos = cm.getDoc().getCursor(true),
posend = cm.getDoc().getCursor(false);
for (var i=pos.line; i<(posend.line+1);i++) {
cm.replaceRange('* '+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
}
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
cm.focus();
}
});
editor.element.on('action.listOl', function() {
if (editor.getCursorMode() == 'markdown') {
var cm = editor.editor,
pos = cm.getDoc().getCursor(true),
posend = cm.getDoc().getCursor(false),
prefix = 1;
if (pos.line > 0) {
var prevline = cm.getLine(pos.line-1), matches;
if(matches = prevline.match(/^(\d+)\./)) {
prefix = Number(matches[1])+1;
}
}
for (var i=pos.line; i<(posend.line+1);i++) {
cm.replaceRange(prefix+'. '+cm.getLine(i), { line: i, ch: 0 }, { line: i, ch: cm.getLine(i).length });
prefix++;
}
cm.setCursor({ line: posend.line, ch: cm.getLine(posend.line).length });
cm.focus();
}
});
if (typeof window.customToolbarElements !== 'undefined') {
window.customToolbarElements.forEach(function(customToolbarElement) {
editor.element.on('action.' + customToolbarElement.identifier, function() {
if (editor.getCursorMode() == 'markdown') {
customToolbarElement.processAction(editor);
}
});
});
}
editor.element.on('cursorMode', function(e, param) {
if (editor.editor.options.mode == 'gfm') {
var pos = editor.editor.getDoc().getCursor();
if (!editor.editor.getTokenAt(pos).state.base.htmlState) {
param.mode = 'markdown';
}
}
});
$.extend(editor, {
enableMarkdown: function() {
enableMarkdown()
this.render();
},
disableMarkdown: function() {
this.editor.setOption('mode', 'htmlmixed');
this.mdeditor.find('.grav-mdeditor-button-code a').html(this.options.lblCodeview);
this.render();
}
});
// switch markdown mode on event
editor.element.on({
enableMarkdown : function() { editor.enableMarkdown(); },
disableMarkdown : function() { editor.disableMarkdown(); }
});
function enableMarkdown() {
editor.editor.setOption('mode', 'gfm');
editor.mdeditor.find('.grav-mdeditor-button-code a').html(editor.options.lblMarkedview);
}
editor.mdeditor.on('click', 'a[data-mdeditor-button="fullscreen"]', function() {
editor.mdeditor.toggleClass('grav-mdeditor-fullscreen');
var wrap = editor.editor.getWrapperElement();
if (editor.mdeditor.hasClass('grav-mdeditor-fullscreen')) {
editor.editor.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, width: wrap.style.width, height: wrap.style.height};
wrap.style.width = '';
wrap.style.height = editor.content.height()+'px';
document.documentElement.style.overflow = 'hidden';
} else {
document.documentElement.style.overflow = '';
var info = editor.editor.state.fullScreenRestore;
wrap.style.width = info.width; wrap.style.height = info.height;
window.scrollTo(info.scrollLeft, info.scrollTop);
}
setTimeout(function() {
editor.fit();
$(window).trigger('resize');
}, 50);
});
editor.addShortcut(['Ctrl-S', 'Cmd-S'], function() { editor.element.trigger('mdeditor-save', [editor]); });
editor.addShortcutAction('bold', ['Ctrl-B', 'Cmd-B']);
editor.addShortcutAction('italic', ['Ctrl-I', 'Cmd-I']);
function addAction(name, replace, mode) {
editor.element.on('action.'+name, function() {
if (editor.getCursorMode() == 'markdown') {
editor[mode == 'replaceLine' ? 'replaceLine' : 'replaceSelection'](replace, name);
}
});
}
}
// toolbar actions
this._initToolbar($this);
this._buildtoolbar();
}
// init
$(function(){
$('textarea[data-grav-mdeditor]').each(function() {
var editor = $(this), obj;
if (!editor.data('mdeditor')) {
obj = MDEditor(editor, JSON.parse(editor.attr('data-grav-mdeditor') || '{}'));
}
});
})
})());
@@ -0,0 +1,82 @@
$(document).ready(function(){
var large_desktop_container = 75.000;
var desktop_container= 60.000;
var tablet_container= 48.000;
var large_mobile_container= 30.000;
var mobile_only= tablet_container - 0.062;
var no_mobile= tablet_container;
var small_mobile_range= large_mobile_container;
var media_mobile = window.matchMedia('(max-width:' + mobile_only + 'em)');
var titlebar = document.getElementById("titlebar");
var sidebar = document.getElementById("admin-sidebar");
var overlay = document.getElementById("overlay");
var mobile = {
setup: function() {
//add event listeners
titlebar.addEventListener('click',mobile.titlebar_click);
sidebar.addEventListener('click',mobile.sidebar_click);
overlay.addEventListener('click',mobile.overlay_click);
},
teardown: function() {
//remove event listeners
titlebar.removeEventListener('click',mobile.titlebar_click);
sidebar.removeEventListener('click',mobile.sidebar_click);
overlay.removeEventListener('click',mobile.overlay_click);
},
titlebar_click: function(event){
//titlebar on click - open sidebar (make sure not a button bar child)
if(!$(event.target).parents('.button-bar').length>0){
$(sidebar).toggle('slide');
overlay.style.display = "inherit";
}
},
sidebar_click: function(){
//sidebar on click - close sidebar
if(event.target == sidebar || event.target == selected[0]) {
$(sidebar).toggle('slide');
overlay.style.display = "none";
}
},
overlay_click: function(){
//overlay on click - close sidebar
$(sidebar).toggle('slide');
overlay.style.display = "none";
}
};
var other = {
setup: function() {
if(sidebar && sidebar.style.display == 'none') {
sidebar.style.display = 'block';
}
},
teardown: function() {
//teardown actions here please
//console.log("Other teardown");
},
onClick: function(){
//onclick event stuff here;
//console.log("Other onClick");
}
};
media_mobile.addListener(function(data) {
if(data.matches) {
other.teardown();
mobile.setup();
} else {
mobile.teardown();
other.setup();
}
});
if (media_mobile.matches) {
mobile.setup();
} else {
other.setup();
}
});
File diff suppressed because one or more lines are too long
@@ -0,0 +1,336 @@
$(function(){
var root = window || {};
root = root.GravJS = root.GravJS || {};
//Make it global because used by ./forms/form.js
root.currentValues = getState();
var clickedLink;
// selectize
var pageFilter = $('input.page-filter'),
pageTypes = pageFilter.data('template-types'),
options = [
{flag: 'Modular', key: 'Modular', cat: 'mode'},
{flag: 'Visible', key: 'Visible', cat: 'mode'},
{flag: 'Routable', key: 'Routable', cat: 'mode'},
{flag: 'Published', key: 'Published', cat: 'mode'},
{flag: 'Non-Modular', key: 'NonModular', cat: 'mode'},
{flag: 'Non-Visible', key: 'NonVisible', cat: 'mode'},
{flag: 'Non-Routable', key: 'NonRoutable', cat: 'mode'},
{flag: 'Non-Published', key: 'NonPublished', cat: 'mode'},
];
if (pageFilter && pageTypes) {
jQuery.each(pageTypes, function(key, name){
options.push({flag: name, key: key, cat: 'type'});
})
pageFilter.selectize({
maxItems: null,
valueField: 'key',
labelField: 'flag',
searchField: ['flag', 'key'],
options: options,
optgroups: [
{id: 'mode', name: 'Page Modes'},
{id: 'type', name: 'Page Types'},
],
optgroupField: 'cat',
optgroupLabelField: 'name',
optgroupValueField: 'id',
optgroupOrder: ['mode', 'type'],
plugins: ['optgroup_columns']
});
}
var childrenToggles = $('[data-toggle="children"]'),
storage = sessionStorage.getItem('grav:admin:pages'),
collapseAll = function(store) {
childrenToggles.each(function(i, element){
var icon = $(element).find('.page-icon'),
open = icon.hasClass('children-open'),
key = $(element).closest('[data-nav-id]').data('nav-id'),
children = $(element).closest('li.page-item').find('ul:first');
if (open) {
children.hide();
if (store) delete storage[key];
icon.removeClass('children-open').addClass('children-closed');
}
if (store) sessionStorage.setItem('grav:admin:pages', JSON.stringify(storage));
});
},
expandAll = function(store) {
childrenToggles.each(function(i, element){
var icon = $(element).find('.page-icon'),
open = icon.hasClass('children-open'),
key = $(element).closest('[data-nav-id]').data('nav-id'),
children = $(element).closest('li.page-item').find('ul:first');
if (!open) {
children.show();
if (store) storage[key] = 1;
icon.removeClass('children-closed').addClass('children-open');
}
if (store) sessionStorage.setItem('grav:admin:pages', JSON.stringify(storage));
});
},
restoreStates = function() {
collapseAll();
for (var key in storage) {
var element = $('[data-nav-id="' + key + '"]'),
icon = element.find('.page-icon').first(),
open = icon.hasClass('children-open'),
children = element.closest('li.page-item').find('ul:first');
children.show();
icon.removeClass('children-closed').addClass('children-open');
}
};
if (!storage) {
sessionStorage.setItem('grav:admin:pages', (storage = '{}'));
}
storage = JSON.parse(storage);
restoreStates();
var startFilterPages = function () {
var task = 'task' + GravAdmin.config.param_sep;
$('input[name="page-search"]').focus();
var flags = $('input[name="page-filter"]').val(),
query = $('input[name="page-search"]').val();
if (!flags.length && !query.length) {
GravAjax.jqxhr.abort();
return finishFilterPages([], true);
}
GravAjax({
dataType: 'json',
method: 'POST',
url: GravAdmin.config.base_url_relative + '/pages-filter.json/' + task + 'filterPages',
data: {
flags: flags,
query: query
},
toastErrors: true,
success: function (result, status) {
finishFilterPages(result.results);
}
});
};
var finishFilterPages = function (pages, reset) {
var items = $('[data-nav-id]');
items.removeClass('search-match');
if (reset) {
items.addClass('search-match');
restoreStates();
} else {
pages.forEach(function (id) {
var match = items.filter('[data-nav-id="' + id + '"]'),
parents = match.parents('[data-nav-id]');
match.addClass('search-match');
match.find('[data-nav-id]').addClass('search-match');
parents.addClass('search-match');
parents.find('[data-toggle="children"]').each(function(index, element){
var icon = $(this).find('.page-icon'),
open = icon.hasClass('children-open'),
children = $(this).closest('li.page-item').find('ul:first');
if (!open) {
children.show();
icon.removeClass('children-closed').addClass('children-open');
}
});
});
}
items.each(function (key, item) {
if ($(item).hasClass('search-match')) {
$(item).show();
} else {
$(item).hide();
}
});
};
// selectize
$('input[name="page-search"]').on('input', startFilterPages);
$('input[name="page-filter"]').on('change', startFilterPages);
// auto generate folder based on title
// on user input on folder, autogeneration stops
// if user empties the folder, autogeneration restarts
$('input[name="folder"]').on('input', function(){
$(this).data('user-custom-folder', true);
if (!$(this).val()) $(this).data('user-custom-folder', false);
});
$('input[name="title"]').on('input', function(e){
if (!$('input[name="folder"]').data('user-custom-folder')) {
folder = $.slugify($(this).val());
$('input[name="folder"]').val(folder);
}
});
$('#slug-target').slugify('#slug-source');
$('input[name="folder"]').on('input', function(e){
var start = this.selectionStart,
end = this.selectionEnd;
value = $(this).val().toLowerCase().replace(/\s/g, '-').replace(/[^a-z0-9_\-]/g, '');
$(this).val(value);
// restore cursor position
this.setSelectionRange(start, end);
});
childrenToggles.on('click', function () {
var icon = $(this).find('.page-icon'),
open = icon.hasClass('children-open'),
key = $(this).closest('[data-nav-id]').data('nav-id'),
children = $(this).closest('li.page-item').find('ul:first');
if (open) {
children.hide();
delete storage[key];
icon.removeClass('children-open').addClass('children-closed');
} else {
children.show();
storage[key] = true;
icon.removeClass('children-closed').addClass('children-open');
}
sessionStorage.setItem('grav:admin:pages', JSON.stringify(storage));
});
$('[data-page-toggleall]').on('click', function() {
var state = $(this).data('page-toggleall');
if (state == 'collapse') collapseAll(true);
else expandAll(true);
});
$('#admin-main button').on('click', function(){
$(window).off('beforeunload');
});
$('[data-remodal-id] form').on('submit', function(){
$(window).off('beforeunload');
});
$("#admin-mode-toggle input[name=mode-switch]").on('change', function(e){
var value = $(this).val(),
uri = $(this).data('leave-url');
if (root.currentValues == getState()) {
setTimeout(function(){
window.location.href = uri;
}, 200)
return true;
}
e.preventDefault();
var confirm = $.remodal.lookup[$('[data-remodal-id=changes]').data('remodal')],
buttons = $('[data-remodal-id=changes] a.button'),
action;
buttons.on('click', function(e){
e.preventDefault();
action = $(this).data('leave-action');
buttons.off('click');
confirm.close();
if (action == 'continue') {
$(window).off('beforeunload');
window.location.href = $("#admin-mode-toggle input[name=mode-switch]:checked").data('leave-url');
} else {
$('input[name=mode-switch][checked]').prop('checked', true);
}
});
confirm.open();
});
$('a[href]:not([href^=#])').on('click', function(e){
if (root.currentValues != getState()){
e.preventDefault();
clickedLink = $(this).attr('href');
var confirm = $.remodal.lookup[$('[data-remodal-id=changes]').data('remodal')],
buttons = $('[data-remodal-id=changes] a.button'),
action;
buttons.on('click', function(e){
e.preventDefault();
action = $(this).data('leave-action');
buttons.off('click');
confirm.close();
if (action == 'continue') {
$(window).off('beforeunload');
window.location.href = clickedLink;
}
});
confirm.open();
}
});
// deletion
$('[data-remodal-target="delete"]').on('click', function(){
var okdelete = $('[data-remodal-id=delete] a.button');
okdelete.data('delete-action', $(this).data('delete-url'));
});
$('[data-delete-action]').on('click', function(){
var confirm = $.remodal.lookup[$('[data-remodal-id=delete]').data('remodal')],
okdelete = $(this).data('delete-action');
window.location.href = okdelete;
confirm.close();
});
$(window).on('beforeunload', function(){
if (root.currentValues != getState()){
return "You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will lose your unsaved changes";
}
});
// Move dropdown sync (on dropdown change)
/*$('body').on('change', '[data-page-move] select', function(){
var route = jQuery('form#blueprints').first().find('select[name="route"]'),
value = $(this).val();
if (route.length && route.val() !== value) {
route.val(value);
route.data('selectize').setValue(value);
}
});*/
// Move dropdown sync (on continue)
$('[data-page-move] button').on('click', function(){
var route = jQuery('form#blueprints').first().find('select[name="route"]'),
value = $('[data-page-move] select').val();
if (route.length && route.val() !== value) {
var selectize = route.data('selectize');
route.val(value);
if (selectize) selectize.setValue(value);
}
});
});
File diff suppressed because one or more lines are too long
+3
View File
@@ -0,0 +1,3 @@
/*! jquery-slugify - v1.2.1 - 2015-08-02
* Copyright (c) 2015 madflow; Licensed */
!function(a){a.fn.slugify=function(b,c){return this.each(function(){var d=a(this),e=a(b);d.on("keyup change",function(){""!==d.val()&&void 0!==d.val()?d.data("locked",!0):d.data("locked",!1)}),e.on("keyup change",function(){!0!==d.data("locked")&&(d.is("input")||d.is("textarea")?d.val(a.slugify(e.val(),c)):d.text(a.slugify(e.val(),c)))})})},a.slugify=function(b,c){return c=a.extend({},a.slugify.options,c),c.lang=c.lang||a("html").prop("lang"),"function"==typeof c.preSlug&&(b=c.preSlug(b)),b=c.slugFunc(b,c),"function"==typeof c.postSlug&&(b=c.postSlug(b)),b},a.slugify.options={preSlug:null,postSlug:null,slugFunc:function(a,b){return window.getSlug(a,b)}}}(jQuery);
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
!function(e){e(["jquery"],function(e){return function(){function t(e,t,n){return f({type:O.error,iconClass:g().iconClasses.error,message:e,optionsOverride:n,title:t})}function n(t,n){return t||(t=g()),v=e("#"+t.containerId),v.length?v:(n&&(v=c(t)),v)}function i(e,t,n){return f({type:O.info,iconClass:g().iconClasses.info,message:e,optionsOverride:n,title:t})}function o(e){w=e}function s(e,t,n){return f({type:O.success,iconClass:g().iconClasses.success,message:e,optionsOverride:n,title:t})}function a(e,t,n){return f({type:O.warning,iconClass:g().iconClasses.warning,message:e,optionsOverride:n,title:t})}function r(e){var t=g();v||n(t),l(e,t)||u(t)}function d(t){var i=g();return v||n(i),t&&0===e(":focus",t).length?void h(t):void(v.children().length&&v.remove())}function u(t){for(var n=v.children(),i=n.length-1;i>=0;i--)l(e(n[i]),t)}function l(t,n){return t&&0===e(":focus",t).length?(t[n.hideMethod]({duration:n.hideDuration,easing:n.hideEasing,complete:function(){h(t)}}),!0):!1}function c(t){return v=e("<div/>").attr("id",t.containerId).addClass(t.positionClass).attr("aria-live","polite").attr("role","alert"),v.appendTo(e(t.target)),v}function p(){return{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",target:"body",closeHtml:"<button>&times;</button>",newestOnTop:!0,preventDuplicates:!1,progressBar:!1}}function m(e){w&&w(e)}function f(t){function i(t){return!e(":focus",l).length||t?(clearTimeout(O.intervalId),l[r.hideMethod]({duration:r.hideDuration,easing:r.hideEasing,complete:function(){h(l),r.onHidden&&"hidden"!==b.state&&r.onHidden(),b.state="hidden",b.endTime=new Date,m(b)}})):void 0}function o(){(r.timeOut>0||r.extendedTimeOut>0)&&(u=setTimeout(i,r.extendedTimeOut),O.maxHideTime=parseFloat(r.extendedTimeOut),O.hideEta=(new Date).getTime()+O.maxHideTime)}function s(){clearTimeout(u),O.hideEta=0,l.stop(!0,!0)[r.showMethod]({duration:r.showDuration,easing:r.showEasing})}function a(){var e=(O.hideEta-(new Date).getTime())/O.maxHideTime*100;f.width(e+"%")}var r=g(),d=t.iconClass||r.iconClass;if(r.preventDuplicates){if(t.message===C)return;C=t.message}"undefined"!=typeof t.optionsOverride&&(r=e.extend(r,t.optionsOverride),d=t.optionsOverride.iconClass||d),T++,v=n(r,!0);var u=null,l=e("<div/>"),c=e("<div/>"),p=e("<div/>"),f=e("<div/>"),w=e(r.closeHtml),O={intervalId:null,hideEta:null,maxHideTime:null},b={toastId:T,state:"visible",startTime:new Date,options:r,map:t};return t.iconClass&&l.addClass(r.toastClass).addClass(d),t.title&&(c.append(t.title).addClass(r.titleClass),l.append(c)),t.message&&(p.append(t.message).addClass(r.messageClass),l.append(p)),r.closeButton&&(w.addClass("toast-close-button").attr("role","button"),l.prepend(w)),r.progressBar&&(f.addClass("toast-progress"),l.prepend(f)),l.hide(),r.newestOnTop?v.prepend(l):v.append(l),l[r.showMethod]({duration:r.showDuration,easing:r.showEasing,complete:r.onShown}),r.timeOut>0&&(u=setTimeout(i,r.timeOut),O.maxHideTime=parseFloat(r.timeOut),O.hideEta=(new Date).getTime()+O.maxHideTime,r.progressBar&&(O.intervalId=setInterval(a,10))),l.hover(s,o),!r.onclick&&r.tapToDismiss&&l.click(i),r.closeButton&&w&&w.click(function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&e.cancelBubble!==!0&&(e.cancelBubble=!0),i(!0)}),r.onclick&&l.click(function(){r.onclick(),i()}),m(b),r.debug&&console&&console.log(b),l}function g(){return e.extend({},p(),b.options)}function h(e){v||(v=n()),e.is(":visible")||(e.remove(),e=null,0===v.children().length&&v.remove())}var v,w,C,T=0,O={error:"error",info:"info",success:"success",warning:"warning"},b={clear:r,remove:d,error:t,getContainer:n,info:i,options:{},subscribe:o,success:s,version:"2.1.0",warning:a};return b}()})}("function"==typeof define&&define.amd?define:function(e,t){"undefined"!=typeof module&&module.exports?module.exports=t(require("jquery")):window.toastr=t(window.jQuery)});