Customize Branding In SharePoint 2013

I wanted to write this article since long time. Here am writing to fellow developers who wanted to play around with the SharePoint branding by customizing it based on their requirements.

I wanted to write this article for a very long time. Here, I am writing to the fellow developers who want to play around with SharePoint branding by customizing it based on their requirements.

Basically, all the customizations start with Master Page as far as the SharePoint On-premises is concerned.

Here are a few simple steps to be followed for achieving the customized global navigation cum branding in SharePoint 2013.

Step 1

  • In the SharePoint site, go to Site Settings > Master pages and page layouts.

SharePoint

  • Select Library > Open with Explorer.

    SharePoint

  • Make a copy of “seattle.html” in your local and edit the name of the file. Let’s say MyMaster.html and upload it back to the Master page document library.
  • It’ll create another file with the extension “.master” with the same name “MyMaster.master”.
  • We won’t be able to edit the “MyMaster.master” directly and we do all the changes in the “MyMaster.html” file only.

Step 2

  • Now, open the “MyMaster.html” file in an editor of your choice and do the below changes.
  • Add the jQuery reference under the <Head> tag.
    1. <script type="text/javascript" src="jquery-1.12.4.js">//<![CDATA[ //]]>  
    2. </script>  
  • Add the below scripts next to the above code.
    1. <script type="text/javascript">  
    2.     $(document).ready(function() {  
    3.         //This will replace the default “SharePoint” branding name to a custom one  
    4.         $('.ms-core-brandingText').replaceWith('<div><a href="#"><img src="Image.png " alt=”" title="Title"/></a></div>');  
    5.         //This will create a custom div to hold the custom navigational elements  
    6.         var div = document.createElement('div');  
    7.         div.setAttribute('class''GlobalNav');  
    8.         div.innerHTML = document.getElementById('divGlobalNav').innerHTML;  
    9.         //Replacing the DeltaSuiteLinks element with the GlobalNav Div  
    10.         $('#DeltaSuiteLinks').replaceWith(div);  
    11.         //This will set the Hover feature of Global Navigation  
    12.         $('.CH-userInfo').on({  
    13.             mouseenter: function() {  
    14.                 $('.CH-userInfoPopup').show();  
    15.             },  
    16.             mouseleave: function() {  
    17.                 $('.CH-userInfoPopup').hide();  
    18.             }  
    19.         });  
    20.         $('nav li').on({  
    21.             mouseenter: function() {  
    22.                 $('.CH-subMenu').each(function() {  
    23.                     var colCount = $(this).find('.CH-subMenu-col').length;  
    24.                     $(this).width(320 * colCount - 50);  
    25.                 });  
    26.                 $subMenuDiv = $(this).find('.CH-subMenu');  
    27.                 if ($subMenuDiv.length) {  
    28.                     nw = $('nav').width();  
    29.                     sw = $subMenuDiv.width();  
    30.                     $subMenuDiv.show();  
    31.                     menuTotalW = $subMenuDiv.offset().left + $subMenuDiv.width();  
    32.                     ew = (menuTotalW - $subMenuDiv.width()) / 2;  
    33.                     if (menuTotalW > 1280) {  
    34.                         if (nw > sw) {  
    35.                             sw = nw - sw;  
    36.                         } else {  
    37.                             sw = 0;  
    38.                         }  
    39.                         $subMenuDiv.offset({  
    40.                             left: ($('nav').offset().left) + sw  
    41.                         })  
    42.                     }  
    43.                 }  
    44.             },  
    45.             mouseleave: function() {  
    46.                 $(this).find('.CH-subMenu').hide();  
    47.             }  
    48.         });  
    49.     });  
    50. </script>  
    51. <!--Here is the global navigation div elements which can be customized as per the your needs-->  
    52. <div id="divGlobalNav" style="display:none;"> <span id="navbar">  
    53.   
    54.             <!-- // Header Start Here -->  
    55.             <header class="">  
    56.                 <div class="CH-innerContainer">  
    57.                     <nav class="">  
    58.                         <ul>  
    59.                             <li><a href="javascript:void(0);" class="">myApps</a>  
    60.                                 <!-- Submenu-->  
    61.                                 <div class="CH-subMenu" style="overflow-y:scroll;height:500px">  
    62.                                     <div class="CH-subMenu-col">  
    63.                                         <div class="CH-subMenu-Item app-all" style="display: block;">  
    64.                                             <h3 class="icon-myPage">  
    65.                                                 <a href="#/">myPage</a>  
    66.                                             </h3>  
    67.                                             <div class="CH-subMenu-Desc">Description</div>  
    68.                                             <div class="CH-readMoreNav">  
    69.                                                 <a href="#">[+] Go to</a>  
    70.                                             </div>  
    71.                                         </div>  
    72.                                     </div>  
    73.                                 </div>  
    74.                             </li>  
    75.                             <li><a href="javascript:void(0);">myPortals</a>  
    76.                                 <!-- Submenu PORTAL TOOLS -->  
    77.                                 <div class="CH-subMenu" style="width: 910px; display: none;">  
    78.                                     <div class="CH-subMenu-col">  
    79.                                         <div class="CH-subMenu-Item app-permanent" style="display: block;">  
    80.                                             <h3 class="no-icon">  
    81.                                                 <a href="#" target="_blank">  
    82.                                                     <img src="#" alt="">  
    83.                                                 </a>  
    84.                                                 <span class="icon-lock" title="Requires additional Login">      </span> <span class="icon-new-window" title="External Site"></span> </h3>  
    85.                                         <div class="CH-subMenu-Desc">Description</div>  
    86.                                         <div class="CH-readMoreNav"> <a href="#" target="_blank">[+] Go to</a> </div>  
    87.                                        </div>  
    88.                                     </div>  
    89.                                  </div>  
    90.                                  </li>  
    91.                               </ul>  
    92.                         </nav>  
    93.                      </div>  
    94.                </header>  
    95.             <!-- // Header End Here -->  
    96.          </span>  
    97. </div>  

Step 3

  • Save the MyMaster.html file and upload it under the Master Pages library.
  • Check in the MyMaster.Master Page and publish a Major Version.
  • All set now! The testing phase and bug fixing starts from here!!

Output

SharePoint

I hope it will help a wide range of developers!!

Happy SharePointing!!