Friday, July 29, 2011

Hiding Ribbon in SP2010

The new ribbon in SP2010 looks nice from a editors point of view. All web-parts seems controlled by the contextual ribbon.Using web-parts on a public website, like a discussion board etc....
The public website is fully skinned now how do we make only the editor to see the ribbon for page.
Answer is as follows :- place you Ribbon Div inside below tag and see the result

<sharepoint:spsecuritytrimmedcontrol permissions="”ManageWeb”" runat="”server”"> 
Control/Ribbon
</sharepoint:spsecuritytrimmedcontrol> 
 
this was for hiding Ribbon but with the help of this we can hide our control also.instead of div just place you control over there.

Permission used in above example is ManageLists we do have other permissions also as follows :-

AddAndCustomizePages
AddDelPrivateWebParts
AddListItems
ApplyStyleSheets
ApplyThemeAndBorder
ApproveItems
BrowseDirectories
BrowseUserInfo
CancelCheckout
CreateAlerts
CreateGroups
CreateSSCSite
DeleteListItems
DeleteVersions
EditListItems
EditMyUserInfo
EmptyMask
EnumeratePermissions
FullMask
ManageAlerts
ManageLists
ManagePermissions
ManagePersonalViews
ManageSubwebs
ManageWeb
Open
OpenItems
UpdatePersonalWebParts
UseClientIntegration
UseRemoteAPIs
ViewFormPages
ViewListItems
ViewPages
ViewUsageData
ViewVersions

Custom SpellCheck in Moss 2007 for Page

Register this Js in you page where you want to use Spell Check


Use followinf funtion in you button click and you are ready yo have custom SpellCheck ready

function doSpellCheck() {
        SpellCheckEntirePage('/_vti_bin/SpellCheck.asmx', '/_layouts/SpellChecker.aspx');
    }

Javascript Formating

Following Function can be use to IsNumeric & Formating Phone Number

    function fncInputNumericValuesOnly() {
        if (!(event.keyCode == 45 || event.keyCode == 48 || event.keyCode == 49 || event.keyCode == 50 || event.keyCode == 51 || event.keyCode == 52 || event.keyCode == 53 || event.keyCode == 54 || event.keyCode == 55 || event.keyCode == 56 || event.keyCode == 57 || event.keyCode == 0 || event.keyCode == 46)) {
            event.returnValue = false;
        }
    }

This Function will return Formated Phone Number E.g : (123)-123-1234

    function fncInputNumericValuesOnlyPhone(objFormField) {
        if (!(event.keyCode == 45 || event.keyCode == 48 || event.keyCode == 49 || event.keyCode == 50 || event.keyCode == 51 || event.keyCode == 52 || event.keyCode == 53 || event.keyCode == 54 || event.keyCode == 55 || event.keyCode == 56 || event.keyCode == 0 || event.keyCode == 46 || event.keyCode == 57)) {
            event.returnValue = false;
        }
        else {
            var PH = objFormField.value;
            PH = PH.replace("(", "");
            PH = PH.replace(")", "");
            PH = PH.replace("-", "");
            PH = PH.replace(" ", "");
            if (PH.length < 3) {
                objFormField.value = "(" + PH;
            }
            if (PH.length > 3 && PH.length <= 6) {
                objFormField.value = "(" + PH.substring(0, 3) + ") " + PH.substring(3, 6);
            }
            if (PH.length > 6) {
                objFormField.value = "(" + PH.substring(0, 3) + ") " + PH.substring(3, 6) + "-" + PH.substring(6, 10);
            }
        }
    }

Sharepoint 2007 Alert Template Name

Alert Template Name                                                              Description

SPAlertTemplateType.GenericList                                          The first alert template in Alerttemplates.xml.                                                                 GenericList is used unless there is                                                                                            a  match to one of other event types.

SPAlertTemplateType.DocumentLibrary                                 Notification of changes in document libraries

SPAlertTemplateType.Survey                                                 Notification of changes in surveys

SPAlertTemplateType.Links                                                   Notification of changes in links

SPAlertTemplateType.Announcements                                   Notification of changes in announcements

