Skip to content

Commit

Permalink
FIX entwine
Browse files Browse the repository at this point in the history
  • Loading branch information
zanderwar committed Mar 16, 2018
1 parent 876bb11 commit f514795
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"dev-master": "1.0.x-dev"
},
"expose": [
"js"
"dist"
]
},
"minimum-stability": "dev",
Expand Down
1 change: 1 addition & 0 deletions dist/js/bitly.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 28 additions & 23 deletions js/bitly.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,34 @@
var Vulcan = {
Bitly: {
initEvents: function () {
var _this = this;
jQuery.entwine('ss', function ($) {
jQuery('#bitlyCopyUrl').entwine({
onclick: function () {
var url = jQuery(this).attr('data-href');
Vulcan.Bitly.copyUrl(url);
}
});

jQuery('#bitlyCopyUrl').on('click', function () {
var url = jQuery(this).attr('data-href');
_this.copyUrl(url);
});
jQuery('.bitly-field').entwine({
onmatch: function () {
var $desc = jQuery('.field.urlsegment .edit-holder .form__field-description').clone();
$desc.html("<strong>Warning</strong>: Changing your URL segment will force your Bitly URL to update and unfortunately the click count will reset as Bitly does not allow you to edit links.");
jQuery('.field.urlsegment .edit-holder').append($desc);
}
});

jQuery('.field.urlsegment .update').on('click', function () {
jQuery('#Form_EditForm_BitlyURL_Holder').find('.preview-holder').html("<div style='margin-top: 8px;'>URL segment has changed, waiting for you to save.</div>")
});
jQuery('.field.urlsegment .update').entwine({
onclick: function () {
jQuery('#Form_EditForm_BitlyURL_Holder').find('.preview-holder').html("<div style='margin-top: 8px;'>URL segment has changed, waiting for you to save.</div>")
}
});

if (jQuery('.bitly-field').length > 0) {
var $desc = jQuery('.field.urlsegment .edit-holder .form__field-description').clone();
$desc.html("<strong>Warning</strong>: Changing your URL segment will force your Bitly URL to update and unfortunately the click count will reset as Bitly does not allow you to edit links.");
jQuery('.field.urlsegment .edit-holder').append($desc);
}
jQuery('#bitlyRefresh').entwine({
onclick: function () {
Vulcan.Bitly.updateClicks();
}
});
});

jQuery('#bitlyRefresh').on('click', function () {
_this.updateClicks();
});
},
var Vulcan = {
Bitly: {
copyUrl: function (url) {
var input = document.createElement('input');
input.setAttribute('value', url);
Expand Down Expand Up @@ -53,6 +60,4 @@ var Vulcan = {
})
}
}
};

Vulcan.Bitly.initEvents();
};
1 change: 0 additions & 1 deletion js/bitly.min.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/Forms/BitlyField.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class BitlyField extends ReadonlyField
*/
public function __construct($name, $title = null, $value = null, BitlyUrl $record)
{
Requirements::javascript('vulcandigital/silverstripe-bitly:js/bitly.min.js');
Requirements::javascript('vulcandigital/silverstripe-bitly:dist/js/bitly.min.js');
$this->setBitly($record);

parent::__construct($name, $title, $value);
Expand Down

0 comments on commit f514795

Please sign in to comment.