/*
Copyright 2017 Ziadin Givan
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
https://github.com/givanz/VvvebJs
*/
Vvveb.ComponentsGroup['Widgets'] = ["widgets/googlemaps", "widgets/video", "widgets/chartjs", "widgets/facebookpage", "widgets/paypal", "widgets/instagram", "widgets/twitter"/*, "widgets/facebookcomments"*/];
Vvveb.Components.extend("_base", "widgets/googlemaps", {
name: "Google Maps",
attributes: ["data-component-maps"],
image: "icons/map.svg",
dragHtml: '',
html: '
',
resizable:true,//show select box resize handlers
resizeMode:"css",
//url parameters
z:3, //zoom
q:'Paris',//location
t: 'q', //map type q = roadmap, w = satellite
onChange: function (node, property, value)
{
map_iframe = jQuery('iframe', node);
this[property.key] = value;
mapurl = 'https://maps.google.com/maps?&q=' + this.q + '&z=' + this.z + '&t=' + this.t + '&output=embed';
map_iframe.attr("src",mapurl);
return node;
},
properties: [{
name: "Address",
key: "q",
inputtype: TextInput
},
{
name: "Map type",
key: "t",
inputtype: SelectInput,
data:{
options: [{
value: "q",
text: "Roadmap"
}, {
value: "w",
text: "Satellite"
}]
},
},
{
name: "Zoom",
key: "z",
inputtype: RangeInput,
data:{
max: 20, //max zoom level
min:1,
step:1
},
}]
});
Vvveb.Components.extend("_base", "widgets/video", {
name: "Video",
attributes: ["data-component-video"],
image: "icons/video.svg",
dragHtml: '', //use image for drag and swap with iframe on drop for drag performance
html: '',
//url parameters set with onChange
t:'y',//video type
video_id:'',//video id
url: '', //html5 video src
autoplay: false,
controls: false,
loop: false,
init: function (node)
{
iframe = jQuery('iframe', node);
video = jQuery('video', node);
$("#right-panel [data-key=url]").hide();
//check if html5
if (video.length)
{
this.url = video.src;
} else if (iframe.length) //vimeo or youtube
{
src = iframe.attr("src");
if (src && src.indexOf("youtube"))//youtube
{
this.video_id = src.match(/youtube.com\/embed\/([^$\?]*)/)[1];
} else if (src && src.indexOf("vimeo"))//youtube
{
this.video_id = src.match(/vimeo.com\/video\/([^$\?]*)/)[1];
}
}
$("#right-panel input[name=video_id]").val(this.video_id);
$("#right-panel input[name=url]").val(this.url);
},
onChange: function (node, property, value)
{
this[property.key] = value;
//if (property.key == "t")
{
switch (this.t)
{
case 'y':
$("#right-panel [data-key=video_id]").show();
$("#right-panel [data-key=url]").hide();
newnode = $(`