First commit
This commit is contained in:
commit
c6e2478c40
13918 changed files with 2303184 additions and 0 deletions
|
@ -0,0 +1,114 @@
|
|||
// https://civicrm.org/licensing
|
||||
(function($, _) {
|
||||
'use strict';
|
||||
/* jshint validthis: true */
|
||||
|
||||
var configRowTpl = _.template($('#config-row-tpl').html()),
|
||||
options;
|
||||
|
||||
// Weird conflict with drupal styles
|
||||
$('body').removeClass('toolbar');
|
||||
|
||||
function format(item) {
|
||||
var icon = '<span class="ui-icon ui-icon-gear"></span>';
|
||||
if (item.icon) {
|
||||
icon = '<img src="' + CRM.config.resourceBase + item.icon + '" />';
|
||||
}
|
||||
return icon + ' ' + item.text;
|
||||
}
|
||||
|
||||
function initOptions(data) {
|
||||
options = _.filter(data, function(n) {
|
||||
return $.inArray(n.id, CRM.vars.ckConfig.blacklist) < 0;
|
||||
});
|
||||
addOption();
|
||||
$.each(CRM.vars.ckConfig.settings, function(key, val) {
|
||||
if ($.inArray(key, CRM.vars.ckConfig.blacklist) < 0) {
|
||||
var $opt = $('.crm-config-option-row:last input.crm-config-option-name');
|
||||
$opt.val(key).change();
|
||||
$opt.siblings('span').find(':input').val(val);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function changeOptionName() {
|
||||
var $el = $(this),
|
||||
name = $el.val();
|
||||
$el.next('span').remove();
|
||||
if (name) {
|
||||
if (($('input.crm-config-option-name').filter(function() {return !this.value;})).length < 1) {
|
||||
addOption();
|
||||
}
|
||||
var type = $el.select2('data').type;
|
||||
if (type === 'Boolean') {
|
||||
$el.after('<span> = <select class="crm-form-select" name="config_' + name + '"><option value="false">false</option><option value="true">true</option></select></span>');
|
||||
}
|
||||
else {
|
||||
$el.after('<span> = <input class="crm-form-text ' + (type==='Number' ? 'eight" type="number"' : 'huge" type="text"') + ' name="config_' + name + '"/></span>');
|
||||
}
|
||||
} else {
|
||||
$el.closest('div').remove();
|
||||
}
|
||||
}
|
||||
|
||||
function addOption() {
|
||||
$('#crm-custom-config-options').append($(configRowTpl({})));
|
||||
$('div:last input.crm-config-option-name', '#crm-custom-config-options').crmSelect2({
|
||||
data: {results: options, text: 'id'},
|
||||
formatSelection: function(field) {
|
||||
return '<strong>' + field.id + '</strong> (' + field.type + ')';
|
||||
},
|
||||
formatResult: function(field) {
|
||||
return '<strong>' + field.id + '</strong> (' + field.type + ')' +
|
||||
'<div class="api-field-desc">' + field.description + '</div>';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$('#extraPlugins').crmSelect2({
|
||||
multiple: true,
|
||||
closeOnSelect: false,
|
||||
data: CRM.vars.ckConfig.plugins,
|
||||
escapeMarkup: _.identity,
|
||||
formatResult: format,
|
||||
formatSelection: format
|
||||
});
|
||||
|
||||
var toolbarModifier = new ToolbarConfigurator.ToolbarModifier( 'editor-basic' );
|
||||
|
||||
toolbarModifier.init(_.noop);
|
||||
|
||||
CKEDITOR.document.getById( 'toolbarModifierWrapper' ).append( toolbarModifier.mainContainer );
|
||||
|
||||
$(function() {
|
||||
var selectorOpen = false,
|
||||
changedWhileOpen = false;
|
||||
|
||||
$('#toolbarModifierForm')
|
||||
.on('submit', function(e) {
|
||||
$('.toolbar button:last', '#toolbarModifierWrapper')[0].click();
|
||||
$('.configContainer textarea', '#toolbarModifierWrapper').attr('name', 'config');
|
||||
})
|
||||
.on('change', '.config-param', function(e) {
|
||||
changedWhileOpen = true;
|
||||
if (!selectorOpen) {
|
||||
$('#toolbarModifierForm').submit().block();
|
||||
}
|
||||
})
|
||||
.on('change', 'input.crm-config-option-name', changeOptionName)
|
||||
// Debounce the change event so it only fires after the multiselect is closed
|
||||
.on('select2-open', 'input.config-param', function(e) {
|
||||
selectorOpen = true;
|
||||
changedWhileOpen = false;
|
||||
})
|
||||
.on('select2-close', 'input.config-param', function(e) {
|
||||
selectorOpen = false;
|
||||
if (changedWhileOpen) {
|
||||
$(this).change();
|
||||
}
|
||||
});
|
||||
|
||||
$.getJSON(CRM.config.resourceBase + 'js/wysiwyg/ck-options.json', null, initOptions);
|
||||
});
|
||||
|
||||
})(CRM.$, CRM._);
|
1177
sites/all/modules/civicrm/js/wysiwyg/ck-options.json
Normal file
1177
sites/all/modules/civicrm/js/wysiwyg/ck-options.json
Normal file
File diff suppressed because it is too large
Load diff
146
sites/all/modules/civicrm/js/wysiwyg/crm.ckeditor.js
Normal file
146
sites/all/modules/civicrm/js/wysiwyg/crm.ckeditor.js
Normal file
|
@ -0,0 +1,146 @@
|
|||
// https://civicrm.org/licensing
|
||||
(function($, _) {
|
||||
|
||||
function getInstance(item) {
|
||||
var name = $(item).attr("name"),
|
||||
id = $(item).attr("id");
|
||||
if (name && window.CKEDITOR && CKEDITOR.instances[name]) {
|
||||
return CKEDITOR.instances[name];
|
||||
}
|
||||
if (id && window.CKEDITOR && CKEDITOR.instances[id]) {
|
||||
return CKEDITOR.instances[id];
|
||||
}
|
||||
}
|
||||
|
||||
CRM.wysiwyg.supportsFileUploads = true;
|
||||
|
||||
CRM.wysiwyg._create = function(item) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
function onReady() {
|
||||
var debounce,
|
||||
editor = this;
|
||||
|
||||
editor.on('focus', function() {
|
||||
$(item).trigger('focus');
|
||||
});
|
||||
editor.on('blur', function() {
|
||||
editor.updateElement();
|
||||
$(item).trigger("blur");
|
||||
$(item).trigger("change");
|
||||
});
|
||||
editor.on('insertText', function() {
|
||||
$(item).trigger("keypress");
|
||||
});
|
||||
_.each(['key', 'pasteState'], function(evName) {
|
||||
editor.on(evName, function(evt) {
|
||||
if (debounce) clearTimeout(debounce);
|
||||
debounce = setTimeout(function() {
|
||||
editor.updateElement();
|
||||
$(item).trigger("change");
|
||||
}, 50);
|
||||
});
|
||||
});
|
||||
editor.on('pasteState', function() {
|
||||
$(item).trigger("paste");
|
||||
});
|
||||
// Hide CiviCRM menubar when editor is fullscreen
|
||||
editor.on('maximize', function (e) {
|
||||
$('#civicrm-menu').toggle(e.data === 2);
|
||||
});
|
||||
deferred.resolve();
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
var
|
||||
browseUrl = CRM.config.resourceBase + "packages/kcfinder/browse.php?cms=civicrm",
|
||||
uploadUrl = CRM.config.resourceBase + "packages/kcfinder/upload.php?cms=civicrm",
|
||||
preset = $(item).data('preset') || 'default',
|
||||
// This variable is always an array but a legacy extension could be setting it as a string.
|
||||
customConfig = (typeof CRM.config.CKEditorCustomConfig === 'string') ? CRM.config.CKEditorCustomConfig :
|
||||
(CRM.config.CKEditorCustomConfig[preset] || CRM.config.CKEditorCustomConfig.default);
|
||||
|
||||
$(item).addClass('crm-wysiwyg-enabled');
|
||||
|
||||
CKEDITOR.replace($(item)[0], {
|
||||
filebrowserBrowseUrl: browseUrl + '&type=files',
|
||||
filebrowserImageBrowseUrl: browseUrl + '&type=images',
|
||||
filebrowserFlashBrowseUrl: browseUrl + '&type=flash',
|
||||
filebrowserUploadUrl: uploadUrl + '&type=files',
|
||||
filebrowserImageUploadUrl: uploadUrl + '&type=images',
|
||||
filebrowserFlashUploadUrl: uploadUrl + '&type=flash',
|
||||
customConfig: customConfig,
|
||||
on: {
|
||||
instanceReady: onReady
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if ($(item).hasClass('crm-wysiwyg-enabled')) {
|
||||
deferred.resolve();
|
||||
}
|
||||
else if ($(item).length) {
|
||||
// Lazy-load ckeditor.js
|
||||
if (window.CKEDITOR) {
|
||||
initialize();
|
||||
} else {
|
||||
CRM.loadScript(CRM.config.resourceBase + 'bower_components/ckeditor/ckeditor.js').done(initialize);
|
||||
}
|
||||
} else {
|
||||
deferred.reject();
|
||||
}
|
||||
return deferred;
|
||||
};
|
||||
|
||||
CRM.wysiwyg.destroy = function(item) {
|
||||
$(item).removeClass('crm-wysiwyg-enabled');
|
||||
var editor = getInstance(item);
|
||||
if (editor) {
|
||||
editor.destroy();
|
||||
}
|
||||
};
|
||||
|
||||
CRM.wysiwyg.updateElement = function(item) {
|
||||
var editor = getInstance(item);
|
||||
if (editor) {
|
||||
editor.updateElement();
|
||||
}
|
||||
};
|
||||
|
||||
CRM.wysiwyg.getVal = function(item) {
|
||||
var editor = getInstance(item);
|
||||
if (editor) {
|
||||
return editor.getData();
|
||||
} else {
|
||||
return $(item).val();
|
||||
}
|
||||
};
|
||||
|
||||
CRM.wysiwyg.setVal = function(item, val) {
|
||||
var editor = getInstance(item);
|
||||
if (editor) {
|
||||
return editor.setData(val);
|
||||
} else {
|
||||
return $(item).val(val);
|
||||
}
|
||||
};
|
||||
|
||||
CRM.wysiwyg.insert = function(item, text) {
|
||||
var editor = getInstance(item);
|
||||
if (editor) {
|
||||
editor.insertText(text);
|
||||
} else {
|
||||
CRM.wysiwyg._insertIntoTextarea(item, text);
|
||||
}
|
||||
};
|
||||
|
||||
CRM.wysiwyg.focus = function(item) {
|
||||
var editor = getInstance(item);
|
||||
if (editor) {
|
||||
editor.focus();
|
||||
} else {
|
||||
$(item).focus();
|
||||
}
|
||||
};
|
||||
|
||||
})(CRM.$, CRM._);
|
69
sites/all/modules/civicrm/js/wysiwyg/crm.wysiwyg.js
Normal file
69
sites/all/modules/civicrm/js/wysiwyg/crm.wysiwyg.js
Normal file
|
@ -0,0 +1,69 @@
|
|||
// https://civicrm.org/licensing
|
||||
(function($, _) {
|
||||
// This defines an interface which by default only handles plain textareas
|
||||
// A wysiwyg implementation can extend this by overriding as many of these functions as needed
|
||||
CRM.wysiwyg = {
|
||||
supportsFileUploads: !!CRM.config.wysisygScriptLocation,
|
||||
create: function(item) {
|
||||
var ret = $.Deferred();
|
||||
// Lazy-load the wysiwyg js
|
||||
if (CRM.config.wysisygScriptLocation) {
|
||||
CRM.loadScript(CRM.config.wysisygScriptLocation).done(function() {
|
||||
CRM.wysiwyg._create(item).done(function() {
|
||||
ret.resolve();
|
||||
});
|
||||
});
|
||||
} else {
|
||||
ret.resolve();
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
destroy: _.noop,
|
||||
updateElement: _.noop,
|
||||
getVal: function(item) {
|
||||
return $(item).val();
|
||||
},
|
||||
setVal: function(item, val) {
|
||||
return $(item).val(val);
|
||||
},
|
||||
insert: function(item, text) {
|
||||
CRM.wysiwyg._insertIntoTextarea(item, text);
|
||||
},
|
||||
focus: function(item) {
|
||||
$(item).focus();
|
||||
},
|
||||
// Fallback function to use when a wysiwyg has not been initialized
|
||||
_insertIntoTextarea: function(item, text) {
|
||||
var itemObj = $(item);
|
||||
var origVal = itemObj.val();
|
||||
var origStart = itemObj[0].selectionStart;
|
||||
var origEnd = itemObj[0].selectionEnd;
|
||||
var newVal = origVal.substring(0, origStart) + text + origVal.substring(origEnd);
|
||||
itemObj.val(newVal);
|
||||
var newPos = (origStart + text.length);
|
||||
itemObj[0].selectionStart = newPos;
|
||||
itemObj[0].selectionEnd = newPos;
|
||||
itemObj.triggerHandler('change');
|
||||
CRM.wysiwyg.focus(item);
|
||||
},
|
||||
// Create a "collapsed" textarea that expands into a wysiwyg when clicked
|
||||
createCollapsed: function(item) {
|
||||
$(item)
|
||||
.hide()
|
||||
.on('blur', function () {
|
||||
CRM.wysiwyg.destroy(item);
|
||||
$(item).hide().next('.replace-plain').show().html($(item).val());
|
||||
})
|
||||
.after('<div class="replace-plain" tabindex="0"></div>');
|
||||
$(item).next('.replace-plain')
|
||||
.attr('title', ts('Click to edit'))
|
||||
.html($(item).val())
|
||||
.on('click keypress', function (e) {
|
||||
// Stop browser from opening clicked links
|
||||
e.preventDefault();
|
||||
$(item).show().next('.replace-plain').hide();
|
||||
CRM.wysiwyg.create(item);
|
||||
});
|
||||
}
|
||||
};
|
||||
})(CRM.$, CRM._);
|
Loading…
Add table
Add a link
Reference in a new issue