Permalink
Browse files

Merge pull request #556 from silverstripe-rebelalliance/trac/7494

Trac/7494
  • Loading branch information...
sminnee committed Jun 21, 2012
2 parents 3a7128d + 6503090 commit bba7a7ad8ccc6c7ae39079afcec9b88761acd1c5
Showing with 66 additions and 6 deletions.
  1. +5 −1 admin/css/screen.css
  2. +22 −0 admin/scss/_style.scss
  3. +1 −1 forms/HtmlEditorField.php
  4. +38 −4 javascript/HtmlEditorField.js
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -1449,6 +1449,22 @@ body.cms-dialog {
@include box-shadow-none;
width:55%;
float:left;
+ position: relative;
+
+ label {
+ position: absolute;
+ left: 8px;
+ top: 0px;
+ font-weight: normal; color: #888;
+ }
+
+ .middleColumn {
+ margin-left: 0;
+ }
+
+ input.remoteurl {
+ padding-left: 40px;
+ }
}
button.add-url{
padding-top:15px;
@@ -1466,6 +1482,12 @@ body.cms-dialog {
@include box-shadow-none;
opacity:1;
}
+ &.ui-state-disabled {
+ &, &:hover, &:active {
+ opacity: 0.35;
+ filter: Alpha(Opacity=35);
+ }
+ }
}
}
@@ -392,7 +392,7 @@ function MediaForm() {
$fromWeb = new CompositeField(
new LiteralField('headerURL', '<h4 class="field header-url">' . sprintf($numericLabelTmpl, '1', _t('HtmlEditorField.ADDURL', 'Add URL')) . '</h4>'),
- $remoteURL = new TextField('RemoteURL', ''),
+ $remoteURL = new TextField('RemoteURL', 'http://'),
new LiteralField('addURLImage', '<button class="action ui-action-constructive ui-button field add-url" data-icon="addMedia"></button>')
);
$remoteURL->addExtraClass('remoteurl');
@@ -871,17 +871,51 @@ ss.editorWrappers['default'] = ss.editorWrappers.tinyMCE;
});
+ $('form.htmleditorfield-form.htmleditorfield-mediaform input.remoteurl').entwine({
+ onadd: function() {
+ this.validate();
+ },
+
+ onkeyup: function() {
+ this.validate();
+ },
+
+ onchange: function() {
+ this.validate();
+ },
+
+ getAddButton: function() {
+ return this.closest('.CompositeField').find('button.add-url');
+ },
+
+ validate: function() {
+ var val = this.val(), orig = val;
+
+ val = val.replace(/^https?:\/\//i, '');
+ if (orig !== val) this.val(val);
+
+ this.getAddButton().button(!!val ? 'enable' : 'disable');
+ return !!val;
+ }
+ });
+
/**
* Show the second step after adding a URL
*/
$('form.htmleditorfield-form.htmleditorfield-mediaform .add-url').entwine({
+ getURLField: function() {
+ return this.closest('.CompositeField').find('input.remoteurl');
+ },
+
onclick: function(e) {
- var form = this.closest('form');
+ var urlField = this.getURLField();
- var urlField = this.closest('.CompositeField').find('input.remoteurl');
+ if (urlField.validate()) {
+ var form = this.closest('form');
+ form.showFileView('http://' + urlField.val());
+ form.redraw();
+ }
- form.showFileView(urlField.val());
- form.redraw();
return false;
}
});

0 comments on commit bba7a7a

Please sign in to comment.