Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Editing takes three elements, prev and next of the selected

  • Loading branch information...
commit 4276ba6279bab7a4b6437cf55feb723fe25a321d 1 parent 7ca5c39
@paazmaya authored
Showing with 30 additions and 7 deletions.
  1. +1 −1  public_html/css/main.css
  2. +29 −6 public_html/js/sendanmaki.js
View
2  public_html/css/main.css
@@ -207,7 +207,7 @@ article li {
article img {
}
/* a that has no direct child img */
-article p > a:not(a > img)::after, article li > a:not(a > img)::after {
+article p > a:not(img)::after, article li > a:not(img)::after {
content: url(../img/link-arrow.png);
margin-left: 4px;
}
View
35 public_html/js/sendanmaki.js
@@ -270,6 +270,8 @@ var sendanmaki = {
});
}
else {
+ w = '300px';
+ h = '140px';
player = '<p><strong>Vaikuttaa siltä että Flash lisäke ei ole käytettävissä.</strong> Siksi ei tätä sisältöäkään voida tarkistella.</p>' +
'<p>Viimeisimmän version Flash lisäkkeestä voi ladata osoitteesta ' +
'<a href="http://get.adobe.com/flashplayer/" title="Get Flash Player">http://get.adobe.com/flashplayer/</a></p>' +
@@ -364,11 +366,24 @@ var sendanmaki = {
* $e is the element, wrapped in jQuery, that was clicked.
*/
editModeClick: function($e) {
- var html = $e.outerHtml();
- var form = $(sendanmaki.editForm).clone();
- form.data('original', html);
+ // http://api.jquery.com/next/
+ var html = $e.prev().outerHtml() + "\n" + $e.outerHtml() + "\n" + $e.next().outerHtml();
+ var $h = $('<div id="contain">' + html + '</div>');
+
+ // replace .mediathumb parts by [|]
+ $h.children('.mediathumb').replaceWith(function() {
+ return "\n" + '[' + $(this).data('key') + ']' + "\n";
+ });
+ $h.children('.medialocal').replaceWith(function() {
+ return "\n" + '[' + $(this).data('key') + ']' + "\n";
+ });
+
+ html = $h.html();
+
+ var $form = $(sendanmaki.editForm).clone();
+ $form.data('original', html); // what is currently on the page
$.colorbox({
- html: form,
+ html: $form,
modal: true,
onComplete: function() {
$('textarea[name="content"]').attr('lang', sendanmaki.lang).val(html);
@@ -377,7 +392,7 @@ var sendanmaki = {
var origClose = $.colorbox.close;
$.colorbox.close = function() {
// but this check now anyhow the initial values...
- if (form.data('original') != form.children('textarea').val()) {
+ if ($form.data('original') != $form.children('textarea').val()) {
var response = confirm('Haluatko varmasti sulkea tämän mahdollisesti muokatun tekstin?');
if (!response) {
return false;
@@ -389,6 +404,8 @@ var sendanmaki = {
}
});
},
+
+
/**
* Callback for submitting the contribution form.
@@ -406,9 +423,15 @@ var sendanmaki = {
$c.children('.medialocal').replaceWith(function() {
return "\n" + '[' + $(this).data('key') + ']' + "\n";
});
- var orig = $c.html().replace("\n\n", "\n"); // remove duplicate new lines
+ var orig = $c.html();
+ console.log("orig.indexOf(original): " + orig.indexOf(original));
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/String/replace
var edited = orig.replace(original, content);
+
+ // TODO
+ // After ever closing p, ul, li, div, ... there needs to be \n
+
+ edited = edited.replace("\n\n", "\n"); // remove duplicate new lines
var data = {
lang: sendanmaki.lang,
page: location.pathname,
Please sign in to comment.
Something went wrong with that request. Please try again.