mirror of
https://github.com/UnickSoft/graphonline.git
synced 2026-04-19 22:50:22 +00:00
first commit
This commit is contained in:
10
lib/ckeditor4/plugins/imagebrowser/LICENSE.txt
Executable file
10
lib/ckeditor4/plugins/imagebrowser/LICENSE.txt
Executable file
@@ -0,0 +1,10 @@
|
||||
Copyright (c) 2013, Slavi Pantaleev
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of ckeditor-imagebrowser nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
69
lib/ckeditor4/plugins/imagebrowser/README.rst
Executable file
69
lib/ckeditor4/plugins/imagebrowser/README.rst
Executable file
@@ -0,0 +1,69 @@
|
||||
CKEditor Image Browser plugin
|
||||
=============================
|
||||
|
||||
**imagebrowser** is a `CKEditor <http://ckeditor.com/>`_ plugin that allows images on the server to be browsed and picked
|
||||
for inclusion into the editor's contents.
|
||||
|
||||
This plugin integrates with the **image** plugin (part of CKEditor),
|
||||
by making it provide a **Browse Server** button in the Image dialog window (`screenshot here <http://ckeditor.com/sites/default/files/styles/large/public/image/image_manager.png>`_).
|
||||
|
||||
The way you use it is very similar to `imageGetJson <http://imperavi.com/redactor/docs/settings/#set_imageGetJson>`_ in `Redactor <http://imperavi.com/redactor/>`_
|
||||
- you only need to provide a list of images in a JSON format, and the image browser will take care of the rest.
|
||||
|
||||
In fact, it uses the same data format as Redactor, allowing for an easy transition between the two editors.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Copy the whole contents of this repository into a new ``plugins/imagebrowser`` directory in your CKEditor install.
|
||||
|
||||
Make sure you're using the **Standard** or **Full** `CKEditor packages <http://ckeditor.com/download>`_.
|
||||
The **Basic** package lacks an in-built "File Browser" plugin, which this plugin depends on.
|
||||
You can also use a `Custom CKEditor package <http://ckeditor.com/builder>`_, if you build it with "File Browser" plugin support.
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
Enable the plugin by adding it to `extraPlugins` and specify the `imageBrowser_listUrl` parameter::
|
||||
|
||||
CKEditor.replace('textareaId', {
|
||||
"extraPlugins": "imagebrowser",
|
||||
"imageBrowser_listUrl": "/path/to/images_list.json"
|
||||
});
|
||||
|
||||
The **imageBrowser_listUrl** configuration parameter points to a URL that lists the server's images in a JSON format.
|
||||
|
||||
Example::
|
||||
|
||||
[
|
||||
{
|
||||
"image": "/image1_200x150.jpg",
|
||||
"thumb": "/image1_thumb.jpg",
|
||||
"folder": "Small"
|
||||
},
|
||||
{
|
||||
"image": "/image2_200x150.jpg",
|
||||
"thumb": "/image2_thumb.jpg",
|
||||
"folder": "Small"
|
||||
},
|
||||
|
||||
{
|
||||
"image": "/image1_full.jpg",
|
||||
"thumb": "/image1_thumb.jpg",
|
||||
"folder": "Large"
|
||||
},
|
||||
{
|
||||
"image": "/image2_full.jpg",
|
||||
"thumb": "/image2_thumb.jpg",
|
||||
"folder": "Large"
|
||||
}
|
||||
]
|
||||
|
||||
The above says that there are 2 image directories ("Small" and "Large") with 2 files in each of them.
|
||||
|
||||
The **image** field is the relative/absolute path being used when the image gets put into the editor's contents.
|
||||
|
||||
The **thumb** field is *optional*. It specifies the relative/absolute path to the image's thumbnail (for preview purposes).
|
||||
If omitted, the value of **image** is used as a thumbnail.
|
||||
|
||||
The **folder** field is *optional*. If omitted, the image list will not be split into folders.
|
||||
62
lib/ckeditor4/plugins/imagebrowser/browser/browser.css
Executable file
62
lib/ckeditor4/plugins/imagebrowser/browser/browser.css
Executable file
@@ -0,0 +1,62 @@
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.folder-switcher {
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
margin: 0;
|
||||
padding: 5px 10px;
|
||||
list-style: none;
|
||||
background-color: #e3e3e3;
|
||||
border-bottom: 1px solid #b7b7b7;
|
||||
}
|
||||
|
||||
.folder-switcher li {
|
||||
display: inline-block;
|
||||
margin: 5px;
|
||||
padding: 5px 10px;
|
||||
border: 1px solid #b7b7b7;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
|
||||
background-color: #fff;
|
||||
color: #333;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.folder-switcher li:hover {
|
||||
color: #0576b7;
|
||||
border-color: #0576b7;
|
||||
}
|
||||
|
||||
.folder-switcher li.active {
|
||||
color: #fff;
|
||||
background-color: #0576b7;
|
||||
border-color: #0576b7;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
.images-container {
|
||||
padding: 5px 10px;
|
||||
}
|
||||
|
||||
.thumbnail {
|
||||
display: inline-block;
|
||||
margin: 5px 5px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
overflow: hidden;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.thumbnail:hover {
|
||||
border-color: #0a94e3;
|
||||
}
|
||||
|
||||
.thumbnail img {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 200px;
|
||||
max-height: 200px;
|
||||
}
|
||||
25
lib/ckeditor4/plugins/imagebrowser/browser/browser.html
Executable file
25
lib/ckeditor4/plugins/imagebrowser/browser/browser.html
Executable file
@@ -0,0 +1,25 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<base>
|
||||
<link rel="stylesheet" href="browser.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script type="text/x-template-html" id="js-template-image">
|
||||
<a href="javascript://" class="thumbnail js-image-link" data-url="%imageUrl%"><img src="%thumbUrl%"></a>
|
||||
</script>
|
||||
|
||||
<ul class="folder-switcher" id="js-folder-switcher"></ul>
|
||||
|
||||
<div class="images-container" id="js-images-container">Loading..</div>
|
||||
|
||||
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
|
||||
<script type="text/javascript" src="browser.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
CkEditorImageBrowser.init();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
126
lib/ckeditor4/plugins/imagebrowser/browser/browser.js
Executable file
126
lib/ckeditor4/plugins/imagebrowser/browser/browser.js
Executable file
@@ -0,0 +1,126 @@
|
||||
var CkEditorImageBrowser = {};
|
||||
|
||||
CkEditorImageBrowser.folders = [];
|
||||
CkEditorImageBrowser.images = {}; //folder => list of images
|
||||
CkEditorImageBrowser.ckFunctionNum = null;
|
||||
|
||||
CkEditorImageBrowser.$folderSwitcher = null;
|
||||
CkEditorImageBrowser.$imagesContainer = null;
|
||||
|
||||
CkEditorImageBrowser.init = function () {
|
||||
CkEditorImageBrowser.$folderSwitcher = $('#js-folder-switcher');
|
||||
CkEditorImageBrowser.$imagesContainer = $('#js-images-container');
|
||||
|
||||
var baseHref = CkEditorImageBrowser.getQueryStringParam("baseHref");
|
||||
if (baseHref) {
|
||||
var h = (document.head || document.getElementsByTagName("head")[0]),
|
||||
el = h.getElementsByTagName("link")[0];
|
||||
el.href = location.href.replace(/\/[^\/]*$/,"/browser.css");
|
||||
(h.getElementsByTagName("base")[0]).href = baseHref;
|
||||
}
|
||||
|
||||
CkEditorImageBrowser.ckFunctionNum = CkEditorImageBrowser.getQueryStringParam('CKEditorFuncNum');
|
||||
|
||||
CkEditorImageBrowser.initEventHandlers();
|
||||
|
||||
CkEditorImageBrowser.loadData(CkEditorImageBrowser.getQueryStringParam('listUrl'), function () {
|
||||
CkEditorImageBrowser.initFolderSwitcher();
|
||||
});
|
||||
};
|
||||
|
||||
CkEditorImageBrowser.loadData = function (url, onLoaded) {
|
||||
CkEditorImageBrowser.folders = [];
|
||||
CkEditorImageBrowser.images = {};
|
||||
|
||||
$.getJSON(url, function (list) {
|
||||
$.each(list, function (_idx, item) {
|
||||
if (typeof(item.folder) === 'undefined') {
|
||||
item.folder = 'Images';
|
||||
}
|
||||
|
||||
if (typeof(item.thumb) === 'undefined') {
|
||||
item.thumb = item.image;
|
||||
}
|
||||
|
||||
CkEditorImageBrowser.addImage(item.folder, item.image, item.thumb);
|
||||
});
|
||||
|
||||
onLoaded();
|
||||
});
|
||||
};
|
||||
|
||||
CkEditorImageBrowser.addImage = function (folderName, imageUrl, thumbUrl) {
|
||||
if (typeof(CkEditorImageBrowser.images[folderName]) === 'undefined') {
|
||||
CkEditorImageBrowser.folders.push(folderName);
|
||||
CkEditorImageBrowser.images[folderName] = [];
|
||||
}
|
||||
|
||||
CkEditorImageBrowser.images[folderName].push({
|
||||
"imageUrl": imageUrl,
|
||||
"thumbUrl": thumbUrl
|
||||
});
|
||||
};
|
||||
|
||||
CkEditorImageBrowser.initFolderSwitcher = function () {
|
||||
var $switcher = CkEditorImageBrowser.$folderSwitcher;
|
||||
|
||||
$switcher.find('li').remove();
|
||||
|
||||
$.each(CkEditorImageBrowser.folders, function (idx, folderName) {
|
||||
var $option = $('<li></li>').data('idx', idx).text(folderName);
|
||||
$option.appendTo($switcher);
|
||||
});
|
||||
|
||||
|
||||
if (CkEditorImageBrowser.folders.length === 0) {
|
||||
$switcher.remove();
|
||||
CkEditorImageBrowser.$imagesContainer.text('No images.');
|
||||
} else {
|
||||
if (CkEditorImageBrowser.folders.length === 1) {
|
||||
$switcher.hide();
|
||||
}
|
||||
|
||||
$switcher.find('li:first').click();
|
||||
}
|
||||
};
|
||||
|
||||
CkEditorImageBrowser.renderImagesForFolder = function (folderName) {
|
||||
var images = CkEditorImageBrowser.images[folderName],
|
||||
templateHtml = $('#js-template-image').html();
|
||||
|
||||
CkEditorImageBrowser.$imagesContainer.html('');
|
||||
|
||||
$.each(images, function (_idx, imageData) {
|
||||
var html = templateHtml;
|
||||
html = html.replace('%imageUrl%', imageData.imageUrl);
|
||||
html = html.replace('%thumbUrl%', imageData.thumbUrl);
|
||||
|
||||
var $item = $($.parseHTML(html));
|
||||
|
||||
CkEditorImageBrowser.$imagesContainer.append($item);
|
||||
});
|
||||
};
|
||||
|
||||
CkEditorImageBrowser.initEventHandlers = function () {
|
||||
$(document).on('click', '#js-folder-switcher li', function () {
|
||||
var idx = parseInt($(this).data('idx'), 10),
|
||||
folderName = CkEditorImageBrowser.folders[idx];
|
||||
|
||||
$(this).siblings('li').removeClass('active');
|
||||
$(this).addClass('active');
|
||||
|
||||
CkEditorImageBrowser.renderImagesForFolder(folderName);
|
||||
});
|
||||
|
||||
$(document).on('click', '.js-image-link', function () {
|
||||
window.opener.CKEDITOR.tools.callFunction(CkEditorImageBrowser.ckFunctionNum, $(this).data('url'));
|
||||
window.close();
|
||||
});
|
||||
};
|
||||
|
||||
CkEditorImageBrowser.getQueryStringParam = function (name) {
|
||||
var regex = new RegExp('[?&]' + name + '=([^&]*)'),
|
||||
result = window.location.search.match(regex);
|
||||
|
||||
return (result && result.length > 1 ? decodeURIComponent(result[1]) : null);
|
||||
};
|
||||
5
lib/ckeditor4/plugins/imagebrowser/browser/jquery-1.9.1.min.js
vendored
Executable file
5
lib/ckeditor4/plugins/imagebrowser/browser/jquery-1.9.1.min.js
vendored
Executable file
File diff suppressed because one or more lines are too long
14
lib/ckeditor4/plugins/imagebrowser/plugin.js
Executable file
14
lib/ckeditor4/plugins/imagebrowser/plugin.js
Executable file
@@ -0,0 +1,14 @@
|
||||
CKEDITOR.plugins.add('imagebrowser', {
|
||||
"init": function (editor) {
|
||||
if (typeof(editor.config.imageBrowser_listUrl) === 'undefined' || editor.config.imageBrowser_listUrl === null) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = editor.plugins.imagebrowser.path + "browser/browser.html?listUrl=" + encodeURIComponent(editor.config.imageBrowser_listUrl);
|
||||
if (editor.config.baseHref) {
|
||||
url += "&baseHref=" + encodeURIComponent(editor.config.baseHref);
|
||||
}
|
||||
|
||||
editor.config.filebrowserImageBrowseUrl = url;
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user