Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Embed: make "size" input optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Wentz committed Aug 6, 2014
1 parent a0fe6ea commit dd5c8d6
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 38 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onion-editor",
"version": "0.2.11",
"version": "0.2.12",
"homepage": "https://github.com/theonion/editor",
"authors": [
"Mike Wnuk <mwnuk@theonion.com>"
Expand Down
41 changes: 24 additions & 17 deletions build/onion-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -10414,9 +10414,7 @@ define('scribe-plugin-embed',[],function () {
$captionInput = $(".embed-caption", $modal),
$embedBtn = $(".set-embed-button", $modal),
$error = $(".embed-error", $modal);



$sizeInput = $("[name=size]", $modal);

$modal.on("hide.bs.modal", function() {
$embedBtn.unbind("click");
Expand All @@ -10434,19 +10432,19 @@ define('scribe-plugin-embed',[],function () {
$("[value=" + sizeCropPair + "]", $modal).attr("checked", true);
$modal.modal("show");
$embedBtn.click(function () {
var embed_body = $bodyInput.val();
if (embed_body.trim() === "") {
var embedBody = $bodyInput.val();
if (embedBody.trim() === "") {
$error.show();
}
else {
$error.hide();
callback(block,
{code: embed_body,
callback(block, {
code: embedBody,
caption: $captionInput.val(),
escaped_code: escape(embed_body),
escaped_code: escape(embedBody),
size: getSize(),
crop: getCrop()
})
});
$modal.modal("hide");

}
Expand All @@ -10460,30 +10458,39 @@ define('scribe-plugin-embed',[],function () {
$modal.modal("show");

$embedBtn.click(function () {
var embed_body = $bodyInput.val();
var embedBody = $bodyInput.val();

if (embed_body.trim() === "") {
if (embedBody.trim() === "") {
$error.show();
}
else {
$error.hide();
callback(
{code: embed_body,
callback({
code: embedBody,
caption: $captionInput.val(),
escaped_code: escape(embed_body),
escaped_code: escape(embedBody),
size: getSize(),
crop: getCrop()
})
});
$modal.modal("hide");
}
});
}

function getSize() {
return $("[name=size]:checked", $modal).val().split("-")[0];
var value = 'original';
if ($sizeInput.length > 0) {
$sizeInput.val().split("-")[0];
}
return value;
}

function getCrop() {
return $("[name=size]:checked", $modal).val().split("-")[1];
var value = 'original';
if ($sizeInput.length > 0) {
$sizeInput.val().split("-")[1];
}
return value;
}

};
Expand Down
4 changes: 2 additions & 2 deletions build/onion-editor.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "onion-editor",
"version": "0.2.10",
"version": "0.2.12",
"author": {
"name": "Mike Wnuk",
"email": "mwnuk@theonion.com"
Expand Down
41 changes: 24 additions & 17 deletions src/js/plugins/scribe-plugin-embed.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ define('scribe-plugin-embed',[],function () {
$captionInput = $(".embed-caption", $modal),
$embedBtn = $(".set-embed-button", $modal),
$error = $(".embed-error", $modal);



$sizeInput = $("[name=size]", $modal);

$modal.on("hide.bs.modal", function() {
$embedBtn.unbind("click");
Expand All @@ -30,19 +28,19 @@ define('scribe-plugin-embed',[],function () {
$("[value=" + sizeCropPair + "]", $modal).attr("checked", true);
$modal.modal("show");
$embedBtn.click(function () {
var embed_body = $bodyInput.val();
if (embed_body.trim() === "") {
var embedBody = $bodyInput.val();
if (embedBody.trim() === "") {
$error.show();
}
else {
$error.hide();
callback(block,
{code: embed_body,
callback(block, {
code: embedBody,
caption: $captionInput.val(),
escaped_code: escape(embed_body),
escaped_code: escape(embedBody),
size: getSize(),
crop: getCrop()
})
});
$modal.modal("hide");

}
Expand All @@ -56,30 +54,39 @@ define('scribe-plugin-embed',[],function () {
$modal.modal("show");

$embedBtn.click(function () {
var embed_body = $bodyInput.val();
var embedBody = $bodyInput.val();

if (embed_body.trim() === "") {
if (embedBody.trim() === "") {
$error.show();
}
else {
$error.hide();
callback(
{code: embed_body,
callback({
code: embedBody,
caption: $captionInput.val(),
escaped_code: escape(embed_body),
escaped_code: escape(embedBody),
size: getSize(),
crop: getCrop()
})
});
$modal.modal("hide");
}
});
}

function getSize() {
return $("[name=size]:checked", $modal).val().split("-")[0];
var value = 'original';
if ($sizeInput.length > 0) {
$sizeInput.val().split("-")[0];
}
return value;
}

function getCrop() {
return $("[name=size]:checked", $modal).val().split("-")[1];
var value = 'original';
if ($sizeInput.length > 0) {
$sizeInput.val().split("-")[1];
}
return value;
}

};
Expand Down

0 comments on commit dd5c8d6

Please sign in to comment.