From 7adcb81e4f83f98c468889aaa5a85558ba88c770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 25 Jan 2016 17:45:33 +0100 Subject: Initial commit --- release/plugins/imagebrowser/LICENSE.txt | 10 ++ release/plugins/imagebrowser/README.rst | 69 ++++++++ release/plugins/imagebrowser/browser/browser.css | 62 +++++++ release/plugins/imagebrowser/browser/browser.html | 25 +++ release/plugins/imagebrowser/browser/browser.js | 6 + .../imagebrowser/browser/jquery-1.9.1.min.js | 181 +++++++++++++++++++++ 6 files changed, 353 insertions(+) create mode 100644 release/plugins/imagebrowser/LICENSE.txt create mode 100644 release/plugins/imagebrowser/README.rst create mode 100644 release/plugins/imagebrowser/browser/browser.css create mode 100644 release/plugins/imagebrowser/browser/browser.html create mode 100644 release/plugins/imagebrowser/browser/browser.js create mode 100644 release/plugins/imagebrowser/browser/jquery-1.9.1.min.js (limited to 'release/plugins/imagebrowser') diff --git a/release/plugins/imagebrowser/LICENSE.txt b/release/plugins/imagebrowser/LICENSE.txt new file mode 100644 index 00000000..e81261ab --- /dev/null +++ b/release/plugins/imagebrowser/LICENSE.txt @@ -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. diff --git a/release/plugins/imagebrowser/README.rst b/release/plugins/imagebrowser/README.rst new file mode 100644 index 00000000..ea9d2296 --- /dev/null +++ b/release/plugins/imagebrowser/README.rst @@ -0,0 +1,69 @@ +CKEditor Image Browser plugin +============================= + +**imagebrowser** is a `CKEditor `_ 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 `_). + +The way you use it is very similar to `imageGetJson `_ in `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 `_. +The **Basic** package lacks an in-built "File Browser" plugin, which this plugin depends on. +You can also use a `Custom CKEditor package `_, 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. diff --git a/release/plugins/imagebrowser/browser/browser.css b/release/plugins/imagebrowser/browser/browser.css new file mode 100644 index 00000000..1bb665c4 --- /dev/null +++ b/release/plugins/imagebrowser/browser/browser.css @@ -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; +} diff --git a/release/plugins/imagebrowser/browser/browser.html b/release/plugins/imagebrowser/browser/browser.html new file mode 100644 index 00000000..181e169a --- /dev/null +++ b/release/plugins/imagebrowser/browser/browser.html @@ -0,0 +1,25 @@ + + + + + + + + + + + +
    + +
    Loading..
    + + + + + + + diff --git a/release/plugins/imagebrowser/browser/browser.js b/release/plugins/imagebrowser/browser/browser.js new file mode 100644 index 00000000..9f21faa5 --- /dev/null +++ b/release/plugins/imagebrowser/browser/browser.js @@ -0,0 +1,6 @@ +var CkEditorImageBrowser={folders:[],images:{},ckFunctionNum:null,$folderSwitcher:null,$imagesContainer:null,init:function(){CkEditorImageBrowser.$folderSwitcher=$("#js-folder-switcher");CkEditorImageBrowser.$imagesContainer=$("#js-images-container");var a=CkEditorImageBrowser.getQueryStringParam("baseHref");if(a){var c=document.head||document.getElementsByTagName("head")[0];c.getElementsByTagName("link")[0].href=location.href.replace(/\/[^\/]*$/,"/browser.css");c.getElementsByTagName("base")[0].href= +a}CkEditorImageBrowser.ckFunctionNum=CkEditorImageBrowser.getQueryStringParam("CKEditorFuncNum");CkEditorImageBrowser.initEventHandlers();CkEditorImageBrowser.loadData(CkEditorImageBrowser.getQueryStringParam("listUrl"),function(){CkEditorImageBrowser.initFolderSwitcher()})},loadData:function(a,c){CkEditorImageBrowser.folders=[];CkEditorImageBrowser.images={};$.getJSON(a,function(a){$.each(a,function(a,b){"undefined"===typeof b.folder&&(b.folder="Images");"undefined"===typeof b.thumb&&(b.thumb=b.image); +CkEditorImageBrowser.addImage(b.folder,b.image,b.thumb)});c()}).error(function(c,d,b){CkEditorImageBrowser.$imagesContainer.html(200>c.status||400<=c.status?"HTTP Status: "+c.status+"/"+c.statusText+': "'+a+'"':"parsererror"===d?d+': invalid JSON file: "'+a+'": '+b.message:d+" / "+c.statusText+" / "+b.message)})},addImage:function(a,c,e){"undefined"===typeof CkEditorImageBrowser.images[a]&&(CkEditorImageBrowser.folders.push(a), +CkEditorImageBrowser.images[a]=[]);CkEditorImageBrowser.images[a].push({imageUrl:c,thumbUrl:e})},initFolderSwitcher:function(){var a=CkEditorImageBrowser.$folderSwitcher;a.find("li").remove();$.each(CkEditorImageBrowser.folders,function(c,e){$("
  • ").data("idx",c).text(e).appendTo(a)});0===CkEditorImageBrowser.folders.length?(a.remove(),CkEditorImageBrowser.$imagesContainer.text("No images.")):(1===CkEditorImageBrowser.folders.length&&a.hide(),a.find("li:first").click())},renderImagesForFolder:function(a){var a= +CkEditorImageBrowser.images[a],c=$("#js-template-image").html();CkEditorImageBrowser.$imagesContainer.html("");$.each(a,function(a,d){var b=c,b=b.replace("%imageUrl%",d.imageUrl),b=b.replace("%thumbUrl%",d.thumbUrl),b=$($.parseHTML(b));CkEditorImageBrowser.$imagesContainer.append(b)})},initEventHandlers:function(){$(document).on("click","#js-folder-switcher li",function(){var a=parseInt($(this).data("idx"),10),a=CkEditorImageBrowser.folders[a];$(this).siblings("li").removeClass("active");$(this).addClass("active"); +CkEditorImageBrowser.renderImagesForFolder(a)});$(document).on("click",".js-image-link",function(){window.opener.CKEDITOR.tools.callFunction(CkEditorImageBrowser.ckFunctionNum,$(this).data("url"));window.close()})},getQueryStringParam:function(a){return(a=window.location.search.match(RegExp("[?&]"+a+"=([^&]*)")))&&1e;e++)delete g[b[e]]; +if(!(d?sa:c.isEmptyObject)(g))return}(d||(delete i[j].data,sa(i[j])))&&(h?c.cleanData([a],!0):c.support.deleteExpando||i!=i.window?delete i[j]:i[j]=null)}}}function Ta(a,b,d){if(d===k&&1===a.nodeType){var e="data-"+b.replace(Rb,"-$1").toLowerCase();if(d=a.getAttribute(e),"string"==typeof d){try{d="true"===d?!0:"false"===d?!1:"null"===d?null:+d+""===d?+d:Sb.test(d)?c.parseJSON(d):d}catch(f){}c.data(a,b,d)}else d=k}return d}function sa(a){for(var b in a)if(("data"!==b||!c.isEmptyObject(a[b]))&&"toJSON"!== +b)return!1;return!0}function ha(){return!0}function U(){return!1}function Ua(a,b){do a=a[b];while(a&&1!==a.nodeType);return a}function Va(a,b,d){if(b=b||0,c.isFunction(b))return c.grep(a,function(a,c){return!!b.call(a,c,a)===d});if(b.nodeType)return c.grep(a,function(a){return a===b===d});if("string"==typeof b){var e=c.grep(a,function(a){return 1===a.nodeType});if(Tb.test(b))return c.filter(b,e,!d);b=c.filter(b,e)}return c.grep(a,function(a){return 0<=c.inArray(a,b)===d})}function Wa(a){var b=Xa.split("|"), +a=a.createDocumentFragment();if(a.createElement)for(;b.length;)a.createElement(b.pop());return a}function Ya(a){var b=a.getAttributeNode("type");return a.type=(b&&b.specified)+"/"+a.type,a}function Za(a){var b=Ub.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function ta(a,b){for(var d,e=0;null!=(d=a[e]);e++)c._data(d,"globalEval",!b||c._data(b[e],"globalEval"))}function $a(a,b){if(1===b.nodeType&&c.hasData(a)){var d,e,f;e=c._data(a);var g=c._data(b,e),h=e.events;if(h)for(d in delete g.handle, +g.events={},h){e=0;for(f=h[d].length;f>e;e++)c.event.add(b,d,h[d][e])}g.data&&(g.data=c.extend({},g.data))}}function u(a,b){var d,e,f=0,g=typeof a.getElementsByTagName!==v?a.getElementsByTagName(b||"*"):typeof a.querySelectorAll!==v?a.querySelectorAll(b||"*"):k;if(!g){g=[];for(d=a.childNodes||a;null!=(e=d[f]);f++)!b||c.nodeName(e,b)?g.push(e):c.merge(g,u(e,b))}return b===k||b&&c.nodeName(a,b)?c.merge([a],g):g}function Vb(a){ua.test(a.type)&&(a.defaultChecked=a.checked)}function ab(a,b){if(b in a)return b; +for(var c=b.charAt(0).toUpperCase()+b.slice(1),e=b,f=bb.length;f--;)if(b=bb[f]+c,b in a)return b;return e}function V(a,b){return a=b||a,"none"===c.css(a,"display")||!c.contains(a.ownerDocument,a)}function cb(a,b){for(var d,e,f,g=[],h=0,i=a.length;i>h;h++)e=a[h],e.style&&(g[h]=c._data(e,"olddisplay"),d=e.style.display,b?(g[h]||"none"!==d||(e.style.display=""),""===e.style.display&&V(e)&&(g[h]=c._data(e,"olddisplay",db(e.nodeName)))):g[h]||(f=V(e),(d&&"none"!==d||!f)&&c._data(e,"olddisplay",f?d:c.css(e, +"display"))));for(h=0;i>h;h++)e=a[h],e.style&&(b&&"none"!==e.style.display&&""!==e.style.display||(e.style.display=b?g[h]||"":"none"));return a}function eb(a,b,c){return(a=Wb.exec(b))?Math.max(0,a[1]-(c||0))+(a[2]||"px"):b}function fb(a,b,d,e,f){for(var b=d===(e?"border":"content")?4:"width"===b?1:0,g=0;4>b;b+=2)"margin"===d&&(g+=c.css(a,d+M[b],!0,f)),e?("content"===d&&(g-=c.css(a,"padding"+M[b],!0,f)),"margin"!==d&&(g-=c.css(a,"border"+M[b]+"Width",!0,f))):(g+=c.css(a,"padding"+M[b],!0,f),"padding"!== +d&&(g+=c.css(a,"border"+M[b]+"Width",!0,f)));return g}function gb(a,b,d){var e=!0,f="width"===b?a.offsetWidth:a.offsetHeight,g=F(a),h=c.support.boxSizing&&"border-box"===c.css(a,"boxSizing",!1,g);if(0>=f||null==f){if(f=P(a,b,g),(0>f||null==f)&&(f=a.style[b]),ia.test(f))return f;e=h&&(c.support.boxSizingReliable||f===a.style[b]);f=parseFloat(f)||0}return f+fb(a,b,d||(h?"border":"content"),e,g)+"px"}function db(a){var b=n,d=hb[a];return d||(d=ib(a,b),"none"!==d&&d||(aa=(aa||c("