SharePoint Pals
 | Sign In
Floating panel for angular js
by Krishna KV 16 Apr 2016
Author
Team Leader, Aspire Systems
Visits   
Today  :   4     Total  :    8160

JSPanel is one of the popular jQuery plugin for creating dynamic re-sizeable panels. In this article we can see how to create a Angualr Js directive for Js Panel so that it can be used in an application in Angular way.

Intro to jsPanel

JSPanel can be used as floating panel, model window or as tooltip. The content can be loaded using static or ajax content.  JsPanel comes with a set of in-built icons but we are free to use Bootstrap or font awesome icons and override the default ones. As this is a jQuery plugin, jQuery 1.9 or above and jQuery UI 1.9 or above is a pre-requisite for this plugin.

Angular Directive

 app.directive('floatingPanel', function () {
     return {
         restrict: 'A',
         scope: {
             parentTag: '@',
             title: '@',
             content: '@',
             htmlTag:'@',
             theme: '@',         
         },
         link: function (scope, elem, attrs) {
             var config =
             {
                 title: scope.title == undefined ? '' : scope.title,
                 position: "center",
                 size: { width: 450, height: 250 },
                 content: scope.htmlTag == undefined ? scope.content : $('#'+ scope.htmlTag),
                 theme: scope.theme == undefined ? 'success' : scope.theme,
 
             };
             
             var size, position;
 
             if (scope.parentTag != undefined) {
                 var element = $('#' + scope.parentTag);
                 var pos = element.offset();
                 config.size = { width: element.width(), height: element.height() };
                 config.position = { top: pos.top, left: pos.left }
                 
             }
             
 
 
             var panel1 = $.jsPanel({
 
                 config
             });
 
         }
     };
 })

parentTag – to set the height, width position based on the html tag
title – to add the title for the panel
content – string parameter, which can be html or plain text.  Or htmlTag – to load the html content  from the page (id as the value).
theme -  to add the theme for the panel.

Controller

 var app = angular.module('appModule', []);
 
 (function () {
 
 
     app.controller('mainController', ['$scope', function ($scope) {
         $scope.title = "Title";
         $scope.date = new Date().toUTCString();
         $scope.onclick = function () {
             $scope.date = new Date().toUTCString();
         };
     }]);
 
 })();

HTML Page

 <!DOCTYPE html>
 <html ng-app="appModule">
 <head>
     <title></title>
 	<meta charset="utf-8" />
     <link href="Content/jquery-ui.complete.min.css" rel="stylesheet" />
     <link href="Content/jquery.jspanel.css" rel="stylesheet" />
     <link href="Content/bootstrap.css" rel="stylesheet" />
     <link href="Content/app.css" rel="stylesheet" />
 </head>
 <style type="text/css">
     .border{
         border:1px solid gray;
     }
 </style>
 <body>
 
     <div>
         <div ng-controller="mainController" style="width:100%;height:550px">
 
             <div style="width:38%;height:100%;float:left" class="border" id="leftDiv">
 
                 <div id="hcontent">
                     <h1>{{title}}</h1>
 
                     <p style="margin-right:20px;font-size:20px;color:blue">
                       
                         {{date}}
                         <button type="button" class="btn btn-default" ng-click="onclick()">Click</button>
 
                     </p>
                 </div>
                 <div floating-panel title="Left" parent-tag="leftDiv" html-tag="hcontent"></div>
             </div>
 
             <div floating-panel title="Right" parent-tag="rightDiv" content="<h1>Test</h1><p>This is paragraph</p>"></div>
 
             <div style="width:60%;height:100%;float:right" class="border" id="rightDiv">
 
             </div>
 
 
         </div>
     </div>
 
     <script src="Scripts/jquery-2.1.4.min.js"></script>
     <script src="Scripts/jquery-ui-complete.min.js"></script>
     <script src="Scripts/vendor/jquery-ui-touch-punch/jquery.ui.touch-punch.js"></script>
     <script src="Scripts/jquery.jspanel.js"></script>
     <script src="Scripts/angular.js"></script>
 
     <script src="app/app.js"></script>
     <script src="app/app.directive.js"></script>
 
 </body>
 </html>

Output

jsPanel

 

References

http://jspanel.de/
https://github.com/Flyer53/jsPanel

blog comments powered by Disqus

SharePoint Pals

Pals
SharePoint Pals, a community portal for SharePoint developers, Administrators and End Users. Let's join hands and share the point together.
Read this on mobile

Training

Angular Js Training In Chennai
Advanced Angular Js training with real world developer scenarios
Angular Js, Web Api and Ionic for .Net Developers
All in one client side application development for .Net developers
Angular Js For SharePoint Developers
Get ready for the future. Its no more just C#

Get Connected

SharePoint Resources

SharePoint 2013 and 2010 Web Parts
Free Web Parts with Source Code for SharePoint Community




SharePoint 2013 Books and Tutorials
Collection of free SharePoint 2013 books and tutorials (eBooks, pdfs)

Supported By

Contribute your article and be eligible for a one month Free Subscription for Plural Sight. The Author of the most popular New Article (published in the previous month) will be awarded with a Free One month Plural Sight Subscription. Article can be sent to articles@sharepointpals.com in a word document.

Related Resources

Recent Tweets

Twitter January 15, 00:25
How To Enable Target Value And Actual Value In #D3 Gauge Chart https://t.co/VxSi4QnNrC

Twitter January 15, 00:24
How To Open #SharePoint List Hyperlink Column In Modal #Popup Window https://t.co/EQ7HkoZDkX

Twitter January 15, 00:24
Quick Introduction To #Asp.NetCore And It’s Features https://t.co/zAXObHCFpH

Twitter January 15, 00:22
How To Configure #PerformancePoint Services To Use Secure Store In #SharePoint 2013 https://t.co/LEwnUoI7EY

Twitter January 15, 00:21
How To Block Or Disable #Office365 Services https://t.co/Yvp2VPFIRP

Follow us @SharePointPals
Note: For Customization and Configuration, CheckOutRecent Tweets Documentation