You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
5.9 KiB

6 years ago
<section>
<style>
.pre-code {
font-size: 12px;
line-height: 1.2;
}
</style>
<div bs-panel-content>
<p>
<state-button state="ctrl.state.adding" on="Close" off="Add Rewrite Rule" ng-click="ctrl.showInputs()"></state-button>
<button ng-show="ctrl.previousRules" ng-click="ctrl.restorePreviousRules()" bs-button="subtle-alt size-small icon-left">
<icon icon="repeat"></icon>
Restore {{ctrl.previousRules.length}}
</button>
</p>
<div ng-show="ctrl.state.adding">
<form name="rewriteForm">
<div bs-heading-bar>
<label for="rewrite-match" bs-input-label>Match</label>
<div bs-button-group>
<button bs-button="size-small subtle-alt" ng-disabled="ctrl.isMatchType('string')" ng-click="ctrl.setMatchType('string')">String</button>
<button bs-button="size-small subtle-alt" ng-click="ctrl.setMatchType('regex')" ng-disabled="ctrl.isMatchType('regex')">Regex</button>
</div>
</div>
<div bs-heading-bar ng-show="ctrl.isMatchType('regex')">
<label for="rewrite-match" bs-input-label>Flags</label>
<div bs-button-group>
<div bs-input="text">
<input type="text" placeholder="eg: gi" ng-model="ctrl.inputs.match.flags"/>
</div>
</div>
</div>
<div bs-textarea-input>
<span bs-tag bs-error="offset" ng-show="ctrl.isMatchType('regex') && !rewriteForm['rewriteMatch'].$valid">Invalid <span>Regex</span></span>
<span bs-tag bs-error="offset" ng-show="ctrl.errors.length">{{ctrl.errors[0].message}}</span>
<textarea
id="rewrite-match"
cols="30"
rows="5"
bs-code-input
name="rewriteMatch"
ng-model="ctrl.inputs.match.value"
valid-regex="ctrl.inputs.match.type"
flags="ctrl.inputs.match.flags"
ng-required="1"
ng-minlength="1"
placeholder="Eg: 'skin/core.css'"></textarea>
<br/>
</div>
<div bs-heading-bar>
<label for="rewrite-replace" bs-input-label>Replace</label>
<div bs-button-group>
<button bs-button="size-small subtle-alt" ng-disabled="ctrl.isReplaceType('string')" ng-click="ctrl.setReplaceType('string')">
String
</button>
<button bs-button="size-small subtle-alt" ng-click="ctrl.setReplaceType('function')" ng-disabled="ctrl.isReplaceType('function')">
Function
</button>
</div>
</div>
<div bs-textarea-input>
<span bs-tag bs-error="offset" ng-show="ctrl.isReplaceType('function') && !rewriteForm['replace-input'].$valid">Invalid <span>Function</span><span>Body</span></span>
<textarea
id="rewrite-replace"
cols="30"
rows="5"
name="replace-input"
bs-code-input
ng-model="ctrl.inputs.replace.value"
valid-fn="ctrl.inputs.replace.type"
placeholder="Eg: 'skin/core.css' or return '/assets' + arguments[0];"></textarea>
<br/>
</div>
<div ng-class="[ctrl.state.classname]" bs-state-wrapper>
<div bs-button-group>
<button id="save-rule" bs-button="size-small subtle-alt icon-left" ng-click="ctrl.saveRule()"
ng-disabled="ctrl.state.waiting || rewriteForm.$invalid || ctrl.errors.length">
<svg bs-svg-icon><use xlink:href="#svg-circle-ok"></use></svg>
Save
</button>
<button id="save-rule2" bs-button="size-small subtle-alt icon-left" ng-click="ctrl.saveRule('reload')"
ng-disabled="ctrl.state.waiting || rewriteForm.$invalid || ctrl.errors.length">
<svg bs-svg-icon><use xlink:href="#svg-circle-ok"></use></svg>
Save & Reload
</button>
</div>
<div bs-state-icons>
<icon icon="circle-ok" bs-state="success inline"></icon>
<icon icon="circle-minus" bs-state="waiting inline" bs-anim="spin"></icon>
</div>
</div>
</form>
</div>
</div>
<!-- -------------------------- -->
<!-- Display each existing rule -->
<!-- -------------------------- -->
<div bs-panel-content ng-show="ctrl.rules.length">
<rewrite-rule ng-repeat="(key, rule) in ctrl.rules track by rule.id" rule="rule" index="$index" edit-rule="ctrl.editRule(rule)"></rewrite-rule>
<p style="margin-top: 20px">
<button bs-button="size-small subtle-alt" type="button" ng-click="ctrl.exportRules()">
{{ctrl.exports.length ? 'Close' : 'Export Rules' }}
</button>
</p>
<div ng-show="ctrl.exports.length">
<p>The following can be used in your Browsersync configuration</p>
<pre class="pre-code">rewriteRules: {{ctrl.exports|json}}</pre>
</div>
</div>
</section>