aboutsummaryrefslogtreecommitdiffstats
path: root/view
diff options
context:
space:
mode:
Diffstat (limited to 'view')
-rw-r--r--view/css/conversation.css6
-rw-r--r--view/js/autocomplete.js120
-rw-r--r--view/js/main.js2
-rwxr-xr-xview/tpl/jot-header.tpl1
-rwxr-xr-xview/tpl/login.tpl2
-rwxr-xr-xview/tpl/nav.tpl50
6 files changed, 178 insertions, 3 deletions
diff --git a/view/css/conversation.css b/view/css/conversation.css
index 39c973c14..304e0f196 100644
--- a/view/css/conversation.css
+++ b/view/css/conversation.css
@@ -296,3 +296,9 @@ a.wall-item-name-link {
.event-label {
font-weight: bold;
}
+
+/* bb-code */
+
+.overline {
+ text-decoration: overline;
+}
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 437425a0e..0ba291004 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -100,6 +100,66 @@ function submit_form(e) {
$(e).parents('form').submit();
}
+function getWord(text, caretPos) {
+ var index = text.indexOf(caretPos);
+ var postText = text.substring(caretPos, caretPos+8);
+ if ((postText.indexOf("[/list]") > 0) || postText.indexOf("[/ul]") > 0 || postText.indexOf("[/ol]") > 0) {
+ return postText;
+ }
+}
+
+function getCaretPosition(ctrl) {
+ var CaretPos = 0; // IE Support
+ if (document.selection) {
+ ctrl.focus();
+ var Sel = document.selection.createRange();
+ Sel.moveStart('character', -ctrl.value.length);
+ CaretPos = Sel.text.length;
+ }
+ // Firefox support
+ else if (ctrl.selectionStart || ctrl.selectionStart == '0')
+ CaretPos = ctrl.selectionStart;
+ return (CaretPos);
+}
+
+function setCaretPosition(ctrl, pos){
+ if(ctrl.setSelectionRange) {
+ ctrl.focus();
+ ctrl.setSelectionRange(pos,pos);
+ }
+ else if (ctrl.createTextRange) {
+ var range = ctrl.createTextRange();
+ range.collapse(true);
+ range.moveEnd('character', pos);
+ range.moveStart('character', pos);
+ range.select();
+ }
+}
+
+function listNewLineAutocomplete(id) {
+ var text = document.getElementById(id);
+ var caretPos = getCaretPosition(text)
+ var word = getWord(text.value, caretPos);
+ if (word != null) {
+ var textBefore = text.value.substring(0, caretPos);
+ var textAfter = text.value.substring(caretPos, text.length);
+ $('#' + id).val(textBefore + '\r\n[*] ' + textAfter);
+ setCaretPosition(text, caretPos + 5);
+ return true;
+ }
+}
+
+function string2bb(element) {
+ if(element == 'bold') return 'b';
+ else if(element == 'italic') return 'i';
+ else if(element == 'underline') return 'u';
+ else if(element == 'overline') return 'o';
+ else if(element == 'strike') return 's';
+ else if(element == 'superscript') return 'sup';
+ else if(element == 'subscript') return 'sub';
+ else return element;
+}
+
/**
* jQuery plugin 'editor_autocomplete'
*/
@@ -197,3 +257,63 @@ function submit_form(e) {
a.on('textComplete:select', function(e, value, strategy) { onselect(value); });
};
})( jQuery );
+
+(function( $ ) {
+ $.fn.bbco_autocomplete = function(type) {
+
+ if(type=='bbcode') {
+ var open_close_elements = ['bold', 'italic', 'underline', 'overline', 'strike', 'superscript', 'subscript', 'quote', 'code', 'spoiler', 'map', 'nobb', 'list', 'ul', 'ol', 'li', 'table', 'tr', 'th', 'td', 'center', 'color', 'font', 'size', 'zrl', 'zmg', 'rpost', 'qr', 'observer'];
+ var open_elements = ['observer.baseurl', 'observer.address', 'observer.photo', 'observer.name', 'observer.webname', 'observer.url', '*', 'hr', ];
+
+ var elements = open_close_elements.concat(open_elements);
+ }
+
+ if(type=='comanche') {
+ var open_close_elements = ['region', 'widget', 'var', 'template', 'css', 'js'];
+ var open_elements = [];
+
+ var elements = open_close_elements.concat(open_elements);
+ }
+
+ bbco = {
+ match: /\[(\w*\**)$/,
+ search: function (term, callback) {
+ callback($.map(elements, function (element) {
+ return element.indexOf(term) === 0 ? element : null;
+ }));
+ },
+ index: 1,
+ replace: function (element) {
+ element = string2bb(element);
+ if(open_elements.indexOf(element) < 0) {
+ if(element === 'list' || element === 'ol' || element === 'ul') {
+ return ['\[' + element + '\]' + '\n\[*\] ', '\n\[/' + element + '\]'];
+ }
+ else if(element === 'table') {
+ return ['\[' + element + '\]' + '\n\[tr\]', '\[/tr\]\n\[/' + element + '\]'];
+ }
+ else {
+ return ['\[' + element + '\]', '\[/' + element + '\]'];
+ }
+ }
+ else {
+ return '\[' + element + '\] ';
+ }
+ }
+ };
+
+ this.attr('autocomplete','off');
+ var a = this.textcomplete([bbco], {className:'acpopup', zIndex:1020});
+
+ a.on('textComplete:select', function(e, value, strategy) { value; });
+
+ $(this).keypress(function(e){
+ if (e.keyCode == 13) {
+ x = listNewLineAutocomplete(this.id);
+ if(x)
+ e.preventDefault();
+ }
+ });
+ };
+})( jQuery );
+
diff --git a/view/js/main.js b/view/js/main.js
index 04b317914..ba476b576 100644
--- a/view/js/main.js
+++ b/view/js/main.js
@@ -617,6 +617,8 @@ function updateConvItems(mode,data) {
/* autocomplete @nicknames */
$(".comment-edit-form textarea").editor_autocomplete(baseurl+"/acl?f=&n=1");
+ /* autocomplete bbcode */
+ $(".comment-edit-form textarea").bbco_autocomplete('bbcode');
var bimgs = ((preloadImages) ? false : $(".wall-item-body img").not(function() { return this.complete; }));
var bimgcount = bimgs.length;
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl
index 84fccc105..2b62f2407 100755
--- a/view/tpl/jot-header.tpl
+++ b/view/tpl/jot-header.tpl
@@ -11,6 +11,7 @@ function initEditor(cb){
if(plaintext == 'none') {
$("#profile-jot-text-loading").spin(false).hide();
$("#profile-jot-text").css({ 'height': 200, 'color': '#000' });
+ $("#profile-jot-text").bbco_autocomplete('bbcode'); // autocomplete bbcode
if(typeof channelId === 'undefined')
$("#profile-jot-text").editor_autocomplete(baseurl+"/acl");
else
diff --git a/view/tpl/login.tpl b/view/tpl/login.tpl
index da38f3571..d56c8f272 100755
--- a/view/tpl/login.tpl
+++ b/view/tpl/login.tpl
@@ -5,7 +5,7 @@
<div id="login-input" class="form-group">
{{include file="field_input.tpl" field=$lname}}
{{include file="field_password.tpl" field=$lpassword}}
- {{include file="field_checkbox.tpl" field=$remember}}
+ {{include file="field_checkbox.tpl" field=$remember_me}}
<button type="submit" name="submit" class="btn btn-block btn-primary">{{$login}}</button>
</div>
<div id="login-extra-links">
diff --git a/view/tpl/nav.tpl b/view/tpl/nav.tpl
index 3d6809c22..886f73947 100755
--- a/view/tpl/nav.tpl
+++ b/view/tpl/nav.tpl
@@ -1,4 +1,45 @@
- <div class="container-fluid">
+<script>
+ $(document).mouseup(function (e)
+ {
+ var container = $("#help-content");
+
+ if (!container.is(e.target) // if the target of the click isn't the container...
+ && container.has(e.target).length === 0 // ... nor a descendant of the container
+ && container.hasClass('help-content-open'))
+ {
+ container.removeClass('help-content-open');
+ }
+ });
+</script>
+<style>
+.help-content {
+ background: rgba(255, 255, 255, 0.9);
+ color: #333333;
+ position: fixed;
+ top: 50px;
+ left: -80%;
+ width: 80%;
+ height: 60%;
+ padding: 20px;
+ transition: left 300ms cubic-bezier(0.17, 0.04, 0.03, 0.94);
+ box-sizing: border-box;
+ border: #CCC thin solid;
+ overflow: auto;
+}
+
+.help-content-open {
+ left: 0px;
+ -moz-box-shadow: 3px 3px 3px #ccc;
+ -webkit-box-shadow: 3px 3px 3px #ccc;
+ box-shadow: 3px 3px 3px #ccc;
+}
+
+.help-content dd {
+ margin-bottom: 1em;
+}
+</style>
+
+<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
<span class="icon-bar"></span>
@@ -189,8 +230,13 @@
{{if $nav.help}}
<li class="{{$sel.help}}">
- <a class="{{$nav.help.2}}" target="hubzilla-help" href="{{$nav.help.0}}" title="{{$nav.help.3}}" id="{{$nav.help.4}}"><i class="icon-question"></i></a>
+ <a class="{{$nav.help.2}}" target="hubzilla-help" href="{{$nav.help.0}}" title="{{$nav.help.3}}" id="{{$nav.help.4}}" onclick="$('#help-content').toggleClass('help-content-open'); return false;"><i class="icon-question"></i></a>
</li>
+
+ <div id="help-content" class="help-content">
+ {{$nav.help.5}}
+ <p class="pull-right"><a href="{{$nav.help.0}}">Click here for more documentation...</a></p>
+ </div>
{{/if}}
</ul>
</div>