Skip to content

Commit 8aae86d

Browse files
committed
Initial commit
0 parents  commit 8aae86d

23 files changed

+638
-0
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
src/packages/
2+
src/Skybrud.CharLimitEditor/bin/
3+
src/Skybrud.CharLimitEditor/obj/
4+
*.suo
5+
*.user
6+
src/Skybrud.CharLimitEditor/App_Data/NuGetBackup/
7+
node_modules/
8+
releases/temp/

Gruntfile.js

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
module.exports = function (grunt) {
2+
3+
var path = require('path');
4+
5+
// Load the package JSON file
6+
var pkg = grunt.file.readJSON('package.json');
7+
8+
// get the root path of the project
9+
var projectRoot = 'src/' + pkg.name + '/';
10+
11+
// Load information about the assembly
12+
var assembly = grunt.file.readJSON(projectRoot + 'Properties/AssemblyInfo.json');
13+
14+
// Get the version of the package
15+
var version = assembly.informationalVersion ? assembly.informationalVersion : assembly.version;
16+
17+
grunt.initConfig({
18+
pkg: pkg,
19+
clean: {
20+
files: [
21+
'releases/temp/'
22+
]
23+
},
24+
copy: {
25+
binary: {
26+
files: [
27+
{
28+
expand: true,
29+
cwd: projectRoot + 'bin/',
30+
src: [
31+
pkg.name + '.dll',
32+
pkg.name + '.xml',
33+
'Skybrud.Umbraco.GridData.dll',
34+
'Skybrud.Umbraco.GridData.xml',
35+
'Skybrud.Essentials.dll',
36+
'Skybrud.Essentials.xml'
37+
],
38+
dest: 'releases/temp/bin/'
39+
}
40+
]
41+
},
42+
resources: {
43+
files: [
44+
{
45+
expand: true,
46+
cwd: projectRoot + 'App_Plugins/' + pkg.name + '/',
47+
src: ['**/*.*'],
48+
dest: 'releases/temp/App_Plugins/' + pkg.name + '/'
49+
}
50+
]
51+
},
52+
nuget: {
53+
files: [
54+
{
55+
expand: true,
56+
cwd: 'releases/nuget/',
57+
src: [pkg.name + '.' + version + '.nupkg'],
58+
dest: 'D:/NuGet/'
59+
}
60+
]
61+
}
62+
},
63+
nugetpack: {
64+
dist: {
65+
src: 'src/' + pkg.name + '/' + pkg.name + '.csproj',
66+
dest: 'releases/nuget/'
67+
}
68+
},
69+
zip: {
70+
release: {
71+
router: function (filepath) {
72+
var name = path.basename(filepath);
73+
return name == 'LICENSE.html' ? name : filepath.replace('releases/temp/', '');
74+
},
75+
src: [
76+
'releases/temp/**/*.*',
77+
projectRoot + '/LICENSE.html'
78+
],
79+
dest: 'releases/github/' + pkg.name + '.v' + version + '.zip'
80+
}
81+
},
82+
umbracoPackage: {
83+
dist: {
84+
src: 'releases/temp/',
85+
dest: 'releases/umbraco',
86+
options: {
87+
name: pkg.name,
88+
version: version,
89+
url: pkg.url,
90+
license: pkg.license.name,
91+
licenseUrl: pkg.license.url,
92+
author: pkg.author.name,
93+
authorUrl: pkg.author.url,
94+
readme: pkg.readme,
95+
outputName: pkg.name + '.v' + version + '.zip'
96+
}
97+
}
98+
}
99+
});
100+
101+
grunt.loadNpmTasks('grunt-contrib-clean');
102+
grunt.loadNpmTasks('grunt-contrib-copy');
103+
grunt.loadNpmTasks('grunt-nuget');
104+
grunt.loadNpmTasks('grunt-zip');
105+
grunt.loadNpmTasks('grunt-umbraco-package');
106+
107+
grunt.registerTask('release', ['clean', 'copy:binary', 'copy:resources', 'nugetpack', 'zip', 'umbracoPackage', 'clean']);
108+
grunt.registerTask('dev', ['release']);
109+
110+
grunt.registerTask('default', ['release']);
111+
112+
};

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 [Skybrud.dk](http://www.skybrud.dk/)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Skybrud.CharLimitEditor",
3+
"url": "https://github.com/skybrud/Skybrud.CharLimitEditor",
4+
"license": {
5+
"name": "MIT",
6+
"url": "https://github.com/skybrud/Skybrud.CharLimitEditor/blob/master/LICENSE.md"
7+
},
8+
"author": {
9+
"name": "Skybrud.dk",
10+
"url": "http://www.skybrud.dk/"
11+
},
12+
"readme": "Char limit property editor for Umbraco 7+.",
13+
"devDependencies": {
14+
"grunt": "~0.4.5",
15+
"grunt-contrib-copy": "~0.4.1",
16+
"grunt-nuget": "~0.1.4",
17+
"grunt-zip": "~0.17.0",
18+
"grunt-umbraco-package": "1.0.0",
19+
"grunt-contrib-clean": "^0.7.0"
20+
}
21+
}