SPAlertTemplateType.Contacts                                              Notification of changes in contacts

SPAlertTemplateType.Events                                                 Notification of changes in events

SPAlertTemplateType.Tasks                                                  Notification of changes in tasks

SPAlertTemplateType.DiscussionBoard                                 Notification of changes in discussion boards

SPAlertTemplateType.PictureLibrary                                     Notification of changes in picture libraries

SPAlertTemplateType.XMLForm                                         Notification of changes in XML form

SPAlertTemplateType.DataConnectionLibrary                       Notification of changes in data connection libraries
                
SPAlertTemplateType.AssignedtoNotification                        Assigned to task / issue list notifications

Adding Context Menu List/library MOSS 2007/Sharepoint 2010

You can add this javascript sharepoint pages with the help of webparts,of using sharepoint designer

Following Javascript Function will add new Menu item Custom Menu to Custom List

function Custom_AddListMenuItems(m, ctx)
{
//this is Title
var strText = "Custom Menu";
//this will add action to be performed e.g in our case it will alert ListItem id
var strAction ="alert(currentItemID)";
//this will add Image to you Context Menu
var strSelectionImage = '';
//this will add you Menu Item to list Menu
CAMOpt(m, strText, strAction, strSelectionImage);
return true;
}

Following Javascript Function will add new Menu item Custom Menu to Custom Library

function Custom_AddDocLibMenuItems(m, ctx)
{
var strText = "Custom Menu";
var strAction ="alert(currentItemID)";
var strSelectionImage = '';
CAMOpt(m, strText, strAction,strSelectionImage);
return true
}

Hope this will help you to add and customize you Sharepoint Context Menu


Following are some usefull javascript object of Sharepoint

0: ctx[listBaseType] : 1                                                 1: ctx[listTemplate] : 101

2: ctx[listName] : {5726BE86-34A8-47F8-AB73-105E34D807F2}

3: ctx[view] : {475151F9-6C22-45FB-B19E-FFE7EC13ADC3}

4: ctx[listUrlDir] : /projects/scans

5: ctx[HttpPath] : /projects/_vti_bin/owssvr.dll?CS=65001

6: ctx[HttpRoot] : http://xxx/projects

7: ctx[serverUrl] : null                                                    8: ctx[imagesPath] : /_layouts/images/

9: ctx[PortalUrl] : null                                                    10: ctx[RecycleBinEnabled] : -1

11: ctx[isWebEditorPreview] : 0                                   12: ctx[rootFolderForDisplay] : null

13: ctx[isPortalTemplate] : null                                      14: ctx[isModerated] : false

15: ctx[recursiveView] : false                                                                                       

16: ctx[displayFormUrl] : /projects/scans/Forms/DispForm.aspx

17: ctx[editFormUrl] : /projects/scans/Forms/EditForm.aspx

18: ctx[newFormUrl] : null                                            19: ctx[ctxId] : 1                                              

20: ctx[CurrentUserId] : 24                                           21: ctx[isForceCheckout] : false

22: ctx[EnableMinorVersions] : false                             23: ctx[ModerationStatus] : 0

24: ctx[verEnabled] : 1                                                 25: ctx[isVersions] : 0

26: ctx[WorkflowsAssociated] : true                             27: ctx[ContentTypesEnabled] : false

28: ctx[SendToLocationName] :                                   29: ctx[SendToLocationUrl] :

30: ctx[OfficialFileName] :                                            31: ctx[WriteSecurity] : 1

32: ctx[SiteTitle] : Projects                                            33: ctx[ListTitle] : scans


Continu............................

0: m[language] :                                                            1: m[scrollHeight] : 0

2: m[isTextEdit] : false                                                   3: m[currentStyle] : [object]

4: m[document] : [object]                                              5: m[onmouseup] : null

6: m[oncontextmenu] : null                                             7: m[isMultiLine] : true

8: m[clientHeight] : 0                                                     9: m[onrowexit] : null

10: m[onbeforepaste] : null                                            11: m[onactivate] : null

12: m[scrollLeft] : 0                                                      13: m[lang] :

