Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Transform com_content to ES6 (#96)
Browse files Browse the repository at this point in the history
* com_content 2

* TODO

* TODO
  • Loading branch information
anuragteapot authored and dneukirchen committed Mar 11, 2018
1 parent fb9c89e commit ed8f46a
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 19 deletions.
33 changes: 33 additions & 0 deletions media/com_content/js/admin-article-readmore.es6.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(() => {
'use strict';

window.insertReadmore = (editor) => {
if (!Joomla.getOptions('xtd-readmore')) {
// Something went wrong!
return false;
}

let content;
const options = window.Joomla.getOptions('xtd-readmore');

if (window.Joomla && window.Joomla.editors && window.Joomla.editors.instances
&& window.Joomla.editors.instances.hasOwnProperty.call(editor)) {
content = window.Joomla.editors.instances[editor].getValue();
} else {
content = () => options.editor;
}

if (!content.match(/<hr\s+id=("|')system-readmore("|')\s*\/*>/i)) {
Joomla.editors.instances[editor].replaceSelection('<hr id="system-readmore">');
} else {
// TODO replace with joomla-alert
alert(options.exists);
return false;
}
return true;
};
})();
50 changes: 31 additions & 19 deletions media/com_content/js/admin-article-readmore.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
/**
* PLEASE DO NOT MODIFY THIS FILE. WORK ON THE ES6 VERSION.
* OTHERWISE YOUR CHANGES WILL BE REPLACED ON THE NEXT BUILD.
**/

/**
* @copyright Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
(function () {
'use strict';

window.insertReadmore = function(editor) {
"use strict";
if (!Joomla.getOptions('xtd-readmore')) {
// Something went wrong!
return false;
}
window.insertReadmore = function (editor) {
if (!Joomla.getOptions('xtd-readmore')) {
// Something went wrong!
return false;
}

var content, options = window.Joomla.getOptions('xtd-readmore');
var content = void 0;
var options = window.Joomla.getOptions('xtd-readmore');

if (window.Joomla && window.Joomla.editors && window.Joomla.editors.instances && window.Joomla.editors.instances.hasOwnProperty(editor)) {
content = window.Joomla.editors.instances[editor].getValue();
} else {
content = (new Function('return ' + options.editor))();
}
if (window.Joomla && window.Joomla.editors && window.Joomla.editors.instances && window.Joomla.editors.instances.hasOwnProperty.call(editor)) {
content = window.Joomla.editors.instances[editor].getValue();
} else {
content = function content() {
return options.editor;
};
}

if (content.match(/<hr\s+id=("|')system-readmore("|')\s*\/*>/i)) {
alert(options.exists);
return false;
} else {
Joomla.editors.instances[editor].replaceSelection('<hr id="system-readmore">');
}
};
if (!content.match(/<hr\s+id=("|')system-readmore("|')\s*\/*>/i)) {
Joomla.editors.instances[editor].replaceSelection('<hr id="system-readmore">');
} else {
// TODO replace with joomla-alert
alert(options.exists);
return false;
}
return true;
};
})();

0 comments on commit ed8f46a

Please sign in to comment.