src/Skybrud.CharLimitEditor.sln

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.40629.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skybrud.CharLimitEditor", "Skybrud.CharLimitEditor\Skybrud.CharLimitEditor.csproj", "{A023AFD0-AA0F-4313-9BB7-E9710DB487FB}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D0AB4044-A66E-4949-AD0D-9885BAB2C3FC}"
9+
ProjectSection(SolutionItems) = preProject
10+
WebEssentials-Settings.json = WebEssentials-Settings.json
11+
EndProjectSection
12+
EndProject
13+
Global
14+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
15+
Debug|Any CPU = Debug|Any CPU
16+
Release|Any CPU = Release|Any CPU
17+
EndGlobalSection
18+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
19+
{A023AFD0-AA0F-4313-9BB7-E9710DB487FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{A023AFD0-AA0F-4313-9BB7-E9710DB487FB}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{A023AFD0-AA0F-4313-9BB7-E9710DB487FB}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{A023AFD0-AA0F-4313-9BB7-E9710DB487FB}.Release|Any CPU.Build.0 = Release|Any CPU
23+
EndGlobalSection
24+
GlobalSection(SolutionProperties) = preSolution
25+
HideSolutionNode = FALSE
26+
EndGlobalSection
27+
EndGlobal
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
3+
<language alias="da" intName="Danish" localName="dansk" lcid="6" culture="da-DK">
4+
<area alias="skyCharLimit">
5+
<key alias="info1"><![CDATA[Du har <strong class="positive">%0%</strong> tegn tilbage.]]></key>
6+
<key alias="info2"><![CDATA[Du har <strong class="negative">%0%</strong> tegn tilbage.]]></key>
7+
<key alias="info3"><![CDATA[Du kan ikke angive mere end <strong class="negative">%0%</strong> tegn!]]></key>
8+
</area>
9+
</language>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
3+
<language alias="en" intName="English (US)" localName="English (US)" lcid="" culture="en-US">
4+
<area alias="skyCharLimit">
5+
<key alias="info1"><![CDATA[You have <strong class="positive">%0% characters remaining.]]></key>
6+
<key alias="info2"><![CDATA[You have <strong class="negative">%0% characters remaining.]]></key>
7+
<key alias="info3"><![CDATA[You cannot write more than <strong class="negative">%0%</strong> characters!]]></key>
8+
</area>
9+
</language>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
3+
<language alias="en" intName="English (UK)" localName="English (UK)" lcid="" culture="en-GB">
4+
<area alias="skyCharLimit">
5+
<key alias="info1"><![CDATA[You have <strong class="positive">%0% characters remaining.]]></key>
6+
<key alias="info2"><![CDATA[You have <strong class="negative">%0% characters remaining.]]></key>
7+
<key alias="info3"><![CDATA[You cannot write more than <strong class="negative">%0%</strong> characters!]]></key>
8+
</area>
9+
</language>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
angular.module('umbraco').controller('Skybrud.CharLimitEditorController', function ($scope, localizationService) {
2+
3+
// Initialize the configuration
4+
var limit = parseInt($scope.model.config.limit);
5+
$scope.model.config.multiline = $scope.model.config.multiline === '1' || $scope.model.config.multiline === true;
6+
$scope.model.config.enforce = $scope.model.config.enforce === '1' || $scope.model.config.enforce === true;
7+
8+
9+
10+
$scope.limitChars = function () {
11+
if ($scope.model.value.length > limit && $scope.model.config.enforce) {
12+
$scope.info = 'You cannot write more than <strong class="negative">' + limit + '</strong> characters!';
13+
14+
localizationService.localize('skyCharLimit_info3', [limit]).then(function (value) {
15+
$scope.info = value;
16+
});
17+
18+
$scope.model.value = $scope.model.value.substr(0, limit);
19+
} else {
20+
var remaining = (limit - $scope.model.value.length);
21+
if ($scope.model.value.length > limit) {
22+
localizationService.localize('skyCharLimit_info2', [remaining]).then(function (value) {
23+
$scope.info = value;
24+
});
25+
} else {
26+
localizationService.localize('skyCharLimit_info1', [remaining]).then(function (value) {
27+
$scope.info = value;
28+
});
29+
}
30+
}
31+
};
32+
33+
$scope.limitChars();
34+
35+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.SkybrudCharLimitEditor .info {
2+
margin-top: 2px;
3+
font-size: 11px;
4+
}
5+
.SkybrudCharLimitEditor .positive {
6+
color: #008800;
7+
}
8+
.SkybrudCharLimitEditor .negative {
9+
color: #880000;
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.SkybrudCharLimitEditor {
2+
.info {
3+
margin-top: 2px;
4+
font-size: 11px;
5+
}
6+
.positive {
7+
color: #008800;
8+
}
9+
.negative {
10+
color: #880000;
11+
}
12+
}

src/Skybrud.CharLimitEditor/App_Plugins/Skybrud.CharLimitEditor/Styles/Styles.min.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<div class="SkybrudCharLimitEditor" ng-controller="Skybrud.CharLimitEditorController">
2+
<div ng-if="model.config.multiline">
3+
<textarea ng-model="model.value" ng-change="limitChars()" rows="10" class="umb-editor umb-textarea textstring"></textarea>
4+
</div>
5+
<div ng-if="!model.config.multiline">
6+
<input ng-model="model.value" ng-change="limitChars()" type="text" class="umb-editor umb-textstring textstring" />
7+
</div>
8+
<div class="info" ng-bind-html="info"></div>
9+
</div>
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"propertyEditors": [
3+
{
4+
"alias": "Skybrud.CharLimitEditor",
5+
"name": "Char limit",
6+
"editor": {
7+
"view": "~/App_Plugins/Skybrud.CharLimitEditor/Views/CharLimitEditor.html"
8+
},
9+
"prevalues": {
10+
"fields": [
11+
{
12+
"label": "Number of characters",
13+
"description": "Enter the number of characters to limit on.",
14+
"key": "limit",
15+
"view": "number"
16+
},
17+
{
18+
"label": "Multiline",
19+
"description": "Allow multiline textbox.",
20+
"key": "multiline",
21+
"view": "boolean"
22+
},
23+
{
24+
"label": "Enforce limit",
25+
"description": "Enforce the limit.",
26+
"key": "enforce",
27+
"view": "boolean"
28+
}
29+
]
30+
}
31+
}
32+
],
33+
"javascript": [
34+
"~/App_Plugins/Skybrud.CharLimitEditor/Scripts/Controllers/CharLimitEditor.js"
35+
],
36+
"css": [
37+
"~/App_Plugins/Skybrud.CharLimitEditor/Styles/Styles.css"
38+
]
39+
}

0 commit comments

Comments
 (0)