clean code + fix a tiny weird js behaviour when picking up a theme asset
This commit is contained in:
parent
3c31c8dbcf
commit
0631b96df9
6
doc/TODO
6
doc/TODO
|
@ -4,7 +4,7 @@ x bushido version
|
||||||
x default template
|
x default template
|
||||||
~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag
|
~ editable_elements: inheritable: false (Mattias) => seems to be fixed by Dirk's last pull request (#44) => content tag
|
||||||
x locomedia tinyMCE plugin (Bernd)
|
x locomedia tinyMCE plugin (Bernd)
|
||||||
- remove asset_collections
|
x remove asset_collections
|
||||||
x site templates
|
x site templates
|
||||||
x tinyMCE plugin
|
x tinyMCE plugin
|
||||||
x vignette.rb
|
x vignette.rb
|
||||||
|
@ -14,9 +14,11 @@ x locomedia tinyMCE plugin (Bernd)
|
||||||
x rake task
|
x rake task
|
||||||
x internal collection
|
x internal collection
|
||||||
x assign same _id
|
x assign same _id
|
||||||
- pull request locomedia
|
x pick up a theme_asset
|
||||||
|
x pull request locomedia
|
||||||
- SEO: support and support/ should be 2 different pages. Remove trailing slash
|
- SEO: support and support/ should be 2 different pages. Remove trailing slash
|
||||||
- BUG: has_many. Delete an author
|
- BUG: has_many. Delete an author
|
||||||
|
- bushido changes in the master
|
||||||
|
|
||||||
BACKLOG:
|
BACKLOG:
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ $(document).ready(function() {
|
||||||
if (typeof $.fn.imagepicker != 'undefined')
|
if (typeof $.fn.imagepicker != 'undefined')
|
||||||
$('a#image-picker-link').imagepicker({
|
$('a#image-picker-link').imagepicker({
|
||||||
insertFn: function(link) {
|
insertFn: function(link) {
|
||||||
return "{{ '" + link.attr('data-local-path') + "' | theme_image_url }}";
|
return "{{ '/" + link.attr('data-local-path') + "' | theme_image_url }}";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1,95 +0,0 @@
|
||||||
body {
|
|
||||||
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
|
|
||||||
font-size: 1em;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
p.no-items {
|
|
||||||
padding: 18px 0px;
|
|
||||||
background: transparent url(/images/admin/list/none-small.png) no-repeat center 0;
|
|
||||||
text-align: center;
|
|
||||||
color: #9d8963 !important;
|
|
||||||
font-size: 1.1em !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.actions {
|
|
||||||
position: absolute;
|
|
||||||
top: 10px;
|
|
||||||
right: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.assets {
|
|
||||||
overflow: auto;
|
|
||||||
height: 571px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.assets li.asset h4 a {
|
|
||||||
top: 9px;
|
|
||||||
font-size: 0.7em;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.assets li.asset .image img {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.assets li.asset div.actions {
|
|
||||||
top: 7px;
|
|
||||||
}
|
|
||||||
|
|
||||||
ul.assets li.new-asset {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#upload-link {
|
|
||||||
float: left;
|
|
||||||
display: block;
|
|
||||||
background: transparent url("/images/admin/buttons/dark-gray-bg.png") repeat-x 0 0;
|
|
||||||
outline: none;
|
|
||||||
-moz-border-radius : 4px;
|
|
||||||
-webkit-border-radius: 4px;
|
|
||||||
height: 20px;
|
|
||||||
font-size: 0.8em;
|
|
||||||
font-family: 'Lucida Grande';
|
|
||||||
padding: 5px 12px 5px 12px;
|
|
||||||
margin: 5px 0 0 14px;
|
|
||||||
color: #fff !important;
|
|
||||||
text-decoration: none;
|
|
||||||
text-shadow: 1px 1px 1px #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
#spinner {
|
|
||||||
position: fixed;
|
|
||||||
top: 40%;
|
|
||||||
left: 30%;
|
|
||||||
height: 60px;
|
|
||||||
width: 250px;
|
|
||||||
background: transparent;
|
|
||||||
z-index: 999;
|
|
||||||
}
|
|
||||||
|
|
||||||
#spinner .overlay, #spinner .text {
|
|
||||||
position: absolute;
|
|
||||||
top: 0px;
|
|
||||||
left: 0px;
|
|
||||||
width: 100%;
|
|
||||||
height: 100%;
|
|
||||||
-moz-border-radius : 10px;
|
|
||||||
-webkit-border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#spinner .overlay {
|
|
||||||
background: #000;
|
|
||||||
opacity: 0.8;
|
|
||||||
}
|
|
||||||
|
|
||||||
#spinner .text {
|
|
||||||
padding: 20px 0;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 1.1em;
|
|
||||||
color: #fff;
|
|
||||||
text-shadow: 1px 1px 1px #000;
|
|
||||||
}
|
|
||||||
|
|
||||||
.mceActionPanel input {
|
|
||||||
font-size: 0.8em;
|
|
||||||
}
|
|
|
@ -1 +0,0 @@
|
||||||
(function(){tinymce.create('tinymce.plugins.LocoImagePlugin',{init:function(ed,url){ed.addCommand('locoImage',function(){ed.windowManager.open({file:url+'/image.htm?6',width:645,height:650,inline:1},{plugin_url:url})});ed.addButton('image',{title:'locoimage.image_desc',cmd:'locoImage'})},getInfo:function(){return{longname:'Locomotive image',author:'Locomotive Engine',authorurl:'http://www.locomotiveapp.org',infourl:'http://www.locomotiveapp.org',version:tinymce.majorVersion+"."+tinymce.minorVersion}}});tinymce.PluginManager.add('locoimage',tinymce.plugins.LocoImagePlugin)})();
|
|
|
@ -1,46 +0,0 @@
|
||||||
/**
|
|
||||||
* editor_plugin_src.js
|
|
||||||
*
|
|
||||||
* Copyright 2009, Moxiecode Systems AB
|
|
||||||
* Released under LGPL License.
|
|
||||||
*
|
|
||||||
* License: http://tinymce.moxiecode.com/license
|
|
||||||
* Contributing: http://tinymce.moxiecode.com/contributing
|
|
||||||
*/
|
|
||||||
|
|
||||||
(function() {
|
|
||||||
tinymce.create('tinymce.plugins.LocoImagePlugin', {
|
|
||||||
init : function(ed, url) {
|
|
||||||
// Register commands
|
|
||||||
ed.addCommand('locoImage', function() {
|
|
||||||
ed.windowManager.open({
|
|
||||||
file : url + '/image.htm',
|
|
||||||
width : 645,
|
|
||||||
height : 650,
|
|
||||||
inline : 1
|
|
||||||
}, {
|
|
||||||
plugin_url : url
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register buttons
|
|
||||||
ed.addButton('image', {
|
|
||||||
title : 'locoimage.image_desc',
|
|
||||||
cmd : 'locoImage'
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
getInfo : function() {
|
|
||||||
return {
|
|
||||||
longname : 'Locomotive image',
|
|
||||||
author : 'Locomotive Engine',
|
|
||||||
authorurl : 'http://www.locomotiveapp.org',
|
|
||||||
infourl : 'http://www.locomotiveapp.org',
|
|
||||||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
|
||||||
};
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Register plugin
|
|
||||||
tinymce.PluginManager.add('locoimage', tinymce.plugins.LocoImagePlugin);
|
|
||||||
})();
|
|
|
@ -1,62 +0,0 @@
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
||||||
<head>
|
|
||||||
<title>{#locoimage_dlg.dialog_title}</title>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="../../tiny_mce_popup.js"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="/javascripts/admin/jquery.js"></script>
|
|
||||||
<script type="text/javascript" src="/javascripts/admin/rails.js"></script>
|
|
||||||
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/src/plupload.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/plupload.gears.min.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/src/flash.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/plupload.html4.min.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/plupload.html5.min.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/jquery.plupload.queue.min.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/plupload/jquery.plupload.queue.min.js" type="text/javascript"></script>
|
|
||||||
<script src="/javascripts/admin/plugins/scrollTo.js" type="text/javascript"></script>
|
|
||||||
|
|
||||||
<script type="text/javascript" src="js/image.js?7"></script>
|
|
||||||
|
|
||||||
<link href="/stylesheets/admin/assets.css" rel="stylesheet" type="text/css" />
|
|
||||||
<link href="css/locoimage.css?3" rel="stylesheet" type="text/css" />
|
|
||||||
</head>
|
|
||||||
<body id="locoimage" style="display: none">
|
|
||||||
|
|
||||||
<div id="spinner">
|
|
||||||
<div class="overlay"></div>
|
|
||||||
<div class="text loading">{#locoimage_dlg.loading}</div>
|
|
||||||
<div class="text uploading" style="display: none">{#locoimage_dlg.uploading}</div>
|
|
||||||
<div class="text destroying" style="display: none">{#locoimage_dlg.destroying}</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<p class="no-items" style="display: none">{#locoimage_dlg.no_items}</p>
|
|
||||||
|
|
||||||
<form onsubmit="insertAction();return false;" action="#">
|
|
||||||
<div id="images">
|
|
||||||
<ul class="assets">
|
|
||||||
<li class="new-asset">
|
|
||||||
<h4><a href="#">NoName</a></h4>
|
|
||||||
<div class="image">
|
|
||||||
<div class="inside">
|
|
||||||
<img />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="actions">
|
|
||||||
<a href="#" class="remove" data-confirm="{#locoimage_dlg.confirm}" data-method="delete" rel="nofollow">
|
|
||||||
<img src="/images/admin/list/icons/cross.png">
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</li>
|
|
||||||
<li class="clear"></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mceActionPanel">
|
|
||||||
<a href="/admin/images.json" id="upload-link">{#locoimage_dlg.upload}</a>
|
|
||||||
<input type="button" id="cancel" name="cancel" value="{#cancel}" onclick="tinyMCEPopup.close();" />
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
Binary file not shown.
Before Width: | Height: | Size: 1.6 KiB |
|
@ -1,172 +0,0 @@
|
||||||
var ImageDialog = {
|
|
||||||
formElement: null,
|
|
||||||
|
|
||||||
listElement: null,
|
|
||||||
|
|
||||||
preInit : function() {
|
|
||||||
var url;
|
|
||||||
|
|
||||||
tinyMCEPopup.requireLangPack();
|
|
||||||
|
|
||||||
if (url = tinyMCEPopup.getParam("external_image_list_url"))
|
|
||||||
document.write('<script language="javascript" type="text/javascript" src="' + tinyMCEPopup.editor.documentBaseURI.toAbsolute(url) + '"></script>');
|
|
||||||
},
|
|
||||||
|
|
||||||
init : function(ed) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
formElement = $(document.forms[0]);
|
|
||||||
|
|
||||||
listElement = formElement.find('ul');
|
|
||||||
|
|
||||||
$.getJSON('/admin/images.json', function(data) {
|
|
||||||
$(data.images).each(function() {
|
|
||||||
self._addImage(this);
|
|
||||||
});
|
|
||||||
|
|
||||||
self.setupUploader();
|
|
||||||
|
|
||||||
self.hideSpinner();
|
|
||||||
|
|
||||||
if ($('ul li.asset').length == 0) $('p.no-items').show();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
hideSpinner: function() {
|
|
||||||
$('#spinner').hide();
|
|
||||||
},
|
|
||||||
|
|
||||||
showSpinner: function(msg) {
|
|
||||||
$('#spinner .text').hide();
|
|
||||||
$('#spinner .' + msg).show();
|
|
||||||
$('#spinner').show();
|
|
||||||
},
|
|
||||||
|
|
||||||
insert: function(url) {
|
|
||||||
var ed = tinyMCEPopup.editor, f = document.forms[0], nl = f.elements, v, args = {}, el;
|
|
||||||
|
|
||||||
tinyMCEPopup.restoreSelection();
|
|
||||||
|
|
||||||
// Fixes crash in Safari
|
|
||||||
if (tinymce.isWebKit) ed.getWin().focus();
|
|
||||||
|
|
||||||
tinymce.extend(args, { src : url });
|
|
||||||
|
|
||||||
el = ed.selection.getNode();
|
|
||||||
|
|
||||||
if (el && el.nodeName == 'IMG') {
|
|
||||||
ed.dom.setAttribs(el, args);
|
|
||||||
} else {
|
|
||||||
ed.execCommand('mceInsertContent', false, '<img id="__mce_tmp" />', {skip_undo : 1});
|
|
||||||
ed.dom.setAttribs('__mce_tmp', args);
|
|
||||||
ed.dom.setAttrib('__mce_tmp', 'id', '');
|
|
||||||
ed.undoManager.add();
|
|
||||||
}
|
|
||||||
|
|
||||||
tinyMCEPopup.close();
|
|
||||||
},
|
|
||||||
|
|
||||||
setupUploader: function() {
|
|
||||||
var self = this;
|
|
||||||
var multipartParams = {};
|
|
||||||
|
|
||||||
with(window.parent) {
|
|
||||||
multipartParams[$('meta[name=csrf-param]').attr('content')] = $('meta[name=csrf-token]').attr('content');
|
|
||||||
}
|
|
||||||
|
|
||||||
var uploader = new plupload.Uploader({
|
|
||||||
runtimes : (jQuery.browser.webkit == true ? 'flash' : 'html5,flash'),
|
|
||||||
// container: 'theme-images',
|
|
||||||
browse_button : 'upload-link',
|
|
||||||
max_file_size : '5mb',
|
|
||||||
url : $('a#upload-link').attr('href'),
|
|
||||||
flash_swf_url : '/javascripts/admin/plugins/plupload/plupload.flash.swf',
|
|
||||||
multipart: true,
|
|
||||||
multipart_params: multipartParams,
|
|
||||||
filters : [
|
|
||||||
{ title : "Image files", extensions : "jpg,gif,png" },
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
uploader.bind('QueueChanged', function() {
|
|
||||||
self.showSpinner('uploading');
|
|
||||||
uploader.start();
|
|
||||||
});
|
|
||||||
|
|
||||||
uploader.bind('FileUploaded', function(up, file, response) {
|
|
||||||
var json = JSON.parse(response.response);
|
|
||||||
|
|
||||||
if (json.status == 'success')
|
|
||||||
self._addImage(json);
|
|
||||||
|
|
||||||
self.hideSpinner();
|
|
||||||
});
|
|
||||||
|
|
||||||
uploader.init();
|
|
||||||
},
|
|
||||||
|
|
||||||
_addImage: function(data) {
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
var asset = $('ul li.new-asset')
|
|
||||||
.clone()
|
|
||||||
.insertBefore($('ul li.clear'))
|
|
||||||
.addClass('asset');
|
|
||||||
|
|
||||||
asset.find('h4 a').attr('href', data.url)
|
|
||||||
.html(data.name)
|
|
||||||
.bind('click', function(e) {
|
|
||||||
self.insert(data.url);
|
|
||||||
e.stopPropagation(); e.preventDefault();
|
|
||||||
});
|
|
||||||
|
|
||||||
asset.find('.image .inside img')
|
|
||||||
.attr('src', data.vignette_url)
|
|
||||||
.bind('click', function(e) {
|
|
||||||
self.insert(data.url);
|
|
||||||
});
|
|
||||||
|
|
||||||
asset.find('.actions a')
|
|
||||||
.attr('href', data.destroy_url)
|
|
||||||
.bind('click', function(e) {
|
|
||||||
if (confirm($(this).attr('data-confirm'))) {
|
|
||||||
self.showSpinner('destroying');
|
|
||||||
$(this).callRemote();
|
|
||||||
}
|
|
||||||
e.preventDefault(); e.stopPropagation();
|
|
||||||
})
|
|
||||||
.bind('ajax:success', function(event, data) {
|
|
||||||
self._destroyImage(asset);
|
|
||||||
});
|
|
||||||
|
|
||||||
if ($('ul li.asset').length % 4 == 0)
|
|
||||||
asset.addClass('last');
|
|
||||||
|
|
||||||
asset.removeClass('new-asset');
|
|
||||||
|
|
||||||
$('p.no-items').hide();
|
|
||||||
|
|
||||||
$('ul').scrollTo($('li.asset:last'), 400);
|
|
||||||
},
|
|
||||||
|
|
||||||
_destroyImage: function(asset) {
|
|
||||||
asset.remove();
|
|
||||||
|
|
||||||
if ($('ul li.asset').length == 0) {
|
|
||||||
$('p.no-items').show();
|
|
||||||
} else {
|
|
||||||
$('ul li.asset').each(function(index) {
|
|
||||||
if ((index + 1) % 4 == 0)
|
|
||||||
$(this).addClass('last');
|
|
||||||
else
|
|
||||||
$(this).removeClass('last');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.hideSpinner();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
ImageDialog.preInit();
|
|
||||||
tinyMCEPopup.onInit.add(ImageDialog.init, ImageDialog);
|
|
|
@ -1,9 +0,0 @@
|
||||||
tinyMCE.addI18n('de.locoimage_dlg',{
|
|
||||||
dialog_title: 'Bild einfügen',
|
|
||||||
upload: 'Bild hochladen',
|
|
||||||
loading: 'Laden...',
|
|
||||||
uploading: 'Hochladen...',
|
|
||||||
destroying: 'Löschen...',
|
|
||||||
confirm: 'Bist du sicher ?',
|
|
||||||
no_items: 'Momentan gibt es hier keine Bilder.'
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
tinyMCE.addI18n('en.locoimage_dlg',{
|
|
||||||
dialog_title: 'Insert image',
|
|
||||||
upload: 'Upload image',
|
|
||||||
loading: 'Loading...',
|
|
||||||
uploading: 'Uploading...',
|
|
||||||
destroying: 'Destroying...',
|
|
||||||
confirm: 'Are you sure ?',
|
|
||||||
no_items: 'There are no images for now.'
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
tinyMCE.addI18n('fr.locoimage_dlg',{
|
|
||||||
dialog_title: 'Insérer une image',
|
|
||||||
upload: 'Uploader image',
|
|
||||||
loading: 'Chargement...',
|
|
||||||
uploading: 'Uploading...',
|
|
||||||
destroying: 'Suppression...',
|
|
||||||
confirm: 'Êtes-vous sûr(e) ?',
|
|
||||||
no_items: 'Il n\'y a aucune image pour l\'instant'
|
|
||||||
});
|
|
|
@ -1,9 +0,0 @@
|
||||||
tinyMCE.addI18n('it.locoimage_dlg',{
|
|
||||||
dialog_title: 'Inserisci immagine',
|
|
||||||
upload: 'Carica immagine',
|
|
||||||
loading: 'Caricamento...',
|
|
||||||
uploading: 'Caricamento file...',
|
|
||||||
destroying: 'Eliminazione...',
|
|
||||||
confirm: 'Sicuro?',
|
|
||||||
no_items: 'Per ora non ci sono immagini.'
|
|
||||||
});
|
|
|
@ -16,7 +16,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
$('a#image-picker-link').imagepicker({
|
$('a#image-picker-link').imagepicker({
|
||||||
insertFn: function(link) {
|
insertFn: function(link) {
|
||||||
return "{{ '" + link.attr('data-local-path') + "' | theme_image_url }}";
|
return "{{ '/" + link.attr('data-local-path') + "' | theme_image_url }}";
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue