-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
80 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/// <reference path='../../_all.ts'/> | ||
|
||
namespace SitecoreExtensions.Modules.AddHere { | ||
export class AddHereButton { | ||
classButtonInitialized: string = "sc-ext-addHere-button-initialized"; | ||
innerElement: HTMLDivElement; | ||
textElement: HTMLSpanElement; | ||
placeholderName: string; | ||
constructor(innerElement: HTMLDivElement) { | ||
this.innerElement = innerElement; | ||
this.textElement = this.innerElement.nextElementSibling.firstChild as HTMLSpanElement; | ||
this.placeholderName = this.innerElement.parentElement.title.match(/'.*'/)[0].replace(/'/g, ""); | ||
this.innerElement.classList.add(this.classButtonInitialized); | ||
} | ||
|
||
public setText(text: string) { | ||
this.textElement.innerText = text; | ||
} | ||
|
||
public getText(): string { | ||
return this.textElement.innerText; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/// <reference path='../../_all.ts'/> | ||
|
||
namespace SitecoreExtensions.Modules.AddHere { | ||
export class AddHereModule extends ModuleBase implements ISitecoreExtensionsModule { | ||
constructor(name: string, description: string, rawOptions: Options.ModuleOptionsBase) { | ||
super(name, description, rawOptions); | ||
} | ||
|
||
canExecute(): boolean { | ||
return this.options.enabled && Context.Location() == Enums.Location.ExperienceEditor; | ||
} | ||
|
||
initialize(): void { | ||
if (window["Sitecore"] != null && Sitecore.PageModes != null) { | ||
HTMLHelpers.addProxy((Sitecore.PageModes.DesignManager as any), 'insertionStart', () => { this.refreshControls(); }); | ||
} | ||
} | ||
|
||
getAddHereButtons(): Array<AddHereButton> { | ||
var elements = document.querySelectorAll('.scInsertionHandleLeft.scAddToHere:not(.sc-ext-addHere-button-initialized)') as NodeListOf<HTMLDivElement>; | ||
return Array.from(Array.prototype.slice.call(elements) as Array<HTMLDivElement>, e => new AddHereButton(e)); | ||
} | ||
|
||
refreshControls(): void { | ||
var addHereButtons = this.getAddHereButtons(); | ||
if (addHereButtons.length === 0) { | ||
return; | ||
} | ||
|
||
addHereButtons.forEach(button => { | ||
let buttons = addHereButtons.filter(function (b) { return b.placeholderName == button.placeholderName; }); | ||
let txt = button.getText() + " | " + button.placeholderName; | ||
if (buttons.length > 1) { | ||
let index = buttons.indexOf(button) + 1; | ||
txt = txt + "(" + index + ")"; | ||
} | ||
button.setText(txt); | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/// <reference path='../../_all.ts'/> | ||
|
||
/// <reference path='AddHereButton.ts'/> | ||
/// <reference path='AddHereModule.ts'/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
declare var scForm: any; | ||
declare var scSitecore: any; | ||
declare var Sitecore: any; | ||
declare var scContentEditor: any; |