diff --git a/css/profile_freelist.css b/css/profile_freelist.css new file mode 100644 --- /dev/null +++ b/css/profile_freelist.css @@ -0,0 +1,4 @@ +.profile_share img{ + width: 75px; + height: 28px; +} \ No newline at end of file diff --git a/js/profile.js b/js/profile.js --- a/js/profile.js +++ b/js/profile.js @@ -1,12 +1,22 @@ var url= ''; (function ($, Drupal, drupalSettings) { })(jQuery, Drupal, drupalSettings); function print_content(){ var printContents = jQuery("#block-bootstrap-content").html(); var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; +} +function hover_share(data){ + var src = data.getAttribute('src'); + var hover = src.replace("1","2"); + data.setAttribute('src',hover); +} +function out_share(data){ + var src = data.getAttribute('src'); + var hover = src.replace("2","1"); + data.setAttribute('src',hover); } \ No newline at end of file diff --git a/src/Plugin/Block/TYPProfileShareBlock.php b/src/Plugin/Block/TYPProfileShareBlock.php new file mode 100644 --- /dev/null +++ b/src/Plugin/Block/TYPProfileShareBlock.php @@ -0,0 +1,86 @@ +getRequestUri(); + $language = \Drupal::languageManager()->getCurrentLanguage()->getId(); + $bid = end(explode("/",$url)); + $this->data = \Drupal::service("typ.search")->getProfile($bid ,AUTO); + $this->result = \Drupal::service('typ.unvservice')->loadListing($this->data['customerid'],NULL); + $type = $this->result['address'][$this->data['headingcode']][$this->data['addressid']]['customertype']; + + switch ($type){ + case "FL": + $email = 'mailto:email@address.com?subject='.format_string($this->data['humanname']).'&body=Link:'.format_string($fullurl).format_string($this->data['proddesc']); + $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.$fullurl; + $twitter = $fullurl; + $gplus = 'https://plus.google.com/share?url='.$fullurl; + break; + default: + $email = 'mailto:email@address.com?subject='.format_string($this->data['humanname']).'&body=Link:'.format_string($fullurl).format_string($this->data['proddesc']); + $facebook = 'https://www.facebook.com/sharer/sharer.php?u='.$fullurl; + $twitter = $fullurl; + $gplus = 'https://plus.google.com/share?url='.$fullurl; + } + + $base_url_images = '/themes/bootstrap/typ/images/icon-service-profilepage/'.$language; + + $build = array(); + + $build[] = array( + '#markup' => format_string('
'), + ); + + $build['#attached']['library'] = array( + 'typ_profile/profile_share' + ); + return $build; + } + +} +?> \ No newline at end of file diff --git a/typ_profile.libraries.yml b/typ_profile.libraries.yml --- a/typ_profile.libraries.yml +++ b/typ_profile.libraries.yml @@ -1,3 +1,8 @@ profile.popup: js: - js/profile.js: {} \ No newline at end of file + js/profile.js: {} + +profile_share: + css: + theme: + css/profile_freelist.css: {}