]> git.mxchange.org Git - friendica.git/commitdiff
theme-settings: background image can be set with fbrowser
authorrabuzarus <>
Mon, 9 May 2016 21:30:09 +0000 (23:30 +0200)
committerrabuzarus <>
Mon, 9 May 2016 21:30:09 +0000 (23:30 +0200)
js/filebrowser.js
js/modal.js
templates/field_fileinput.tpl [new file with mode: 0644]
templates/theme_settings.tpl

index 648090677cd68af753a0302fa3ea94c3db75eceb..58d050a743a871dbf3c1cfefef5dfde7851a5fdd 100644 (file)
@@ -135,6 +135,7 @@ var FileBrowser = {
                                this.dataset.filename,\r
                                embed,\r
                                FileBrowser.id,\r
+                               this.dataset.img\r
                        ]);\r
 \r
                        // close model\r
index a296c9ba9cfa8a5e8524aa84748daf81eed1b61b..8868e06407228cab6ecd4c25e67242b5a19e476e 100644 (file)
@@ -48,6 +48,27 @@ $(document).ready(function(){
                e.preventDefault();
                toggleJotNav(this);
        });
+
+       // Open filebrowser for elements with the class "image-select"
+       // The following part handles the filebrowser for field_fileinput.tpl
+       $("body").on("click", ".image-select", function(e){
+               // set a extra attribute to mark the clicked button
+               this.setAttribute("image-input", "select");
+               Dialog.doImageBrowser("input");
+       });
+
+       // Insert filebrowser images into the input field (field_fileinput.tpl)
+       $("body").on("fbrowser.image.input", function(e, filename, embedcode, id, img) {
+               // select the clicked button by it's attribute
+               var elm = $("[image-input='select']")
+               // select the input field which belongs to this button
+               var input = elm.parent(".input-group").children("input");
+               // remove the special indicator attribut from the button
+               elm.removeAttr("image-input");
+               // inserte the link from the image into the input field
+               input.val(img);
+               
+       });
 });
 
 // overwrite Dialog.show from main js to load the filebrowser into a bs modal
diff --git a/templates/field_fileinput.tpl b/templates/field_fileinput.tpl
new file mode 100644 (file)
index 0000000..ebaa769
--- /dev/null
@@ -0,0 +1,10 @@
+
+<div class="form-group field input file">
+       <label for="id_{{$field.0}}" id="label_{{$field.0}}">{{$field.1}}</label>
+       <div class="input-group" id="{{$field.0}}">
+               <input class="form-control file" name="{{$field.0}}" id="id_{{$field.0}}" type="text" value="{{$field.2}}">{{if $field.4}} <span class="required">{{$field.4}}</span> {{/if}}
+               <span class="input-group-addon image-select"><i class="fa fa-picture-o"></i></span>
+       </div>
+       <span id="help_{{$field.0}}" class="help-block">{{$field.3}}</span>
+       <div id="end_{{$field.0}}" class="field_end"></div>
+</div>
index 55a2b33ee112121b9dfa683d5c2780c613815ecc..ebedfcfb5749a9083e01c8ca4c6e5d100502c0d7 100644 (file)
@@ -1,6 +1,8 @@
+
 <link rel="stylesheet" href="{{$baseurl}}/view/theme/frio/frameworks/jRange/jquery.range.css" type="text/css" media="screen" />
 <script src="{{$baseurl}}/view/theme/quattro/jquery.tools.min.js"></script>
 <script src="{{$baseurl}}/view/theme/frio/frameworks/jRange/jquery.range.js"></script>
+<script type="text/javascript" src="{{$baseurl}}/js/ajaxupload.js" ></script>
 
 {{include file="field_select.tpl" field=$schema}}
 
@@ -20,7 +22,7 @@
 </div>
 {{/if}}
 
-{{if $background_image}}{{include file="field_colorinput.tpl" field=$background_image}}{{/if}}
+{{if $background_image}}{{include file="field_fileinput.tpl" field=$background_image}}{{/if}}
 
 <div id="frio_bg_image_options" style="display: none;">
 {{foreach $bg_image_options as $options}}