Skip to content

Commit

Permalink
small output related fixes; and indentation ;)
Browse files Browse the repository at this point in the history
  • Loading branch information
tanius committed Jan 24, 2015
1 parent 0f41129 commit 8c75f22
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 53 deletions.
32 changes: 14 additions & 18 deletions drupal_annotation/annotation.controller.inc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class AnnotationAPIController extends EntityAPIController {

if ($entity->tid != NULL) {
$term = taxonomy_term_load($entity->tid);
$term_markup = l($term->name, "taxonomy/term/$term->tid") . " (tid: $term->tid)";
$term_markup = l($term->name, "taxonomy/term/{$term->tid}") . " (tid: {$term->tid})";
}
else {
$term_markup = '';
Expand Down Expand Up @@ -110,22 +110,18 @@ class AnnotationAPIController extends EntityAPIController {
}
}

function get_properties($obj, $values=false)
{
$obj_dump = print_r($obj, 1);
$matches = array();
preg_match_all('/^\s+\[(\w+).*\] => (\w*)/m', $obj_dump, $matches);
if ($values)
{
$output = array();
foreach ($matches[1] as $key => $property)
{
$output[$property] = $matches[2][$key];
}
return $output;
}
else
{
return $matches[1];
function get_properties($obj, $values=false) {
$obj_dump = print_r($obj, 1);
$matches = array();
preg_match_all('/^\s+\[(\w+).*\] => (\w*)/m', $obj_dump, $matches);
if ($values) {
$output = array();
foreach ($matches[1] as $key => $property) {
$output[$property] = $matches[2][$key];
}
return $output;
}
else {
return $matches[1];
}
}
8 changes: 5 additions & 3 deletions drupal_annotation/js/annotator_store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
(function ($) {
Drupal.behaviors.annotatorStore = {

attach: function (context, settings) {
Drupal.Annotator.annotator('addPlugin', 'Store', {
prefix: settings.annotator_store.prefix,
Expand All @@ -10,11 +11,12 @@
'type': 'annotator'
},
loadFromSearch: function(that){
return {
'nid': jQuery(that.element).parents('.node').attr('id').split('-')[1]
return {
'nid': jQuery(that.element).parents('.node').attr('id').split('-')[1]
};
},
},
});
}

};
})(jQuery);
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ $plugin = array(
'class' => 'StoreAnnotatorPlugin',
),
);

69 changes: 38 additions & 31 deletions drupal_annotator/js/annotator_drupalnode.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,53 @@
var _ref,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

Annotator.Plugin.DrupalNode = (function(_super) {
__extends(DrupalNode, _super);
function DrupalNode(element) {
return DrupalNode.__super__.constructor.apply(this, arguments);
__extends = function(child, parent) {
for (var key in parent) {
if (__hasProp.call(parent, key)) child[key] = parent[key];
}
function ctor() { this.constructor = child; }
ctor.prototype = parent.prototype;
child.prototype = new ctor();
child.__super__ = parent.prototype;
return child;
};

DrupalNode.prototype.pluginInit = function() {
if (!Annotator.supported()) {
return;
}

Annotator.Plugin.DrupalNode = (function(_super) {
__extends(DrupalNode, _super);

function DrupalNode(element) {
return DrupalNode.__super__.constructor.apply(this, arguments);
}

DrupalNode.prototype.pluginInit = function() {
if (!Annotator.supported()) {
return;
}

this.annotator.subscribe(
'annotationEditorSubmit',
function(editor, annotation) {
annotation.nid = editor.element.parents('.node').attr('id').split('-').slice(-1).pop();
}
);

this.annotator.subscribe('annotationsLoaded', function(annotations){
jQuery('.annotator-hl').each(function(){
if(
jQuery(this).data('annotation').user.uid == Drupal.settings.annotator_permissions.user.uid){
jQuery(this).addClass('annotator-own-annotation');
}
else {
jQuery(this).addClass('annotator-others-annotation');
}
}
);
});




};
return DrupalNode;

})(Annotator.Plugin);
this.annotator.subscribe(
'annotationsLoaded',
function(annotations) {
jQuery('.annotator-hl').each(function() {
if (jQuery(this).data('annotation').user.uid == Drupal.settings.annotator_permissions.user.uid) {
jQuery(this).addClass('annotator-own-annotation');
}
else {
jQuery(this).addClass('annotator-others-annotation');
}
});
}
);
};

return DrupalNode;
})(Annotator.Plugin);

(function ($) {
Drupal.behaviors.annotatorDrupalNode = {
Expand Down

0 comments on commit 8c75f22

Please sign in to comment.