Skip to content

Commit

Permalink
Merge pull request FuelInteractive#74 from coryshaw1/master
Browse files Browse the repository at this point in the history
0.3.3 - TextExpander, New Router, Documentation Updates
  • Loading branch information
coryshaw1 authored Jun 15, 2016
2 parents d18533f + 0b97c6a commit 65a74dd
Show file tree
Hide file tree
Showing 13 changed files with 682 additions and 243 deletions.
276 changes: 138 additions & 138 deletions bundles/fuel-ui.css

Large diffs are not rendered by default.

92 changes: 90 additions & 2 deletions bundles/fuel-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3411,6 +3411,92 @@ System.registerDynamic("fuel-ui/dist/components/TimePicker/TimePicker", ["@angul
return module.exports;
});

System.registerDynamic("fuel-ui/dist/components/TextExpander/TextExpander", ["@angular/core", "@angular/common"], true, function($__require, exports, module) {
"use strict";
;
var define,
global = this,
GLOBAL = this;
var __decorate = (this && this.__decorate) || function(decorators, target, key, desc) {
var c = arguments.length,
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function(k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(k, v);
};
var core_1 = $__require('@angular/core');
var common_1 = $__require('@angular/common');
var TextExpander = (function() {
function TextExpander() {
this.expanded = false;
this.ellipsis = true;
this.text = null;
this.characters = 50;
this.words = 0;
this.expandText = "show more";
this.shrinkText = "show less";
this.expandedChange = new core_1.EventEmitter();
}
TextExpander.prototype.toggleExpand = function() {
this.expanded = !this.expanded;
this.expandedChange.next(this.expanded);
};
TextExpander.prototype.amountOfCharacters = function() {
if (this.words > 0)
return this.getCharactersUpToNumberOfWords(this.words);
return this.characters;
};
TextExpander.prototype.getCharactersUpToNumberOfWords = function(words) {
var textCopy = this.text;
textCopy = textCopy.replace(/(^\s*)|(\s*$)/gi, "");
textCopy = textCopy.replace(/[ ]{2,}/gi, " ");
textCopy = textCopy.replace(/\n /, "\n");
var wordsArr = textCopy.split(' ');
if (words >= wordsArr.length - 1)
return this.text.length;
wordsArr = wordsArr.splice(0, words);
var lastWordToShow = wordsArr[wordsArr.length - 1];
var occurencesOfLastWord = wordsArr.filter(function(str) {
return str === lastWordToShow;
}).length;
if (occurencesOfLastWord == 1)
return this.text.split(lastWordToShow)[0].length + lastWordToShow.length;
var charactersUntilLastWord = 0;
for (var i = 0; i < occurencesOfLastWord; i++) {
charactersUntilLastWord += this.text.split(lastWordToShow)[i].length;
}
return charactersUntilLastWord + lastWordToShow.length;
};
__decorate([core_1.Input(), __metadata('design:type', Boolean)], TextExpander.prototype, "expanded", void 0);
__decorate([core_1.Input(), __metadata('design:type', Boolean)], TextExpander.prototype, "ellipsis", void 0);
__decorate([core_1.Input(), __metadata('design:type', String)], TextExpander.prototype, "text", void 0);
__decorate([core_1.Input(), __metadata('design:type', Number)], TextExpander.prototype, "characters", void 0);
__decorate([core_1.Input(), __metadata('design:type', Number)], TextExpander.prototype, "words", void 0);
__decorate([core_1.Input(), __metadata('design:type', String)], TextExpander.prototype, "expandText", void 0);
__decorate([core_1.Input(), __metadata('design:type', String)], TextExpander.prototype, "shrinkText", void 0);
__decorate([core_1.Output(), __metadata('design:type', Object)], TextExpander.prototype, "expandedChange", void 0);
TextExpander = __decorate([core_1.Component({
selector: 'text-expander',
template: "\n <span *ngIf=\"text\">\n {{text | slice : 0 : (expanded ? text.length : amountOfCharacters())}}\n <span *ngIf=\"!expanded && text.length > amountOfCharacters()\">\n <span *ngIf=\"ellipsis\">&hellip;</span>\n <a href=\"javascript:void(8);\" (click)=\"toggleExpand()\">\n {{expandText}}\n </a>\n </span>\n <span *ngIf=\"expanded && text.length > amountOfCharacters()\">\n <a href=\"javascript:void(8);\" (click)=\"toggleExpand()\">\n {{shrinkText}}\n </a>\n </span>\n </span>\n ",
directives: [common_1.CORE_DIRECTIVES],
pipes: [common_1.SlicePipe]
}), __metadata('design:paramtypes', [])], TextExpander);
return TextExpander;
}());
exports.TextExpander = TextExpander;
exports.TEXTEXPANDER_PROVIDERS = [TextExpander];
return module.exports;
});

System.registerDynamic("fuel-ui/dist/components/Accordion/Accordion", ["@angular/core"], true, function($__require, exports, module) {
"use strict";
;
Expand Down Expand Up @@ -3681,7 +3767,7 @@ System.registerDynamic("fuel-ui/dist/components/Tag/TagSet", ["@angular/core", "
return module.exports;
});

System.registerDynamic("fuel-ui/dist/components/components", ["./Accordion/AccordionItem", "./Alert/Alert", "./Carousel/Carousel", "./DatePicker/DatePickerProviders", "./Modal/Modal", "./Pagination/Pagination", "./InfiniteScroller/InfiniteScroller", "./Dropdown/Dropdown", "./Tab/Tab", "./Tag/Tag", "./TableSortable/TableSortable", "./Slider/Slider", "./TimePicker/TimePicker", "./Accordion/Accordion", "./Tab/TabSet", "./TableSortable/TableSortableColumn", "./TableSortable/TableSortableSorting", "./Tag/TagSet"], true, function($__require, exports, module) {
System.registerDynamic("fuel-ui/dist/components/components", ["./Accordion/AccordionItem", "./Alert/Alert", "./Carousel/Carousel", "./DatePicker/DatePickerProviders", "./Modal/Modal", "./Pagination/Pagination", "./InfiniteScroller/InfiniteScroller", "./Dropdown/Dropdown", "./Tab/Tab", "./Tag/Tag", "./TableSortable/TableSortable", "./Slider/Slider", "./TimePicker/TimePicker", "./TextExpander/TextExpander", "./Accordion/Accordion", "./Tab/TabSet", "./TableSortable/TableSortableColumn", "./TableSortable/TableSortableSorting", "./Tag/TagSet"], true, function($__require, exports, module) {
"use strict";
;
var define,
Expand All @@ -3705,7 +3791,8 @@ System.registerDynamic("fuel-ui/dist/components/components", ["./Accordion/Accor
var TableSortable_1 = $__require('./TableSortable/TableSortable');
var Slider_1 = $__require('./Slider/Slider');
var TimePicker_1 = $__require('./TimePicker/TimePicker');
exports.FUELUI_COMPONENT_PROVIDERS = [AccordionItem_1.ACCORDION_PROVIDERS, Alert_1.ALERT_PROVIDERS, Carousel_1.CAROUSEL_PROVIDERS, DatePickerProviders_1.DATE_PICKER_PROVIDERS, Modal_1.MODAL_PROVIDERS, Pagination_1.PAGINATION_PROVIDERS, InfiniteScroller_1.INFINITE_SCROLLER_PROVIDERS, Dropdown_1.DROPDOWN_COMPONENT_PROVIDERS, TableSortable_1.TABLESORTABLE_PROVIDERS, Slider_1.SLIDER_COMPONENT_PROVIDERS, Tab_1.TAB_PROVIDERS, Tag_1.TAG_PROVIDERS, TimePicker_1.TIMEPICKER_PROVIDERS];
var TextExpander_1 = $__require('./TextExpander/TextExpander');
exports.FUELUI_COMPONENT_PROVIDERS = [AccordionItem_1.ACCORDION_PROVIDERS, Alert_1.ALERT_PROVIDERS, Carousel_1.CAROUSEL_PROVIDERS, DatePickerProviders_1.DATE_PICKER_PROVIDERS, Modal_1.MODAL_PROVIDERS, Pagination_1.PAGINATION_PROVIDERS, InfiniteScroller_1.INFINITE_SCROLLER_PROVIDERS, Dropdown_1.DROPDOWN_COMPONENT_PROVIDERS, TableSortable_1.TABLESORTABLE_PROVIDERS, Slider_1.SLIDER_COMPONENT_PROVIDERS, Tab_1.TAB_PROVIDERS, Tag_1.TAG_PROVIDERS, TextExpander_1.TEXTEXPANDER_PROVIDERS, TimePicker_1.TIMEPICKER_PROVIDERS];
__export($__require('./Accordion/Accordion'));
__export($__require('./Accordion/AccordionItem'));
__export($__require('./Alert/Alert'));
Expand All @@ -3724,6 +3811,7 @@ System.registerDynamic("fuel-ui/dist/components/components", ["./Accordion/Accor
__export($__require('./Tag/TagSet'));
__export($__require('./Slider/Slider'));
__export($__require('./TimePicker/TimePicker'));
__export($__require('./TextExpander/TextExpander'));
return module.exports;
});

Expand Down
6 changes: 3 additions & 3 deletions bundles/fuel-ui.min.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fuel-ui",
"version": "0.3.2",
"version": "0.3.3",
"description": "A set of utilities and Angular2 components implementing Twitter's Bootstrap 4 components",
"main": "fuel-ui.js",
"typings": "fuel-ui.d.ts",
Expand Down Expand Up @@ -42,9 +42,9 @@
"path": "^0.12.7",
"prismjs": "^1.4.1",
"run-sequence": "^1.1.5",
"systemjs-builder": "^0.15.15",
"typescript": "^1.8.10",
"typings": "^1.0.4",
"systemjs-builder": "^0.15.20",
"typescript": "^1.9.0-dev.20160615-1.0",
"typings": "^1.0.5",
"vinyl-buffer": "^1.0.0",
"vinyl-paths": "^2.1.0",
"vinyl-source-stream": "^1.1.0"
Expand All @@ -56,7 +56,7 @@
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router": "3.0.0-alpha.3",
"bootstrap": "^4.0.0-alpha.2",
"font-awesome": "^4.6.1",
"rxjs": "5.0.0-beta.6",
Expand All @@ -69,15 +69,15 @@
"@angular/http": "2.0.0-rc.1",
"@angular/platform-browser": "2.0.0-rc.1",
"@angular/platform-browser-dynamic": "2.0.0-rc.1",
"@angular/router": "2.0.0-rc.1",
"@angular/router": "3.0.0-alpha.3",
"bootstrap": "^4.0.0-alpha.2",
"core-js": "^2.2.1",
"es6-shim": "^0.35.0",
"es6-shim": "^0.35.1",
"font-awesome": "^4.6.1",
"hammerjs": "^2.0.8",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"systemjs": "^0.19.25",
"systemjs": "^0.19.30",
"zone.js": "0.6.12"
}
}
2 changes: 2 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ Then simply add the proper script tags to your `index.html`
- [TableSortable](https://github.com/FuelInteractive/fuel-ui/tree/master/src/components/TableSortable#readme)
- [Tabs](https://github.com/FuelInteractive/fuel-ui/tree/master/src/components/Tab#readme)
- [Tags](https://github.com/FuelInteractive/fuel-ui/tree/master/src/components/Tag#readme)
- [TextExpander](https://github.com/FuelInteractive/fuel-ui/tree/master/src/components/TextExpander#readme)
- [TimePicker](https://github.com/FuelInteractive/fuel-ui/tree/master/src/components/TimePicker#readme)

##Directives
- [Animation (helper)](https://github.com/FuelInteractive/fuel-ui/tree/master/src/directives/Animation#readme)
Expand Down
176 changes: 176 additions & 0 deletions src/components/TextExpander/TextExpander.Demo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
import {Component} from '@angular/core';
import {TEXTEXPANDER_PROVIDERS} from './TextExpander';
import {CodeHighlighter} from '../../directives/CodeHighlighter/CodeHighlighter';
import {TableSortable, TableSortableColumn, TableSortableSorting} from '../../components/TableSortable/TableSortable';
import {Event, EventColumns, EventsDefaultSort, Attribute, AttributeColumns, AttributesDefaultSort} from '../../utilities/demoUtilities';
import {TAB_PROVIDERS} from '../../components/Tab/Tab';

@Component({
template: `
<div class="row">
<div class="col-md-12">
<div class="card card-block">
<h2 class="card-title">TextExpander</h2>
<p class="card-text">TextExpander is a custom component to display a text expander number list</p>
</div>
</div>
</div>
<section class="row m-a">
<div class="col-md-8">
<form>
<div class="form-group row">
<label for="text" class="col-sm-2 form-control-label">Text</label>
<div class="col-sm-12">
<input class="form-control" [(ngModel)]="text" type="text" name="text">
</div>
</div>
<div class="form-group row">
<label for="characters" class="col-sm-2 form-control-label">Characters</label>
<div class="col-sm-2">
<input class="form-control" [(ngModel)]="characters" min="1" type="number" name="characters">
</div>
</div>
<div class="form-group row">
<label for="words" class="col-sm-2 form-control-label">Words</label>
<div class="col-sm-2">
<input class="form-control" [(ngModel)]="words" min="0" type="number" name="words">
</div>
<small class="text-muted">Expander defaults to number of characters when set to 0.</small>
</div>
<div class="form-group row">
<label for="expandText" class="col-sm-2 form-control-label">Expand Text</label>
<div class="col-sm-6">
<input class="form-control" [(ngModel)]="expandText" type="text" name="expandText">
</div>
</div>
<div class="form-group row">
<label for="expandText" class="col-sm-2 form-control-label">Shrink Text</label>
<div class="col-sm-6">
<input class="form-control" [(ngModel)]="shrinkText" type="text" name="shrinkText">
</div>
</div>
<div class="row">
<div class="checkbox col-md-3">
<label for="expanded" class="form-control-label">
<input [(ngModel)]="expanded" type="checkbox" />
Expanded
</label>
</div>
</div>
<div class="row">
<div class="checkbox col-md-3">
<label for="ellipsis" class="form-control-label">
<input [(ngModel)]="ellipsis" type="checkbox" />
Ellipsis
</label>
</div>
</div>
</form>
<text-expander
[(expanded)]="expanded"
[ellipsis]="ellipsis"
[text]="text"
[characters]="characters"
[words]="words"
[expandText]="expandText"
[shrinkText]="shrinkText">
</text-expander>
</div>
</section>
<div class="source">
<h3>Import</h3>
<pre>
<code class="language-javascript" code-highlight>
import {TextExpander} from 'fuel-ui/fuel-ui';
</code>
</pre>
<h3>Getting Started</h3>
<p>TextExpander is a custom element to show an interactive list of page numbers to use for paging</p>
<h3>Usage</h3>
<tabset>
<tab heading="HTML">
<pre>
<code class="language-markup" code-highlight>
&lt;text-expander
[(expanded)]=&quot;expanded&quot;
[ellipsis]=&quot;ellipsis&quot;
[text]=&quot;text&quot;
[words]=&quot;words&quot;
[characters]=&quot;characters&quot;
[expandText]=&quot;expandText&quot;
[shrinkText]=&quot;shrinkText&quot;&gt;
&lt;/text-expander&gt;
</code>
</pre>
</tab>
<tab heading="TypeScript">
<pre>
<code class="language-javascript" code-highlight>
export class TextExpanderExample {
expanded: boolean = false;
ellipsis: boolean = true;
text: string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sed " +
"massa sed odio gravida iaculis. Sed elementum dapibus neque, sit.";
characters: number = 50;
words: number = 0;
expandText: string = "Show more";
shrinkText: string = "Show less";
}
</code>
</pre>
</tab>
</tabset>
<h3>Attributes</h3>
<table-sortable
[columns]="attributesColumns"
[data]="attributes"
[sort]="attributesSort">
Loading table...
</table-sortable>
<h3>Events</h3>
<table-sortable
[columns]="eventsColumns"
[data]="events"
[sort]="eventsSort">
Loading table...
</table-sortable>
</div>`,
directives: [TEXTEXPANDER_PROVIDERS, CodeHighlighter, TableSortable, TAB_PROVIDERS]
})
export class TextExpanderDemo {
expanded: boolean = false;
ellipsis: boolean = true;
text: string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum sed massa sed odio gravida iaculis. Sed elementum dapibus neque, sit.";
characters: number = 50;
words: number = 0;
expandText: string = "Show more";
shrinkText: string = "Show less";

attributes:Attribute[] = [
new Attribute('expanded', 'boolean', 'false', 'The current state of whether or not the complete text is displayed'),
new Attribute('ellipsis', 'boolean', 'true', 'Add "..." at the end of the text when not expanded'),
new Attribute('text', 'string', 'null', 'The text that can be expanded/shrunk'),
new Attribute('characters', 'number', '50', 'The number of characters displayed when text is shrunk'),
new Attribute('words', 'number', '0', 'The number of words displayed when text is shrunk. If set to 0, characters are defaulted to'),
new Attribute('expandText', 'string', 'show more', 'Clickable text used to expand text'),
new Attribute('shrinkText', 'string', 'show less', 'Clickable text used to shrink text')
];
attributesColumns:TableSortableColumn[] = AttributeColumns;
attributesSort:TableSortableSorting = AttributesDefaultSort;
events:Event[] = [
new Event('expandedChange', '$event = expanded: boolean', 'New state of whether the text is expanded or not')
];
eventsColumns:TableSortableColumn[] = EventColumns;
eventsSort:TableSortableSorting = EventsDefaultSort;
}

export var TEXTEXPANDER_DEMO_PROVIDERS = [
TextExpanderDemo
];
14 changes: 14 additions & 0 deletions src/components/TextExpander/TextExpander.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<span *ngIf="text">
{{text | slice : 0 : (expanded ? text.length : amountOfCharacters())}}
<span *ngIf="!expanded && text.length > amountOfCharacters()">
<span *ngIf="ellipsis">&hellip;</span>
<a href="javascript:void(8);" (click)="toggleExpand()">
{{expandText}}
</a>
</span>
<span *ngIf="expanded && text.length > amountOfCharacters()">
<a href="javascript:void(8);" (click)="toggleExpand()">
{{shrinkText}}
</a>
</span>
</span>
Loading

0 comments on commit 65a74dd

Please sign in to comment.