14: m[onmousemove] : null                                            15: m[onmove] : null

16: m[onselectstart] : null                                               17: m[parentTextEdit] : [object]

18: m[oncontrolselect] : null                                           19: m[canHaveHTML] : true

20: m[onkeypress] : null                                                21: m[oncut] : null

22: m[onrowenter] : null                                                23: m[onmousedown] : null

24: m[onpaste] : null                                                      25: m[className] : ms-SrvMenuUI

26: m[id] : 14_menu                                                      27: m[onreadystatechange] : null

28: m[onbeforedeactivate] : null                                    29: m[hideFocus] : false

30: m[dir] :                                                                   31: m[isContentEditable] : false

32: m[onkeydown] : null                                                33: m[clientWidth] : 0

34: m[onlosecapture] : null                                            35: m[parentElement] : [object]

36: m[ondrag] : null                                                       37: m[ondragstart] : null

38: m[oncellchange] : null                                              39: m[recordNumber] : null

40: m[onfilterchange] : null                                             41: m[onrowsinserted] : null

42: m[ondatasetcomplete] : null                                    43: m[onmousewheel] : null

44: m[ondragenter] : null                                               45: m[onblur] : null

46: m[onresizeend] : null                                                47: m[onerrorupdate] : null

48: m[onbeforecopy] : null                                            49: m[ondblclick] : null

50: m[scopeName] : HTML                                         51: m[onkeyup] : null

52: m[onresizestart] : null                                               53: m[onmouseover] : null

54: m[onmouseleave] : null                                            55: m[outerText] :

56: m[innerText] :                                                         57: m[onmoveend] : null

58: m[tagName] : MENU                                             59: m[title] :

60: m[offsetWidth] : 0                                                  61: m[onresize] : null

62: m[contentEditable] : inherit                                     63: m[runtimeStyle] : [object]

64: m[filters] : [object]                                                 65: m[ondrop] : null

66: m[onpage] : null                                                      67: m[onrowsdelete] : null

68: m[tagUrn] :                                                             69: m[offsetLeft] : -1

70: m[clientTop] : 0                                                      71: m[style] : [object]

72: m[onfocusout] : null                                                73: m[clientLeft] : 0

74: m[ondatasetchanged] : null                                      75: m[canHaveChildren] : true

76: m[ondeactivate] : null                                              77: m[isDisabled] : false

78: m[onpropertychange] : null                                     79: m[ondragover] : null

80: m[onhelp] : null                                                       81: m[ondragend] : null

82: m[onbeforeeditfocus] : null                                      83: m[disabled] : false

84: m[onfocus] : null                                                      85: m[behaviorUrns] : [object]

86: m[accessKey] :                                                       87: m[onscroll] : null

88: m[onbeforeactivate] : null                                        89: m[onbeforecut] : null

90: m[readyState] : complete                                        91: m[all] : [object]

92: m[sourceIndex] : 1421                                            93: m[onclick] : null

94: m[scrollTop] : 0                                                      95: m[oncopy] : null

96: m[onfocusin] : null                                                  97: m[tabIndex] : 0

98: m[onbeforeupdate] : null                                          99: m[outerHTML] :


100: m[innerHTML] :                                                  101: m[ondataavailable] : null

102: m[offsetHeight] : 0                                                103: m[onmovestart] : null

104: m[onmouseout] : null                                             105: m[scrollWidth] : 0

106: m[offsetTop] : -1                                                  107: m[onmouseenter] : null

108: m[onlayoutcomplete] : null                                     109: m[offsetParent] : [object]

110: m[onafterupdate] : null                                           111: m[ondragleave] : null

112: m[children] : [object]                                             113: m[nodeName] : MENU

114: m[nodeValue] : null                                               115: m[ownerDocument] : [object]

116: m[firstChild] : null                                                  117: m[lastChild] : null

118: m[childNodes] : [object]                                       119: m[nextSibling] : null

120: m[parentNode] : [object]                                      121: m[type] :

122: m[compact] : false                                                 123: m[nodeType] : 1

124: m[previousSibling] : [object]                                  125: m[attributes] : [object]