Skip to content
Browse files

Translation added to

  • Loading branch information...
1 parent 3005bde commit 470fdae181630781e31daa2bfdeca5e59c243b1a @jicho committed
View
75 plugins/image-editor/index.html
@@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" href="../../plugins/image-editor/style.css" />
</head>
<body>
-
+[crop_title]
<!-- upload form -->
<form id="save-image" method="get">
<input type="hidden" id="path" name="path" value="" />
@@ -19,22 +19,20 @@
<!-- edit options -->
<div>
- <label>Options</label>
- <input type="radio" name="mode" value="crop" id="crop" checked="checked" /> <label for="crop" title="Crop image">Crop</label>
- <input type="radio" name="mode" value="resize" id="resize" /> <label for="resize" title="Resize image dimensions">Resize</label>
- <button id="save">Save</button>
+ <label>[options]</label>
+ <input type="radio" name="mode" value="crop" id="crop" checked="checked" /> <label for="crop" title="Crop image">[crop]</label>
+ <input type="radio" name="mode" value="resize" id="resize" /> <label for="resize" title="Resize image dimensions">[resize]</label>
+ <button id="save">[save]</button>
</div>
</form>
<!-- resize options -->
<div id="resize-options">
- <label>Dimensions</label>
- <input type="text" id="changeWidth" name="resize-width" /> x <input type="text" id="changeHeight" name="resize-height" /> px
+ <label>[dimensions]</label>
+ <input type="text" id="changeWidth" name="resize-width" /> x <input type="text" id="changeHeight" name="resize-height" /> [pixels]
</div>
-<div id="help">
- Make your selection and press "Save".
-</div>
+<div id="help">[help_crop]</div>
<!-- photo -->
<div>
@@ -42,17 +40,51 @@
</div>
<script type="text/javascript" src="../../scripts/jquery-1.6.1.min.js"></script>
+<script type="text/javascript" src="scripts/jquery.ba-replacetext.js"></script>
<script type="text/javascript" src="../../scripts/jquery.form-2.63.js"></script>
<script type="text/javascript" src="../../scripts/jquery.impromptu-3.1.min.js"></script>
<script type="text/javascript" src="../../scripts/jquery.imgareaselect/jquery.imgareaselect.min.js"></script>
-<script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript" src="../../scripts/filemanager.config.js"></script>
+<script type="text/javascript" src="scripts.js"></script>
<script type="text/javascript">
(function ($) {
// Sets image path.
var imgPath = $.urlParam('path');
+ // disable further actions
+ if (window.opener == null) {
+ alert("You're not allowed to access this window directly!");
+ window.close();
+ return;
+ }
+
+ // Get localized messages from file
+ // through culture var or from URL
+ if ($.urlParam('langCode') != 0 && window.opener.$.file_exists('plugins/image-editor/languages/' + $.urlParam('langCode') + '.js')) {
+ culture = $.urlParam('langCode');
+ } else if (window.opener.$.file_exists('plugins/image-editor/languages/' + culture + '.js')) {
+ // no file found based on default culture setting in filemanager.config.js
+ // lets take the English version
+ culture = "en";
+ };
+
+ var lg = [];
+ $.ajax({
+ url: 'languages/' + culture + '.js',
+ async: false,
+ dataType: 'json',
+ success: function (json) {
+ lg = json;
+ }
+ });
+
+ // Get translation
+ function getTranslation(found) {
+ var search = found.substr(1, found.length - 2);
+ return lg[search] ? lg[search] : found;
+ };
+
$(document).ready(function () {
/**********************************************************
Default settings
@@ -62,12 +94,16 @@
cache: false
});
+ // place translation using jQuery replaceText
+ // source: http://benalman.com/projects/jquery-replacetext-plugin/
+ $("body *").replaceText(/\[.*?\]/g, getTranslation, true);
+
// cosmetic tweak for buttons
$('button').wrapInner('<span></span>');
// disable save button
$('#save').attr('disabled', true);
-
+
// set image source
$('#photo').attr('src', imgPath);
@@ -88,7 +124,7 @@
originalImageWidth = $("#photo").width(),
originalImageHeight = $("#photo").height();
}, 100);
-
+
/**********************************************************
Options
**********************************************************/
@@ -102,7 +138,7 @@
});
// undo resize settings
- $.resizeInputs(false, originalImageWidth, originalImageHeight);
+ $.resizeInputs(false, originalImageWidth, originalImageHeight, lg);
// resize options (hidden)
$("#resize-options").slideUp();
@@ -114,7 +150,7 @@
});
// undo resize settings
- $.resizeInputs(true, originalImageWidth, originalImageHeight);
+ $.resizeInputs(true, originalImageWidth, originalImageHeight, lg);
// resize options (visible)
$("#resize-options").slideDown();
@@ -124,7 +160,6 @@
$('#save').attr('disabled', true);
});
-
/**********************************************************
Crop "editor"
**********************************************************/
@@ -141,13 +176,15 @@
}
});
- // save crop
+ /**********************************************************
+ Save image
+ **********************************************************/
$('#save-image').ajaxForm({
//target: '#uploadresponse',
beforeSubmit: function (arr, form, options) {
// disable button
$('#save').attr('disabled', true);
- $('#save span').addClass("loading").text("Saving image");
+ $('#save span').addClass("loading").text(lg.saving_image);
},
success: function (result) {
var data = jQuery.parseJSON(result);
@@ -164,7 +201,7 @@
// activate button
$('#save').removeAttr('disabled');
- $('#save span').removeClass("loading").text("Save");
+ $('#save span').removeClass("loading").text(lg.save);
}
}
});
View
13 plugins/image-editor/languages/en.js
@@ -0,0 +1,13 @@
+{
+ "help_crop": "Make your selection and press \"Save\".",
+ "help_resize": "Set the new dimensions an press \"Save\".<br />Image quality can change a little compared to the preview!",
+ "dimensions": "Dimensions",
+ "options": "Options",
+ "crop": "Crop",
+ "crop_title": "Crop image",
+ "resize": "Resize",
+ "resize_title": "Resize image dimensions",
+ "save": "Save",
+ "saving_image": "Saving image",
+ "pixels": "px"
+}
View
13 plugins/image-editor/languages/nl.js
@@ -0,0 +1,13 @@
+{
+ "help_crop": "Selecteer het gewenste gedeelte en klik op \"Opslaan\".",
+ "help_resize": "Pas de afmetingen aan en klik op \"Opslaan\".<br />De kwaliteit van de afbeelding kan afwijken t.o.v. het voorbeeld!",
+ "dimensions": "Afmetingen",
+ "options": "Opties",
+ "crop": "Crop",
+ "crop_title": "Crop image",
+ "resize": "Schalen",
+ "resize_title": "Afbeelding schalen",
+ "save": "Opslaan",
+ "saving_image": "Afbeelding wordt opgeslagen",
+ "pixels": "px"
+}
View
15 plugins/image-editor/scripts.js
@@ -21,20 +21,21 @@ $.setFormAction = function () {
};
/**********************************************************
-Form action settings
+Resize input action
**********************************************************/
-$.resizeInputs = function (pResize, pOrgImgWidth, pOrgImgHeight) {
- // set current image size
+$.resizeInputs = function (pResize, pOrgImgWidth, pOrgImgHeight, lg) {
+ // set current image size (visible to user)
$("#changeWidth").val(pOrgImgWidth);
$("#changeHeight").val(pOrgImgHeight);
- // set dimensions on input
+ // set dimensions on input (not visible to user)
+ // also used by crop logic
$("input[name='width']").val(pOrgImgWidth);
$("input[name='height']").val(pOrgImgHeight);
if (pResize) {
// help text
- $('#help').html('Set the new dimensions an press "Save".<br />Image quality can change a little compared to the preview!');
+ $('#help').html(lg.help_resize);
// activate resize logic
$("#changeWidth, #changeHeight").keyup(function () {
@@ -72,13 +73,13 @@ $.resizeInputs = function (pResize, pOrgImgWidth, pOrgImgHeight) {
});
} else {
// used in crop mode
-
+
// reset image dimensions
$("#photo").width(pOrgImgWidth)
.height(pOrgImgHeight);
// help text
- $('#help').html('Make your selection and press "Save".');
+ $('#help').html(lg.help_crop);
// reset hidden (crop) inputs
$("input[name='width']").val('');
View
129 plugins/image-editor/scripts/jquery.ba-replacetext.js
@@ -0,0 +1,129 @@
+/*!
+ * jQuery replaceText - v1.1 - 11/21/2009
+ * http://benalman.com/projects/jquery-replacetext-plugin/
+ *
+ * Copyright (c) 2009 "Cowboy" Ben Alman
+ * Dual licensed under the MIT and GPL licenses.
+ * http://benalman.com/about/license/
+ */
+
+// Script: jQuery replaceText: String replace for your jQueries!
+//
+// *Version: 1.1, Last updated: 11/21/2009*
+//
+// Project Home - http://benalman.com/projects/jquery-replacetext-plugin/
+// GitHub - http://github.com/cowboy/jquery-replacetext/
+// Source - http://github.com/cowboy/jquery-replacetext/raw/master/jquery.ba-replacetext.js
+// (Minified) - http://github.com/cowboy/jquery-replacetext/raw/master/jquery.ba-replacetext.min.js (0.5kb)
+//
+// About: License
+//
+// Copyright (c) 2009 "Cowboy" Ben Alman,
+// Dual licensed under the MIT and GPL licenses.
+// http://benalman.com/about/license/
+//
+// About: Examples
+//
+// This working example, complete with fully commented code, illustrates one way
+// in which this plugin can be used.
+//
+// replaceText - http://benalman.com/code/projects/jquery-replacetext/examples/replacetext/
+//
+// About: Support and Testing
+//
+// Information about what version or versions of jQuery this plugin has been
+// tested with, and what browsers it has been tested in.
+//
+// jQuery Versions - 1.3.2, 1.4.1
+// Browsers Tested - Internet Explorer 6-8, Firefox 2-3.6, Safari 3-4, Chrome, Opera 9.6-10.1.
+//
+// About: Release History
+//
+// 1.1 - (11/21/2009) Simplified the code and API substantially.
+// 1.0 - (11/21/2009) Initial release
+
+(function ($) {
+ '$:nomunge'; // Used by YUI compressor.
+
+ // Method: jQuery.fn.replaceText
+ //
+ // Replace text in specified elements. Note that only text content will be
+ // modified, leaving all tags and attributes untouched. The new text can be
+ // either text or HTML.
+ //
+ // Uses the String prototype replace method, full documentation on that method
+ // can be found here:
+ //
+ // https://developer.mozilla.org/En/Core_JavaScript_1.5_Reference/Objects/String/Replace
+ //
+ // Usage:
+ //
+ // > jQuery('selector').replaceText( search, replace [, text_only ] );
+ //
+ // Arguments:
+ //
+ // search - (RegExp|String) A RegExp object or substring to be replaced.
+ // Because the String prototype replace method is used internally, this
+ // argument should be specified accordingly.
+ // replace - (String|Function) The String that replaces the substring received
+ // from the search argument, or a function to be invoked to create the new
+ // substring. Because the String prototype replace method is used internally,
+ // this argument should be specified accordingly.
+ // text_only - (Boolean) If true, any HTML will be rendered as text. Defaults
+ // to false.
+ //
+ // Returns:
+ //
+ // (jQuery) The initial jQuery collection of elements.
+
+ $.fn.replaceText = function (search, replace, text_only) {
+ return this.each(function () {
+ var node = this.firstChild,
+ val,
+ new_val,
+
+ // Elements to be removed at the end.
+ remove = [];
+
+ // Only continue if firstChild exists.
+ if (node) {
+
+ // Loop over all childNodes.
+ do {
+
+ // Only process text nodes.
+ if (node.nodeType === 3) {
+
+ // The original node value.
+ val = node.nodeValue;
+
+ // The new value.
+ new_val = val.replace(search, replace);
+
+ // Only replace text if the new value is actually different!
+ if (new_val !== val) {
+
+ if (!text_only && /</.test(new_val)) {
+ // The new value contains HTML, set it in a slower but far more
+ // robust way.
+ $(node).before(new_val);
+
+ // Don't remove the node yet, or the loop will lose its place.
+ remove.push(node);
+ } else {
+ // The new value contains no HTML, so it can be set in this
+ // very fast, simple way.
+ node.nodeValue = new_val;
+ }
+ }
+ }
+
+ } while (node = node.nextSibling);
+ }
+
+ // Time to remove those elements!
+ remove.length && $(remove).remove();
+ });
+ };
+
+})(jQuery);

0 comments on commit 470fdae

Please sign in to comment.
Something went wrong with that request. Please try again.