Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample Movable Type plugin to fix bug reported in https://movabletype.atlassian.net/browse/FEEDBACK-1185
# MIT License
#
# Copyright (c) 2018 Six Apart Ltd.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
package MT::Plugin::DraggableFieldBugWorkaroundSample;
use strict;
use warnings;
use base 'MT::Plugin';
use MT;
MT->add_plugin(
__PACKAGE__->new(
{ name => 'DraggableFieldBugWorkdaroundSample',
registry => {
applications => {
cms => {
callbacks =>
{ 'template_param.edit_entry' => \&_add_js_code },
},
},
},
}
)
);
sub _add_js_code {
my ( $cb, $app, $param, $tmpl ) = @_;
my $new_jq_js_include = $tmpl->createElement(
'setvarblock',
{ name => 'jq_js_include',
append => 1,
},
);
$new_jq_js_include->innerHTML(
q/jQuery('#sortable [draggable]').removeAttr('draggable');/);
my $last_jq_js_include = $tmpl->getElementsByName('jq_js_include')->[-1];
$tmpl->insertAfter( $new_jq_js_include, $last_jq_js_include );
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment