forked from moodle/moodle
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MDL-43861: Atto Plugins: create new plugin for font and background co…
…lors
- v3.8.2
- v3.8.1
- v3.8.0
- v3.8.0-rc1
- v3.8.0-beta
- v3.7.5
- v3.7.4
- v3.7.3
- v3.7.2
- v3.7.1
- v3.7.0
- v3.7.0-rc2
- v3.7.0-rc1
- v3.7.0-beta
- v3.6.9
- v3.6.8
- v3.6.7
- v3.6.6
- v3.6.5
- v3.6.4
- v3.6.3
- v3.6.2
- v3.6.1
- v3.6.0
- v3.6.0-rc3
- v3.6.0-rc2
- v3.6.0-rc1
- v3.6.0-beta
- v3.5.11
- v3.5.10
- v3.5.9
- v3.5.8
- v3.5.7
- v3.5.6
- v3.5.5
- v3.5.4
- v3.5.3
- v3.5.2
- v3.5.1
- v3.5.0
- v3.5.0-rc1
- v3.5.0-beta
- v3.4.9
- v3.4.8
- v3.4.7
- v3.4.6
- v3.4.5
- v3.4.4
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.4.0-rc3
- v3.4.0-rc2
- v3.4.0-rc1
- v3.4.0-beta
- v3.3.9
- v3.3.8
- v3.3.7
- v3.3.6
- v3.3.5
- v3.3.4
- v3.3.3
- v3.3.2
- v3.3.1
- v3.3.0
- v3.3.0-rc3
- v3.3.0-rc2
- v3.3.0-rc1
- v3.3.0-beta
- v3.2.9
- v3.2.8
- v3.2.7
- v3.2.6
- v3.2.5
- v3.2.4
- v3.2.3
- v3.2.2
- v3.2.1
- v3.2.0
- v3.2.0-rc5
- v3.2.0-rc4
- v3.2.0-rc3
- v3.2.0-rc2
- v3.2.0-rc1
- v3.2.0-beta
- v3.1.18
- v3.1.17
- v3.1.16
- v3.1.15
- v3.1.14
- v3.1.13
- v3.1.12
- v3.1.11
- v3.1.10
- v3.1.9
- v3.1.8
- v3.1.7
- v3.1.6
- v3.1.5
- v3.1.4
- v3.1.3
- v3.1.2
- v3.1.1
- v3.1.0
- v3.1.0-rc2
- v3.1.0-rc1
- v3.1.0-beta
- v3.0.10
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- v3.0.0-rc4
- v3.0.0-rc3
- v3.0.0-rc2
- v3.0.0-rc1
- v3.0.0-beta
- v2.9.9
- v2.9.8
- v2.9.7
- v2.9.6
- v2.9.5
- v2.9.4
- v2.9.3
- v2.9.2
- v2.9.1
- v2.9.0
- v2.9.0-rc2
- v2.9.0-rc1
- v2.9.0-beta
- v2.8.12
- v2.8.11
- v2.8.10
- v2.8.9
- v2.8.8
- v2.8.7
- v2.8.6
- v2.8.5
- v2.8.4
- v2.8.3
- v2.8.2
- v2.8.1
- v2.8.0
- v2.8.0-rc2
- v2.8.0-rc1
- v2.8.0-beta
- v2.7.20
- v2.7.19
- v2.7.18
- v2.7.17
- v2.7.16
- v2.7.15
- v2.7.14
- v2.7.13
- v2.7.12
- v2.7.11
- v2.7.10
- v2.7.9
- v2.7.8
- v2.7.7
- v2.7.6
- v2.7.5
- v2.7.4
- v2.7.3
- v2.7.2
- v2.7.1
- v2.7.0
- v2.7.0-rc2
- v2.7.0-rc1
- v2.7.0-beta
Rossiani Wijaya
authored and
Damyon Wiese
committed
Mar 26, 2014
1 parent
0012a94
commit 534cf7b
Showing
21 changed files
with
883 additions
and
17 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
lib/editor/atto/plugins/backcolor/lang/en/atto_backcolor.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Strings for component 'atto_backcolor', language 'en'. | ||
* | ||
* @package atto_backcolor | ||
* @copyright 2014 Rossiani Wijaya <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
$string['pluginname'] = 'Background color'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Atto text editor integration version file. | ||
* | ||
* @package atto_backcolor | ||
* @copyright 2014 Rossiani Wijaya <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
defined('MOODLE_INTERNAL') || die(); | ||
|
||
$plugin->version = 2014020600; // The current plugin version (Date: YYYYMMDDXX). | ||
$plugin->requires = 2013110500; // Requires this Moodle version. | ||
$plugin->component = 'atto_backcolor'; // Full name of the plugin (used for diagnostics). |
134 changes: 134 additions & 0 deletions
134
...ns/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-debug.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
YUI.add('moodle-atto_backcolor-button', function (Y, NAME) { | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Atto text editor background color plugin. | ||
* | ||
* @package editor-atto | ||
* @copyright 2014 Rossiani Wijaya <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
M.atto_backcolor = M.atto_backcolor || { | ||
init : function(params) { | ||
var plugin = 'backcolor'; | ||
|
||
var rgb_white = '#FFFFFF', | ||
rgb_red = '#EF4540', | ||
rgb_yellow = '#FFCF35', | ||
rgb_green = '#98CA3E', | ||
rgb_blue = '#7D9FD3', | ||
rgb_black = '#333333'; | ||
|
||
var click_white = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_white); | ||
}; | ||
var click_red = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_red); | ||
}; | ||
var click_yellow = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_yellow); | ||
}; | ||
var click_green = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_green); | ||
}; | ||
var click_blue = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_blue); | ||
}; | ||
var click_black = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_black); | ||
}; | ||
|
||
var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; | ||
var white = '<div style="' + buttoncss + rgb_white + '"></div>'; | ||
var red = '<div style="' + buttoncss + rgb_red + '"></div>'; | ||
var yellow = '<div style="' + buttoncss + rgb_yellow + '"></div>'; | ||
var green = '<div style="' + buttoncss + rgb_green + '"></div>'; | ||
var blue = '<div style="' + buttoncss + rgb_blue + '"></div>'; | ||
var black = '<div style="' + buttoncss + rgb_black + '"></div>'; | ||
|
||
var iconurl = M.util.image_url('e/text_highlight', 'core'); | ||
|
||
M.editor_atto.add_toolbar_menu(params.elementid, | ||
plugin, | ||
iconurl, | ||
params.group, | ||
[ | ||
{'text' : white, 'handler' : click_white}, | ||
{'text' : red, 'handler' : click_red}, | ||
{'text' : yellow, 'handler' : click_yellow}, | ||
{'text' : green, 'handler' : click_green}, | ||
{'text' : blue, 'handler' : click_blue}, | ||
{'text' : black, 'handler' : click_black} | ||
], | ||
'4'); | ||
}, | ||
|
||
/** | ||
* Handle to change the background color. | ||
* @param event e - The event that triggered this. | ||
* @param string elementid - the elemen id of menu icon. | ||
* @param string color - The color for the background. | ||
*/ | ||
change_color : function(e, elementid, color) { | ||
e.preventDefault(); | ||
if (!M.editor_atto.is_active(elementid)) { | ||
M.editor_atto.focus(elementid); | ||
} | ||
|
||
if (window.getSelection) { | ||
// Test for IE9 and non-IE browsers. | ||
try { | ||
if (!document.execCommand("BackColor", false, color)) { | ||
M.atto_backcolor.set_back_color(color); | ||
} | ||
} catch (ex) { | ||
M.atto_backcolor.set_back_color(color); | ||
} | ||
} else if (document.selection && document.selection.createRange) { | ||
// Test for IE8 or less. | ||
range = document.selection.createRange(); | ||
range.execCommand("BackColor", false, color); | ||
} | ||
|
||
// Clean the YUI ids from the HTML. | ||
M.editor_atto.text_updated(elementid); | ||
}, | ||
/** | ||
* Change the background color. | ||
* This function is an alternative use for IE broswers. | ||
* @param string color - The color for the background. | ||
*/ | ||
set_back_color : function (color) { | ||
var selection = window.getSelection(); | ||
var range = null; | ||
if (selection.rangeCount && selection.getRangeAt) { | ||
range = selection.getRangeAt(0); | ||
} | ||
document.designMode = "on"; | ||
if (range) { | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
} | ||
|
||
if (!document.execCommand("HiliteColor", false, color)) { | ||
document.execCommand("BackColor", false, color); | ||
} | ||
document.designMode = "off"; | ||
} | ||
}; | ||
|
||
}, '@VERSION@'); |
1 change: 1 addition & 0 deletions
1
...gins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button-min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
134 changes: 134 additions & 0 deletions
134
.../plugins/backcolor/yui/build/moodle-atto_backcolor-button/moodle-atto_backcolor-button.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
YUI.add('moodle-atto_backcolor-button', function (Y, NAME) { | ||
|
||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Atto text editor background color plugin. | ||
* | ||
* @package editor-atto | ||
* @copyright 2014 Rossiani Wijaya <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
M.atto_backcolor = M.atto_backcolor || { | ||
init : function(params) { | ||
var plugin = 'backcolor'; | ||
|
||
var rgb_white = '#FFFFFF', | ||
rgb_red = '#EF4540', | ||
rgb_yellow = '#FFCF35', | ||
rgb_green = '#98CA3E', | ||
rgb_blue = '#7D9FD3', | ||
rgb_black = '#333333'; | ||
|
||
var click_white = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_white); | ||
}; | ||
var click_red = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_red); | ||
}; | ||
var click_yellow = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_yellow); | ||
}; | ||
var click_green = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_green); | ||
}; | ||
var click_blue = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_blue); | ||
}; | ||
var click_black = function(e, elementid) { | ||
M.atto_backcolor.change_color(e, elementid, rgb_black); | ||
}; | ||
|
||
var buttoncss = 'width: 20px; height: 20px; border: 1px solid #CCC; background-color: '; | ||
var white = '<div style="' + buttoncss + rgb_white + '"></div>'; | ||
var red = '<div style="' + buttoncss + rgb_red + '"></div>'; | ||
var yellow = '<div style="' + buttoncss + rgb_yellow + '"></div>'; | ||
var green = '<div style="' + buttoncss + rgb_green + '"></div>'; | ||
var blue = '<div style="' + buttoncss + rgb_blue + '"></div>'; | ||
var black = '<div style="' + buttoncss + rgb_black + '"></div>'; | ||
|
||
var iconurl = M.util.image_url('e/text_highlight', 'core'); | ||
|
||
M.editor_atto.add_toolbar_menu(params.elementid, | ||
plugin, | ||
iconurl, | ||
params.group, | ||
[ | ||
{'text' : white, 'handler' : click_white}, | ||
{'text' : red, 'handler' : click_red}, | ||
{'text' : yellow, 'handler' : click_yellow}, | ||
{'text' : green, 'handler' : click_green}, | ||
{'text' : blue, 'handler' : click_blue}, | ||
{'text' : black, 'handler' : click_black} | ||
], | ||
'4'); | ||
}, | ||
|
||
/** | ||
* Handle to change the background color. | ||
* @param event e - The event that triggered this. | ||
* @param string elementid - the elemen id of menu icon. | ||
* @param string color - The color for the background. | ||
*/ | ||
change_color : function(e, elementid, color) { | ||
e.preventDefault(); | ||
if (!M.editor_atto.is_active(elementid)) { | ||
M.editor_atto.focus(elementid); | ||
} | ||
|
||
if (window.getSelection) { | ||
// Test for IE9 and non-IE browsers. | ||
try { | ||
if (!document.execCommand("BackColor", false, color)) { | ||
M.atto_backcolor.set_back_color(color); | ||
} | ||
} catch (ex) { | ||
M.atto_backcolor.set_back_color(color); | ||
} | ||
} else if (document.selection && document.selection.createRange) { | ||
// Test for IE8 or less. | ||
range = document.selection.createRange(); | ||
range.execCommand("BackColor", false, color); | ||
} | ||
|
||
// Clean the YUI ids from the HTML. | ||
M.editor_atto.text_updated(elementid); | ||
}, | ||
/** | ||
* Change the background color. | ||
* This function is an alternative use for IE broswers. | ||
* @param string color - The color for the background. | ||
*/ | ||
set_back_color : function (color) { | ||
var selection = window.getSelection(); | ||
var range = null; | ||
if (selection.rangeCount && selection.getRangeAt) { | ||
range = selection.getRangeAt(0); | ||
} | ||
document.designMode = "on"; | ||
if (range) { | ||
selection.removeAllRanges(); | ||
selection.addRange(range); | ||
} | ||
|
||
if (!document.execCommand("HiliteColor", false, color)) { | ||
document.execCommand("BackColor", false, color); | ||
} | ||
document.designMode = "off"; | ||
} | ||
}; | ||
|
||
}, '@VERSION@'); |
10 changes: 10 additions & 0 deletions
10
lib/editor/atto/plugins/backcolor/yui/src/button/build.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"name": "moodle-atto_backcolor-button", | ||
"builds": { | ||
"moodle-atto_backcolor-button": { | ||
"jsfiles": [ | ||
"button.js" | ||
] | ||
} | ||
} | ||
} |
Oops, something went wrong.