Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
Recent Tutorials
Top posting users this month
Top Achievers
Who is online?
In total there are 54 users online :: 0 Registered, 0 Hidden and 54 Guests :: 2 Bots
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
GIFActif - Giphy Button for the Editor
Page 2 of 3 • Share
Page 2 of 3 • 1, 2, 3
First topic message reminder :
What is GIFActif ? GIFActif is a Giphy search plugin for the free forum service, Forumotion aka Forumactif. GIFActif adds a new button to the message editor that gives your members the ability to search for GIFS and attach them to their messages without ever leaving the page ! Why express yourself with just words alone when you can add a GIF to your message to liven things up ?
How does it work ?
Where do the GIFs come from ?
All GIFs are retrieved from Giphy.com by using the Giphy Search API to find GIFs just for you !
Note : Since this project is open source, it'll be using the public beta key provided by Giphy, which is subject to rate limit constraints.
Feel free to move onto the installation if you're ready to get giphy with it !
Title : GIFActif
Placement : In all the pages
Paste the following script and submit :
NOTE:
For this application to work properly, you must replace API_KEY with your API key.
To get your own personal API key, go to https://developers.giphy.com/dashboard/?create=true and create a giphy account if you do not already have one. Once you've done that, click create an app and name it whatever you like and submit it. Afterwards you should be given an API key. Simply replace API_KEY in the script with your new API key.
Modifications
If you want to make any modifications to this plugin, please click the spoiler below to reveal the instructions.
Once you've installed the script and you're finished making modifications, the Giphy button should now be available in your editor !! Click the button to do searches and exchange some awesome GIFs with everyone !
If you have any comments, questions, or problems, feel free to leave a reply below. Enjoy !
Thanks to baivong, you can also install an additional plugin which displays Giphy's GIFs like Facebook ; the GIFs will remain static until you click on them !
To install this additional plugin, go to Admin Panel > Modules > JavaScript codes management and create a new script with the following settings.
Title : GIFActif Player
Placement : In all the pages
Paste the script below and submit :
When you're finished, save the script and the Giphy GIFs should now display like Facebook !
What is GIFActif ? GIFActif is a Giphy search plugin for the free forum service, Forumotion aka Forumactif. GIFActif adds a new button to the message editor that gives your members the ability to search for GIFS and attach them to their messages without ever leaving the page ! Why express yourself with just words alone when you can add a GIF to your message to liven things up ?
Click to view demo |
How does it work ?
- GIFActif adds a new button to the editor with the Giphy logo -->
- Clicking the button opens the Giphy search drop down.
- Type any words you want into the search bar and you'll immediately be presented with GIFs relevant to your keywords.
- Scrolling to the end of the results will load more results.
- Click the GIF you want to add to your message and you're done !
- Open the drop down again to find more GIFs !!
Where do the GIFs come from ?
All GIFs are retrieved from Giphy.com by using the Giphy Search API to find GIFs just for you !
Note : Since this project is open source, it'll be using the public beta key provided by Giphy, which is subject to rate limit constraints.
Feel free to move onto the installation if you're ready to get giphy with it !
Installation
To install the Giphy search button, go to Admin Panel > Modules > JavaScript codes management and create a new JavaScript with the following settings.Title : GIFActif
Placement : In all the pages
Paste the following script and submit :
- Code:
(function() {
// return if gifactif has been initialized
if (window.gifactif) {
if (window.console && console.warn) {
console.warn('gifactif has already been initialized');
}
return;
}
// setup global object
window.gifactif = {
key : 'API_KEY', // authorization
limit : 26, // max image results
delay : 200, // delay before searches commence (200ms)
auto_close : true,
// general language settings
lang : {
searching : 'Searching...',
not_found : 'No results found.. <img src="https://2img.net/i/fa/i/smiles/icon_sad.gif" style="margin:0;vertical-align:middle;"/>'
},
// dropdown markup
dropDown : $(
'<div>'+
'<input type="text" id="gifactif_search" placeholder="Search for a GIF..." style="width:90%;"/>'+
'<div id="gifactif_results" onscroll="gifactif.scrolling(this);"><div id="gifactif_images"></div></div>'+
'<div id="giphy_attribution_mark"></div>'+
'</div>'
)[0],
// initial setup of the SCEditor command
init : function () {
if ($.sceditor && window.toolbar) {
// set the gifactif command
$.sceditor.command.set('gifactif', {
tooltip : 'Find a GIF',
// Dropdown and general functionality for gifactif
dropDown : function (editor, caller, callback) {
gifactif.reset();
gifactif.editor = editor;
gifactif.callback = callback;
editor.createDropDown(caller, 'gifactif', gifactif.dropDown);
$('#gifactif_search', gifactif.dropDown)[0].focus(); // focus the search area
},
// WYSIWYG MODE
exec : function(caller) {
var editor = this;
$.sceditor.command.get('gifactif').dropDown(editor, caller, function(gif) {
editor.insert('[img]' + gif + '[/img]');
});
},
// SOURCE MODE
txtExec : function(caller) {
var editor = this;
$.sceditor.command.get('gifactif').dropDown(editor, caller, function(gif) {
editor.insertText('[img]' + gif + '[/img]');
});
}
});
// add gifactif to the editor toolbar
toolbar = toolbar.replace('image,', 'image,gifactif,');
// add CSS for button image and dropdown
$('head').append(
'<style type="text/css">'+
'.sceditor-button-gifactif div { background-image:url(https://i.servimg.com/u/f35/18/21/60/73/giphy10.png) !important; }'+
'.sceditor-button-gifactif:after, .sceditor-button-gifactif:before { content:""; }'+ // Forumactif Edge override
'#gifactif_results { width:300px; margin:10px auto; min-height:30px; max-height:300px; overflow-x:hidden; overflow-y:auto; }'+
'.gifactif_imagelist { line-height:0; column-count:2; column-gap:3px; }'+
'.gifactif_imagelist img { margin-bottom:3px; cursor:pointer; width:100%; }'+
'html #giphy_attribution_mark { background:url(https://i.servimg.com/u/f35/18/21/60/73/powere11.png) no-repeat 50% 50% transparent !important; height:22px !important; width:100%; !important; min-width:200px !important; display:block !important; visibility:visible !important; opacity:1 !important; }'+
'</style>'
);
}
},
// search for a GIPHY gif
search : function (query) {
if (gifactif.timeout) {
gifactif.abort(); // abort ongoing searches and requests
}
if (query) {
// set a small timeout in case the user is still typing
gifactif.timeout = window.setTimeout(function() {
gifactif.reset(true, gifactif.lang.searching);
gifactif.query = encodeURIComponent(query);
gifactif.request = $.get('http://api.giphy.com/v1/gifs/search?q=' + gifactif.query + '&limit=' + gifactif.limit + '&rating=pg-13&api_key=' + gifactif.key, function(data) {
// update global data such as page offsets for scrolling
gifactif.request = null;
gifactif.offset = data.pagination.offset + gifactif.limit;
gifactif.offset_total = data.pagination.total_count;
gifactif.reset(true); // reset HTML content
gifactif.addGIF(data); // send data to be parsed
});
}, gifactif.delay);
} else {
gifactif.reset(true);
}
},
// abort ongoing searches and requests
abort : function () {
if (gifactif.timeout) {
window.clearInterval(gifactif.timeout);
gifactif.timeout = null;
}
if (gifactif.request) {
gifactif.request.abort();
gifactif.request = null;
}
},
// add gifs to the result list
addGIF : function (data, loadMore) {
// setup data and begin parsing results
var gif = data.data,
i = 0,
j = gif.length,
list = $('<div class="gifactif_imagelist" />')[0];
if (j) {
for (; i < j; i++) {
list.appendChild($('<img id="' + gif[i].id + '" src="' + gif[i].images.fixed_width.url + '" />').click(gifactif.insert)[0]);
}
} else if (!loadMore) {
gifactif.reset(true, gifactif.lang.not_found);
}
// add results to the result list
$('#gifactif_results', gifactif.dropDown).append(list);
},
// listen to the scrolling so we can add more gifs when the user reaches the bottom
scrolling : function (that) {
if (that.scrollHeight - that.scrollTop === that.clientHeight) {
gifactif.loadMore();
}
},
// load more results once the user has scrolled through the last results
loadMore : function () {
if (gifactif.offset < gifactif.offset_total) {
gifactif.request = $.get('http://api.giphy.com/v1/gifs/search?q=' + gifactif.query + '&offset=' + gifactif.offset + '&limit=' + gifactif.limit + '&rating=pg-13&api_key=' + gifactif.key, function(data) {
gifactif.request = null;
gifactif.offset = data.pagination.offset + gifactif.limit;
gifactif.offset_total = data.pagination.total_count;
gifactif.addGIF(data, true); // send data to be parsed
});
}
},
// inserts the gif into the editor
insert : function () {
// add the gif to the editor and close the dropdown
gifactif.callback('http://media0.giphy.com/media/' + this.id + '/giphy.gif');
if (gifactif.auto_close) {
gifactif.editor.closeDropDown(true);
gifactif.reset();
}
},
// reset the dropdown fields
reset : function (resultsOnly, newContent) {
$('#gifactif_results', gifactif.dropDown).html(newContent ? newContent : '');
if (!resultsOnly) {
$('#gifactif_search', gifactif.dropDown).val('');
}
}
};
// bind keyup event to search input
$('#gifactif_search', gifactif.dropDown)[0].onkeyup = function(e) {
var k = e.keyCode;
// ignore specific key inputs to prevent unnecessary requests
if (k && (k == 16 || k == 17 || k == 18 || k == 20 || k == 37 || k == 38 || k == 39 || k == 40)) {
return;
} else {
gifactif.search(this.value);
}
};
// initilize gifactif
$(gifactif.init);
}());
NOTE:
For this application to work properly, you must replace API_KEY with your API key.
To get your own personal API key, go to https://developers.giphy.com/dashboard/?create=true and create a giphy account if you do not already have one. Once you've done that, click create an app and name it whatever you like and submit it. Afterwards you should be given an API key. Simply replace API_KEY in the script with your new API key.
Modifications
If you want to make any modifications to this plugin, please click the spoiler below to reveal the instructions.
- Click to view modifications:
- 1. limit
The limit variable determines the maximum amount of GIFs that are loaded into the search results at a time. By default, 26 GIFs are loaded into the results when you search or scroll to the end of the results. Increment or decrement this value to show more or less results at a time.- Code:
limit : 26, // max image results
2. delay
The delay variable defines a small delay before the search results are submitted to Giphy. This helps reduce the frequency of requests while you're still typing. By default, the delay is 200ms, if you want it to be longer or shorter, simply modify the value of this variable.- Code:
delay : 200, // delay before searches commence (200ms)
3. auto_close
The auto_close variable allows you to choose if the Giphy search drop down closes once you choose an image. By default the drop down closes when you've chosen a GIF. If you want the drop down to remain open after picking a GIF simply change the value of this option to false !- Code:
auto_close : true, // choose if the drop down automatically closes
4. language
If you want to change the general language of this plugin simply find and edit the lang object and dropDown element :- Code:
// general language settings
lang : {
searching : 'Searching...',
not_found : 'No results found.. <img src="https://2img.net/i/fa/i/smiles/icon_sad.gif" style="margin:0;vertical-align:middle;"/>'
},
// dropdown markup
dropDown : $(
'<div>'+
'<input type="text" id="gifactif_search" placeholder="Search for a GIF..." style="width:90%;"/>'+
'<div id="gifactif_results" onscroll="gifactif.scrolling(this);"><div id="gifactif_images"></div></div>'+
'<div id="giphy_attribution_mark"></div>'+
'</div>'
)[0],
5. key
The key variable is for the API key provided by Giphy to everyone -- it's necessary for submitting searches for the vast awesomeness that Giphy offers. You shouldn't need to edit this variable.
Once you've installed the script and you're finished making modifications, the Giphy button should now be available in your editor !! Click the button to do searches and exchange some awesome GIFs with everyone !
If you have any comments, questions, or problems, feel free to leave a reply below. Enjoy !
Extra - Display Giphy GIFs like Facebook
Thanks to baivong, you can also install an additional plugin which displays Giphy's GIFs like Facebook ; the GIFs will remain static until you click on them !
Click to view demo |
To install this additional plugin, go to Admin Panel > Modules > JavaScript codes management and create a new script with the following settings.
Title : GIFActif Player
Placement : In all the pages
Paste the script below and submit :
- Code:
// Demo: https://jsfiddle.net/baivong/a4z0hz63/embedded/result,html,js/
jQuery(function() {
'use strict';
// Giphy image in post
var $giphyImg = $('.postbody, .post-entry').find('img[src*=".giphy.com/media/"][src$="giphy.gif"]');
if (!$giphyImg.length) return;
// Add style to player like Facebook
$('head').append($('<style/>', {
text: '.gifactif_icon_bg,.gifactif_icon_load,.gifactif_icon_text{background-image:url(//i.imgur.com/VvrpCQJ.png);background-repeat:no-repeat;background-size:auto;left:50%;top:50%;cursor:pointer}.gifactif_wrap{position:relative;display:inline-block}.gifactif_icon_bg{background-position:0 0;height:72px;margin-left:-36px;margin-top:-36px;position:absolute;width:72px}.gifactif_icon_load{background-position:0 -73px;height:66px;margin-left:-33px;margin-top:-33px;position:absolute;width:66px}.rotate-spinner{-webkit-animation:rotateSpinner 2.5s linear infinite;animation:rotateSpinner 2.5s linear infinite}.gifactif_icon_text{background-position:0 -140px;height:17px;margin-left:-16px;margin-top:-9px;position:absolute;width:32px}.gifactif_external{display:block;background:url(//i.imgur.com/1yqUihp.png) repeat-x;bottom:0;color:#fff;font-size:11px;-webkit-font-smoothing:antialiased;font-weight:700;height:56px;left:0;position:absolute;right:0;text-align:left;text-shadow:0 1px 4px rgba(0,0,0,.4);text-transform:uppercase;white-space:nowrap}.gifactif_external_text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;bottom:9px;left:11px;max-width:400px;position:absolute;vertical-align:top;color:#fff}.gifactif_external_icon{width:24px;height:24px;background-image:url(//i.imgur.com/VvrpCQJ.png);background-size:auto;background-repeat:no-repeat;display:inline-block;background-position:0 -158px;bottom:9px;position:absolute;right:10px}.gifactif_player,.gifactif_poster{max-width:100%}.gifactif_cover{display:block}.gifactif_player,.gifactif_video .gifactif_cover{display:none}.gifactif_video .gifactif_player{display:block}@-webkit-keyframes rotateSpinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotateSpinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}'
}));
// Replace GIF image to player like Facebook
$giphyImg.replaceWith(function() {
var imgUrl = this.src,
pre = imgUrl.replace(/\.gif$/, '');
return '<div class="gifactif_wrap" data-pre="' + pre + '" data-id="' + pre.match(/\/media\/([^\/]+)\/giphy/)[1] + '"><img class="gifactif_cover gifactif_poster" src="' + pre + '_s.gif" alt=""><div class="gifactif_cover gifactif_icon"><div class="gifactif_icon_bg"></div><div class="gifactif_icon_load"></div><div class="gifactif_icon_text"></div></div><a class="gifactif_cover gifactif_external" href="' + pre + '_s.gif" target="_blank"><div class="gifactif_external_text">giphy.com</div><i class="gifactif_external_icon"></i></a></div>';
});
// Click on player
$('.gifactif_wrap').on('click', function(e) {
var $this = $(this),
$cover = $this.find('.gifactif_cover'),
$video = $this.find('.gifactif_player'),
$poster = $this.find('.gifactif_poster'),
$loader = $this.find('.gifactif_icon_load'),
pre = $this.data('pre');
// Skip external url
if (e.target.className === 'gifactif_cover gifactif_external') return;
if (e.target.tagName !== 'VIDEO') {
if (!$video.length) {
// Generate video player
$video = $('<video/>', {
class: 'gifactif_player',
poster: pre + '_s.gif',
loop: 'loop',
muted: 'muted',
width: $poster.width(),
height: $poster.height(),
html: '<source src="' + pre + '.mp4" type="video/mp4"><source src="' + pre + '.webm" type="video/webm">Your browser does not support HTML5 video.'
});
$this.append($video);
// Loading effect
$loader.addClass('rotate-spinner');
$video.on('canplay canplaythrough', function() {
$loader.removeClass('rotate-spinner'); // Disable loading effect
$this.addClass('gifactif_video'); // Hide image, show video
$video.trigger('play');
});
$video.on('click', function() {
$this.removeClass('gifactif_video'); // Show image, hide video
$video.trigger('pause');
});
// Get real source url
$.get('http://api.giphy.com/v1/gifs/' + $this.data('id') + '?api_key=' + (window.gifactif ? window.gifactif.key : 'dc6zaTOxFJmzC')).done(function(res) {
if (res.meta.status !== 200) return;
$this.find('.gifactif_external').attr('href', (res.data.source_post_url || res.data.url));
$this.find('.gifactif_external_text').text(res.data.source_tld || 'giphy.com');
});
} else {
$this.addClass('gifactif_video');
}
$video.get(0).currentTime = 0; // Play video from the start
$video.trigger('play');
}
});
});
When you're finished, save the script and the Giphy GIFs should now display like Facebook !
Notice |
Tutorial written by Ange Tuteur. Special thanks to baivong for the Giphy player and to the Beta Testers for testing this plugin. Reproduction not permitted without consent from the author. |
Last edited by Ange Tuteur on Wed 08 May 2019, 11:32; edited 1 time in total
hope this dose not bother you
using
$var this = $(this),
lead to this
ReferenceError: invalid assignment left-hand side
using
var this = $(this),
leads to
SyntaxError: missing variable name
again
same with var this = (this),
more details about
my head is aching lolwhich means it contains another dollar sign.
this is funny
i replaced the word this with ange
in the whole Script so i might avoid what you just said
due i got the same error
the error changed to
SyntaxError: expected expression, got ')'
changing (ange,) to _ange, give
SyntaxError: expected expression, got '.'
i think ill be dead body in a few mins
ill try i think tomorrow a lot of pain and smoke coming out off my head
i replaced the word this with ange
in the whole Script so i might avoid what you just said
after trying to use _this"this" is a keyword in javascript so it cannot be used as a variable name. Try changing it's name to "_this" without the quotes.
due i got the same error
the error changed to
SyntaxError: expected expression, got ')'
changing (ange,) to _ange, give
SyntaxError: expected expression, got '.'
i think ill be dead body in a few mins
ill try i think tomorrow a lot of pain and smoke coming out off my head
@Michael_vx give this a try :
- Code:
// Demo: https://jsfiddle.net/baivong/a4z0hz63/embedded/result,html,js/
jQuery(function() {
'use strict';
// Giphy image in post
var giphyImg = $('.post_body, .post-entry').find('img[src*=".giphy.com/media/"][src$="giphy.gif"]');
if (!giphyImg.length) return;
// Add style to player like Facebook
$('head').append($('<style/>', {
text: '.gifactif_icon_bg,.gifactif_icon_load,.gifactif_icon_text{background-image:url(//i.imgur.com/VvrpCQJ.png);background-repeat:no-repeat;background-size:auto;left:50%;top:50%;cursor:pointer}.gifactif_wrap{position:relative;display:inline-block}.gifactif_icon_bg{background-position:0 0;height:72px;margin-left:-36px;margin-top:-36px;position:absolute;width:72px}.gifactif_icon_load{background-position:0 -73px;height:66px;margin-left:-33px;margin-top:-33px;position:absolute;width:66px}.rotate-spinner{-webkit-animation:rotateSpinner 2.5s linear infinite;animation:rotateSpinner 2.5s linear infinite}.gifactif_icon_text{background-position:0 -140px;height:17px;margin-left:-16px;margin-top:-9px;position:absolute;width:32px}.gifactif_external{display:block;background:url(//i.imgur.com/1yqUihp.png) repeat-x;bottom:0;color:#fff;font-size:11px;-webkit-font-smoothing:antialiased;font-weight:700;height:56px;left:0;position:absolute;right:0;text-align:left;text-shadow:0 1px 4px rgba(0,0,0,.4);text-transform:uppercase;white-space:nowrap}.gifactif_external_text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;bottom:9px;left:11px;max-width:400px;position:absolute;vertical-align:top;color:#fff}.gifactif_external_icon{width:24px;height:24px;background-image:url(//i.imgur.com/VvrpCQJ.png);background-size:auto;background-repeat:no-repeat;display:inline-block;background-position:0 -158px;bottom:9px;position:absolute;right:10px}.gifactif_player,.gifactif_poster{max-width:100%}.gifactif_cover{display:block}.gifactif_player,.gifactif_video .gifactif_cover{display:none}.gifactif_video .gifactif_player{display:block}@-webkit-keyframes rotateSpinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotateSpinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}'
}));
// Replace GIF image to player like Facebook
giphyImg.replaceWith(function() {
var imgUrl = this.src,
pre = imgUrl.replace(/\.gif$/, '');
return '<div class="gifactif_wrap" data-pre="' + pre + '" data-id="' + pre.match(/\/media\/([^\/]+)\/giphy/)[1] + '"><img class="gifactif_cover gifactif_poster" src="' + pre + '_s.gif" alt=""><div class="gifactif_cover gifactif_icon"><div class="gifactif_icon_bg"></div><div class="gifactif_icon_load"></div><div class="gifactif_icon_text"></div></div><a class="gifactif_cover gifactif_external" href="' + pre + '_s.gif" target="_blank"><div class="gifactif_external_text">giphy.com</div><i class="gifactif_external_icon"></i></a></div>';
});
// Click on player
$('.gifactif_wrap').on('click', function(e) {
var _this = $(this),
_cover = _this.find('.gifactif_cover'),
_video = _this.find('.gifactif_player'),
_poster = _this.find('.gifactif_poster'),
_loader = _this.find('.gifactif_icon_load'),
pre = _this.data('pre');
// Skip external url
if (e.target.className === 'gifactif_cover gifactif_external') return;
if (e.target.tagName !== 'VIDEO') {
if (!_video.length) {
// Generate video player
_video = $('<video/>', {
class: 'gifactif_player',
poster: pre + '_s.gif',
loop: 'loop',
muted: 'muted',
width: _poster.width(),
height: _poster.height(),
html: '<source src="' + pre + '.mp4" type="video/mp4"><source src="' + pre + '.webm" type="video/webm">Your browser does not support HTML5 video.'
});
_this.append(_video);
// Loading effect
_loader.addClass('rotate-spinner');
_video.on('canplay canplaythrough', function() {
_loader.removeClass('rotate-spinner'); // Disable loading effect
_this.addClass('gifactif_video'); // Hide image, show video
_video.trigger('play');
});
_video.on('click', function() {
_this.removeClass('gifactif_video'); // Show image, hide video
_video.trigger('pause');
});
// Get real source url
$.get('http://api.giphy.com/v1/gifs/' + _this.data('id') + '?api_key=' + (window.gifactif ? window.gifactif.key : 'dc6zaTOxFJmzC')).done(function(res) {
if (res.meta.status !== 200) return;
_this.find('.gifactif_external').attr('href', (res.data.source_post_url || res.data.url));
_this.find('.gifactif_external_text').text(res.data.source_tld || 'giphy.com');
});
} else {
_this.addClass('gifactif_video');
}
_video.get(0).currentTime = 0; // Play video from the start
_video.trigger('play');
}
});
});
Ange Tuteur wrote:@Michael_vx give this a try :
- Code:
// Demo: https://jsfiddle.net/baivong/a4z0hz63/embedded/result,html,js/
jQuery(function() {
'use strict';
// Giphy image in post
var giphyImg = $('.post_body, .post-entry').find('img[src*=".giphy.com/media/"][src$="giphy.gif"]');
if (!giphyImg.length) return;
// Add style to player like Facebook
$('head').append($('<style/>', {
text: '.gifactif_icon_bg,.gifactif_icon_load,.gifactif_icon_text{background-image:url(//i.imgur.com/VvrpCQJ.png);background-repeat:no-repeat;background-size:auto;left:50%;top:50%;cursor:pointer}.gifactif_wrap{position:relative;display:inline-block}.gifactif_icon_bg{background-position:0 0;height:72px;margin-left:-36px;margin-top:-36px;position:absolute;width:72px}.gifactif_icon_load{background-position:0 -73px;height:66px;margin-left:-33px;margin-top:-33px;position:absolute;width:66px}.rotate-spinner{-webkit-animation:rotateSpinner 2.5s linear infinite;animation:rotateSpinner 2.5s linear infinite}.gifactif_icon_text{background-position:0 -140px;height:17px;margin-left:-16px;margin-top:-9px;position:absolute;width:32px}.gifactif_external{display:block;background:url(//i.imgur.com/1yqUihp.png) repeat-x;bottom:0;color:#fff;font-size:11px;-webkit-font-smoothing:antialiased;font-weight:700;height:56px;left:0;position:absolute;right:0;text-align:left;text-shadow:0 1px 4px rgba(0,0,0,.4);text-transform:uppercase;white-space:nowrap}.gifactif_external_text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;bottom:9px;left:11px;max-width:400px;position:absolute;vertical-align:top;color:#fff}.gifactif_external_icon{width:24px;height:24px;background-image:url(//i.imgur.com/VvrpCQJ.png);background-size:auto;background-repeat:no-repeat;display:inline-block;background-position:0 -158px;bottom:9px;position:absolute;right:10px}.gifactif_player,.gifactif_poster{max-width:100%}.gifactif_cover{display:block}.gifactif_player,.gifactif_video .gifactif_cover{display:none}.gifactif_video .gifactif_player{display:block}@-webkit-keyframes rotateSpinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}@keyframes rotateSpinner{0%{-webkit-transform:rotate(0);transform:rotate(0)}100%{-webkit-transform:rotate(360deg);transform:rotate(360deg)}}'
}));
// Replace GIF image to player like Facebook
giphyImg.replaceWith(function() {
var imgUrl = this.src,
pre = imgUrl.replace(/\.gif$/, '');
return '<div class="gifactif_wrap" data-pre="' + pre + '" data-id="' + pre.match(/\/media\/([^\/]+)\/giphy/)[1] + '"><img class="gifactif_cover gifactif_poster" src="' + pre + '_s.gif" alt=""><div class="gifactif_cover gifactif_icon"><div class="gifactif_icon_bg"></div><div class="gifactif_icon_load"></div><div class="gifactif_icon_text"></div></div><a class="gifactif_cover gifactif_external" href="' + pre + '_s.gif" target="_blank"><div class="gifactif_external_text">giphy.com</div><i class="gifactif_external_icon"></i></a></div>';
});
// Click on player
$('.gifactif_wrap').on('click', function(e) {
var _this = $(this),
_cover = _this.find('.gifactif_cover'),
_video = _this.find('.gifactif_player'),
_poster = _this.find('.gifactif_poster'),
_loader = _this.find('.gifactif_icon_load'),
pre = _this.data('pre');
// Skip external url
if (e.target.className === 'gifactif_cover gifactif_external') return;
if (e.target.tagName !== 'VIDEO') {
if (!_video.length) {
// Generate video player
_video = $('<video/>', {
class: 'gifactif_player',
poster: pre + '_s.gif',
loop: 'loop',
muted: 'muted',
width: _poster.width(),
height: _poster.height(),
html: '<source src="' + pre + '.mp4" type="video/mp4"><source src="' + pre + '.webm" type="video/webm">Your browser does not support HTML5 video.'
});
_this.append(_video);
// Loading effect
_loader.addClass('rotate-spinner');
_video.on('canplay canplaythrough', function() {
_loader.removeClass('rotate-spinner'); // Disable loading effect
_this.addClass('gifactif_video'); // Hide image, show video
_video.trigger('play');
});
_video.on('click', function() {
_this.removeClass('gifactif_video'); // Show image, hide video
_video.trigger('pause');
});
// Get real source url
$.get('http://api.giphy.com/v1/gifs/' + _this.data('id') + '?api_key=' + (window.gifactif ? window.gifactif.key : 'dc6zaTOxFJmzC')).done(function(res) {
if (res.meta.status !== 200) return;
_this.find('.gifactif_external').attr('href', (res.data.source_post_url || res.data.url));
_this.find('.gifactif_external_text').text(res.data.source_tld || 'giphy.com');
});
} else {
_this.addClass('gifactif_video');
}
_video.get(0).currentTime = 0; // Play video from the start
_video.trigger('play');
}
});
});
my god
im full of mistakes i have never thinked about replacing $ with _
also i mistake moved the , inside (and) to make a problem at (this,) part
i should buy some coffe to foces on Script coding
now its full working
filling 100 page of thank you words is not Enough to say thank you
Master of Scripts
@Michael_vx you're welcome. ^^
I should've converted the script for you sooner, but I wasn't thinking clearly because I was lacking coffee.
I should've converted the script for you sooner, but I wasn't thinking clearly because I was lacking coffee.
im not feeling good today
there was a customer with Plasma TV tried for 3 hours to find the fault but i failed Plasma TVs are not possible to be fixed
about the Editor ID of mine
im not sure which one i should use so here they are
there was a customer with Plasma TV tried for 3 hours to find the fault but i failed Plasma TVs are not possible to be fixed
about the Editor ID of mine
im not sure which one i should use so here they are
- Code:
id="message"
class="sceditor-container rtl">
MyBBEditor = $("#message").sceditor("instance");
thats make the buttons gone
also getting error
ReferenceError: my_getcookie is not defined
its refer to
color: my_getcookie("defColCP") ? my_getcookie("defColCP") : "#000000",
im not sure if that the right changes
- Code:
$(function() {
$(function() {
$(".sceditor-button-color").hide()
})
});
$(function() {
$("div.post_body").each(function() {
var n = this;
if ($(".post-entry", n).length) {
n = $(".post-entry", n)[0]
} else {
if ($(".content", n).length) {
n = $(".content", n)[0]
}
}
while (n.nodeType != 3 && n.hasChildNodes()) {
n = n.childNodes[0]
}
if (n.nodeType != 3) {
return val
}
if (n.nodeValue.substr(0, 8) != "[postbg=") {
return val
}
var m = n.nodeValue.match(/^\[postbg=([^\[]*)\]/);
$(this).closest("div.post-container,div.post,td.row1,td.row2,div.postmain").addClass("postbg").css("background-image", "url(" + m[1] + ")");
n.nodeValue = n.nodeValue.replace(/^\[postbg=[^\[]*\]\n?/, "");
if (!n.nodeValue && n.nextSibling.nodeType == 1 && n.nextSibling.tagName == "BR") {
$(n.nextSibling).remove()
}
});
if ($("#message").length && $.sceditor) {
var bglist = "http://i55.servimg.com/u/f55/14/83/59/48/daqtda10.gif,http://i55.servimg.com/u/f55/14/83/59/48/pftcnq10.png,http://i55.servimg.com/u/f55/14/83/59/48/lruwov10.png,http://i55.servimg.com/u/f55/14/83/59/48/ehp45h10.png,http://i39.servimg.com/u/f39/14/83/59/48/bg1310.jpg,http://i39.servimg.com/u/f39/14/83/59/48/rip_jo10.png".split(",");
var bgnum = -1;
var val = $("#message").val();
if (val.substr(0, 8) == "[postbg=") {
var m = val.match(/^\[postbg=([^\[]*)\]/);
if (m) {
var r = $.inArray(m[1], bglist);
if (r != -1) {
bgnum = r
} else {
bgnum = bglist.length - 1
}
$(function() {
$(".sceditor-container").css("background-position", "0 " + ($(".sceditor-toolbar").height() + 6) + "px");
$(".sceditor-container").css("background-image", "url(" + m[1] + ")")
});
$("#message").val(val.replace(/^\[postbg=[^\[]*\]/, ""))
}
}
$(function() {
if (!$("#message").sceditor("instance")) {
return
}
$('<a class="sceditor-button" unselectable="on" title="إختر خلفية الموضوع/المشاركة"><div unselectable="on" style="background:url(http://i39.servimg.com/u/f39/14/83/59/48/catego10.png);opacity:1">خلفية المشاركة</div></a>').insertAfter(".sceditor-button-faspoiler").click(function(e) {
if (e.ctrlKey) {
$(".sceditor-container").css("background-image", "");
bgnum = -1
} else {
bgnum++;
if (!bgnum) {
$(".sceditor-container").css("background-position", "0 " + ($(".sceditor-toolbar").height() + 6) + "px")
}
$(".sceditor-container").css("background-image", "url(" + bglist[bgnum % bglist.length] + ")")
}
})
});
$(function() {
$('form[name="post"]').submit(function() {
if (bgnum != -1) {
$("#message").val(function(i, val) {
return "[postbg=" + bglist[bgnum % bglist.length] + "]" + val
})
}
})
})
}
});
$(function() {
$(function() {
$('.sceditor-button-image').after('<a title="إدراج صورة برابط" class="sceditor-button sceditor-button-imganc"><div style="background:url(http://i39.servimg.com/u/f39/18/21/41/30/imganc10.png);"></div></a>');
$('.sceditor-button-imganc').click(function() {
if ($('.sceditor-insertimganc').length) return $('.sceditor-insertimganc').remove();
$('body').append('<div class="sceditor-dropdown sceditor-insertimganc" style="position:absolute;"><div><label>رابط الصورة</label> <input id="imganc-img" class="url" placeholder="http://" type="text"></div><div><label>رابط التوجيه</label> <input id="imganc-url" class="url" placeholder="http://" type="text"></div><div><label>عرض (حقل اختياري)</label> <input id="imganc-width" size="2" type="text"></div><div><label>ارتفاع (حقل اختياري)</label> <input id="imganc-height" size="2" type="text"></div><div><input id="submit-imganc" class="button" value="إدراج" type="button"></div></div>');
$('.sceditor-insertimganc').css({
'left': $('.sceditor-button-imganc').offset().left + 'px',
'top': $('.sceditor-button-imganc').offset().top + 25 + 'px'
});
$('#submit-imganc').click(function() {
var dimension = '',
width = $('#imganc-width').val(),
height = $('#imganc-height').val(),
image = $('#imganc-img').val(),
url = $('#imganc-url').val();
if (width.length > 0 && height.length > 0) dimension = '(' + width + 'px,' + height + 'px)';
else if (width.length > 0 && height.length < 1) dimension = '(' + width + 'px,' + width + 'px)';
else if (width.length < 1 && height.length > 0) dimension = '(' + height + 'px,' + height + 'px)';
if (image.length > 0 && url.length > 0) $('#message').sceditor('instance').insertText('[url=' + url + '][img' + dimension + ']' + image, '[/img][/url]');
$('.sceditor-insertimganc').remove();
return false
})
});
$('.sceditor-button-source').click(function() {
$('.sceditor-button-imganc').removeClass('disabled')
});
$('.sceditor-button').not('.sceditor-button-imganc').click(function() {
$('.sceditor-insertimganc').remove()
});
$('.sceditor-container textarea').focus(function() {
$('.sceditor-insertimganc').remove()
});
$('.sceditor-container i-frame').contents().mousedown(function() {
$('.sceditor-insertimganc').remove()
})
})
});
$(document).on('ready', function() {
$(".sceditor-container").append('<div class="sceditor-dropdown sceditor-tooltip"style="display:none;margin-top: 27px;"><div><label for="tooltipnote"style="text-align:right;font-size: 16px;">الخلفية</label><input type="text" id="tooltipnote" style = "float:left;text-align: left;" placeholder="//:http"><br /><label for="tooltiptext"style="text-align:right;font-size: 16px;">عرض (حقل اختياري)</label><input type="text" id="tooltiptext" style = "height: 17px;width: 33px;margin: 1px 1px -5px 132px;" placeholder=""><br /><input type="button"style="margin: 22px -3px 1px 110px;"class="button"value="إدراج"></div></div>');
$('<a class= "sceditor-button sceditor-button-paletaavanzada" unselectable="on" title= "إدراج خلفية الموضوع/المشاركة"><div style="background-image:url(http://i39.servimg.com/u/f39/14/83/59/48/block-10.png)">BBCode Tooltip</div></a>').insertAfter('.sceditor-button-faspoiler').click(function() {
var f = $(".sceditor-tooltip").css("display");
if (f == 'none') {
$(".sceditor-tooltip").css({
"left": $(this).position().left,
"top": $(this).position().top,
}).show()
} else {
$(".sceditor-tooltip").hide()
}
});
$(".sceditor-tooltip .button").click(function() {
var a = $(".sceditor-tooltip #tooltiptext").val();
var b = $(".sceditor-tooltip #tooltipnote").val();
$('#message').sceditor("instance").insert('[table style="width:' + a + 'px; height:300px; background: url(' + b + ');" align="center" background="' + b + '"][tr][td][/td][/tr][/table]')
});
$('.post').each(function() {
var m = $(this).html().replace(/\[tooltip=(.*?)\](.*?)\[\/tooltip]/gi, '<span class="tooltip"><datatip>$1</datatip><texttip>*$2</texttip></span>');
$(this).html(m)
});
$('.post ').find('.tooltip').each(function() {
var s = $(this);
$(s).hover(function() {
$(s).find('datatip').show()
}, function() {
$(s).find('datatip').hide()
})
})
});
$(document).on('ready', function() {
$(".sceditor-container").append('<div class="sceditor-dropdown sceditor-tooltip1"style="display:none;margin-top: 27px;"><div><label for="tooltipnote"style="text-align:right;font-size: 16px;">رابط</label><input type="text" id="tooltipnote" style = "float:left;text-align: left;" placeholder="//:http"><br /><input type="button"style="margin: 1px -3px 1px 78px;"class="button"value="إدراج"></div></div>');
$('<a class= "sceditor-button sceditor-button-paletaavanzada" unselectable="on" title= "إدراج رابط فيديو من أى موقع "><div style="background-image:url(http://i39.servimg.com/u/f39/14/83/59/48/movie-10.png)">BBCode Tooltip</div></a>').insertAfter('.sceditor-button-link').click(function() {
var f = $(".sceditor-tooltip1").css("display");
if (f == 'none') {
$(".sceditor-tooltip1").css({
"left": $(this).position().left,
"top": $(this).position().top,
}).show()
} else {
$(".sceditor-tooltip1").hide()
}
});
$(".sceditor-tooltip1 .button").click(function() {
var c = $(".sceditor-tooltip1 #tooltiptext").val();
var d = $(".sceditor-tooltip1 #tooltipnote").val();
$('#message').sceditor("instance").insert('<embed src=' + d + ' width=' + 500 + ' height=' + 300 + '></embed>')
});
$('.post').each(function() {
var m = $(this).html().replace(/\[tooltip=(.*?)\](.*?)\[\/tooltip]/gi, '<span class="tooltip"><datatip>$1</datatip><texttip>*$2</texttip></span>');
$(this).html(m)
});
$('.post ').find('.tooltip').each(function() {
var s = $(this);
$(s).hover(function() {
$(s).find('datatip').show()
}, function() {
$(s).find('datatip').hide()
})
})
});
$(document).on('ready', function() {
$(".sceditor-container").append('<div class="sceditor-dropdown sceditor-tooltip2" style="display:none;margin-top: 27px;"><div><label for="tooltiptext" style="text-align:right;font-size: 16px;" >رابط المقطع الصوتي</label><input type="text" id="tooltiptext" style = "float:left;text-align: left;" placeholder="//:http"><br /><input type="button" style = "margin: 1px -3px 1px 78px;"class="button" value="إدراج"></div></div>');
$('<a class= "sceditor-button sceditor-button-paletaavanzada2" unselectable="on" title= "إدراج مقطع صوتي "><div style="background-image:url(http://i39.servimg.com/u/f39/14/83/59/48/sound-10.png)">BBCode Tooltip</div></a>').insertAfter('.sceditor-button-link').click(function() {
var f = $(".sceditor-tooltip2").css("display");
if (f == 'none') {
$(".sceditor-tooltip2").css({
"left": $(this).position().left,
"top": $(this).position().top,
}).show()
} else {
$(".sceditor-tooltip2").hide()
}
});
$(".sceditor-tooltip2 .button").click(function() {
var e = $(".sceditor-tooltip2 #tooltiptext").val();
var f = $(".sceditor-tooltip2 #tooltipnote").val();
$('#message').sceditor("instance").insert('<object id="audioplayer_1" data="http://althkr.com/templates/swf/player3.swf" style="outline: none" name="audioplayer_1" type="application/x-shockwave-flash" height="24" width="100%"><param value="#FFFFFF" name="bgcolor"><param value="transparent" name="wmode"><param value="false" name="menu"><param value="' + e + '" name="flashvars"></object>')
});
$('.post').each(function() {
var m = $(this).html().replace(/\[tooltip=(.*?)\](.*?)\[\/tooltip]/gi, '<span class="tooltip"><datatip>$1</datatip><texttip>*$2</texttip></span>');
$(this).html(m)
});
$('.post ').find('.tooltip').each(function() {
var s = $(this);
$(s).hover(function() {
$(s).find('datatip').show()
}, function() {
$(s).find('datatip').hide()
})
})
});
$(document).on('ready', function() {
$('<a class= "sceditor-button bbcode-classic" title= "إسم العضو"><div style="background-image:url(http://i57.servimg.com/u/f57/11/54/61/22/im_mes10.png)">Success Note</div></a>').insertAfter('.sceditor-button-date').click(function() {
$('#message').sceditor('instance').insert('{USERNAME}');
return false
});
$('<a class="sceditor-button bbcode-tip" title="نص مشع"><div style="background-image:url(http://i39.servimg.com/u/f39/14/83/59/48/wand-m11.png)">Tips</div></a>').insertAfter('.sceditor-button-horizontalrule').click(function() {
$('#message').sceditor("instance").insert('[blur]', '[/blur]');
return false
});
$('<a class="sceditor-button bbcode-myexample" title="إطار للعنوان"><div style="background-image:url(http://i39.servimg.com/u/f39/14/83/59/48/wrwrwe10.png)">Tips</div></a>').insertAfter('.sceditor-button-horizontalrule').click(function() {
$('#message').sceditor("instance").insert('[table class=gdwl][tr][td]', '[/td][/tr][/table]');
return false
});
$('<a class="sceditor-button bbcode-important" title="قلب النص"><div style="background-image:url(http://i71.servimg.com/u/f71/14/83/59/48/reload11.png)">Info note</div></a>').insertAfter('.sceditor-button-horizontalrule').click(function() {
$('#message').sceditor("instance").insert('[flipv]', '[/flipv]');
return false
})
});
var skin_color_picker = "light";
$(function() {
$(function() {
$("#message").length != 0 && (function(e) {
var t = function() {
var t = 65,
n = {
eventName: "click",
onShow: function() {},
onBeforeShow: function() {},
onHide: function() {},
onChange: function() {},
onSubmit: function() {},
color: "ff0000",
livePreview: !0,
skin: "light",
flat: !1
},
r = function(t, n) {
var r = D(t);
e(n).data("colorpicker").fields.eq(1).val(r.r).end().eq(2).val(r.g).end().eq(3).val(r.b).end()
},
i = function(t, n) {
e(n).data("colorpicker").fields.eq(4).val(t.h).end().eq(5).val(t.s).end().eq(6).val(t.b).end()
},
s = function(t, n) {
e(n).data("colorpicker").fields.eq(0).val(P(D(t))).end()
},
o = function(t, n) {
e(n).data("colorpicker").selector.css("backgroundColor", "#" + P(D({
h: t.h,
s: 100,
b: 100
})));
e(n).data("colorpicker").selectorIndic.css({
left: parseInt(150 * t.s / 100, 10),
top: parseInt(150 * (100 - t.b) / 100, 10)
})
},
u = function(t, n) {
e(n).data("colorpicker").hue.css("top", parseInt(150 - 150 * t.h / 360, 10))
},
a = function(t, n) {
e(n).data("colorpicker").currentColor.css("backgroundColor", "#" + P(D(t)))
},
f = function(t, n) {
e(n).data("colorpicker").newColor.css("backgroundColor", "#" + P(D(t)))
},
l = function(n) {
n = n.charCode || n.keyCode || -1;
if (n > t && n <= 90 || n == 32) return !1;
e(this).parent().parent().data("colorpicker").livePreview === !0 && h.apply(this)
},
h = function(t) {
var n = e(this).parent().parent(),
a;
if (this.parentNode.className.indexOf("_hex") > 0) {
a = n.data("colorpicker");
var l = this.value,
h = 6 - l.length;
if (h > 0) {
for (var p = [], d = 0; d < h; d++) p.push("0");
p.push(l);
l = p.join("")
}
l = _(M(l));
a.color = a = l
} else this.parentNode.className.indexOf("_hsb") > 0 ? n.data("colorpicker").color = a = O({
h: parseInt(n.data("colorpicker").fields.eq(4).val(), 10),
s: parseInt(n.data("colorpicker").fields.eq(5).val(), 10),
b: parseInt(n.data("colorpicker").fields.eq(6).val(), 10)
}) : (a = n.data("colorpicker"), l = {
r: parseInt(n.data("colorpicker").fields.eq(1).val(), 10),
g: parseInt(n.data("colorpicker").fields.eq(2).val(), 10),
b: parseInt(n.data("colorpicker").fields.eq(3).val(), 10)
}, a.color = a = _({
r: Math.min(255, Math.max(0, l.r)),
g: Math.min(255, Math.max(0, l.g)),
b: Math.min(255, Math.max(0, l.b))
}));
t && (r(a, n.get(0)), s(a, n.get(0)), i(a, n.get(0)));
o(a, n.get(0));
u(a, n.get(0));
f(a, n.get(0));
n.data("colorpicker").onChange.apply(n, [a, P(D(a)), D(a)])
},
p = function() {
e(this).parent().parent().data("colorpicker").fields.parent().removeClass("colorpicker_focus")
},
d = function() {
t = this.parentNode.className.indexOf("_hex") > 0 ? 70 : 65;
e(this).parent().parent().data("colorpicker").fields.parent().removeClass("colorpicker_focus");
e(this).parent().addClass("colorpicker_focus")
},
v = function(t) {
var n = e(this).parent().find("input").focus(),
t = {
el: e(this).parent().addClass("colorpicker_slider"),
max: this.parentNode.className.indexOf("_hsb_h") > 0 ? 360 : this.parentNode.className.indexOf("_hsb") > 0 ? 100 : 255,
y: t.pageY,
field: n,
val: parseInt(n.val(), 10),
preview: e(this).parent().parent().data("colorpicker").livePreview
};
e(document).bind("mouseup", t, g);
e(document).bind("mousemove", t, m)
},
m = function(e) {
e.data.field.val(Math.max(0, Math.min(e.data.max, parseInt(e.data.val + e.pageY - e.data.y, 10))));
e.data.preview && h.apply(e.data.field.get(0), [!0]);
return !1
},
g = function(t) {
h.apply(t.data.field.get(0), [!0]);
t.data.el.removeClass("colorpicker_slider").find("input").focus();
e(document).unbind("mouseup", g);
e(document).unbind("mousemove", m);
return !1
},
y = function() {
var t = {
cal: e(this).parent(),
y: e(this).offset().top
};
t.preview = t.cal.data("colorpicker").livePreview;
e(document).bind("mouseup", t, w);
e(document).bind("mousemove", t, b)
},
b = function(e) {
h.apply(e.data.cal.data("colorpicker").fields.eq(4).val(parseInt(360 * (150 - Math.max(0, Math.min(150, e.pageY - e.data.y))) / 150, 10)).get(0), [e.data.preview]);
return !1
},
w = function(t) {
r(t.data.cal.data("colorpicker").color, t.data.cal.get(0));
s(t.data.cal.data("colorpicker").color, t.data.cal.get(0));
e(document).unbind("mouseup", w);
e(document).unbind("mousemove", b);
return !1
},
E = function() {
var t = {
cal: e(this).parent(),
pos: e(this).offset()
};
t.preview = t.cal.data("colorpicker").livePreview;
e(document).bind("mouseup", t, x);
e(document).bind("mousemove", t, S)
},
S = function(e) {
h.apply(e.data.cal.data("colorpicker").fields.eq(6).val(parseInt(100 * (150 - Math.max(0, Math.min(150, e.pageY - e.data.pos.top))) / 150, 10)).end().eq(5).val(parseInt(100 * Math.max(0, Math.min(150, e.pageX - e.data.pos.left)) / 150, 10)).get(0), [e.data.preview]);
return !1
},
x = function(t) {
r(t.data.cal.data("colorpicker").color, t.data.cal.get(0));
s(t.data.cal.data("colorpicker").color, t.data.cal.get(0));
e(document).unbind("mouseup", x);
e(document).unbind("mousemove", S);
return !1
},
T = function() {
e(this).addClass("colorpicker_focus")
},
N = function() {
e(this).removeClass("colorpicker_focus")
},
C = function(t) {
var n = e(this).parent(),
r = n.data("colorpicker").color;
n.data("colorpicker").origColor = r;
a(r, n.get(0));
n.data("colorpicker").onSubmit(r, P(D(r)), D(r), n.data("colorpicker").el, t);
e(this).parent().hide()
},
k = function() {
var t = e("#" + e(this).data("colorpickerId"));
t.data("colorpicker").onBeforeShow.apply(this, [t.get(0)]);
var n = e(this).offset(),
r;
r = document.compatMode == "CSS1Compat";
r = {
l: window.pageXOffset || (r ? document.documentElement.scrollLeft : document.body.scrollLeft),
t: window.pageYOffset || (r ? document.documentElement.scrollTop : document.body.scrollTop),
w: window.innerWidth || (r ? document.documentElement.clientWidth : document.body.clientWidth),
h: window.innerHeight || (r ? document.documentElement.clientHeight : document.body.clientHeight)
};
var i = n.top + this.offsetHeight,
n = n.left;
i + 176 > r.t + r.h && (i -= this.offsetHeight + 176);
n + 356 > r.l + r.w && (n -= 356);
t.css({
left: n + "px",
top: i + "px"
});
t.data("colorpicker").onShow.apply(this, [t.get(0)]) != !1 && t.show("fast");
e(document).bind("mousedown", {
cal: t
}, L);
return !1
},
L = function(t) {
A(t.data.cal.get(0), t.target, t.data.cal.get(0)) || (t.data.cal.data("colorpicker").onHide.apply(this, [t.data.cal.get(0)]) != !1 && t.data.cal.hide(), e(document).unbind("mousedown", L))
},
A = function(e, t, n) {
if (e == t) return !0;
if (e.contains) return e.contains(t);
if (e.compareDocumentPosition) return !!(e.compareDocumentPosition(t) & 16);
for (t = t.parentNode; t && t != n;) {
if (t == e) return !0;
t = t.parentNode
}
return !1
},
O = function(e) {
return {
h: Math.min(360, Math.max(0, e.h)),
s: Math.min(100, Math.max(0, e.s)),
b: Math.min(100, Math.max(0, e.b))
}
},
M = function(e) {
e = parseInt(e.indexOf("#") > -1 ? e.substring(1) : e, 16);
return {
r: e >> 16,
g: (e & 65280) >> 8,
b: e & 255
}
},
_ = function(e) {
var t = {
h: 0,
s: 0,
b: 0
},
n = Math.max(e.r, e.g, e.b),
r = n - Math.min(e.r, e.g, e.b);
t.b = n;
t.s = n != 0 ? 255 * r / n : 0;
t.h = t.s != 0 ? e.r == n ? (e.g - e.b) / r : e.g == n ? 2 + (e.b - e.r) / r : 4 + (e.r - e.g) / r : -1;
t.h *= 60;
t.h < 0 && (t.h += 360);
t.s *= 100 / 255;
t.b *= 100 / 255;
return t
},
D = function(e) {
var t = {},
n = Math.round(e.h),
r = Math.round(e.s * 255 / 100),
e = Math.round(e.b * 255 / 100);
if (r == 0) t.r = t.g = t.b = e;
else {
var r = (255 - r) * e / 255,
i = (e - r) * (n % 60) / 60;
n == 360 && (n = 0);
n < 60 ? (t.r = e, t.b = r, t.g = r + i) : n < 120 ? (t.g = e, t.b = r, t.r = e - i) : n < 180 ? (t.g = e, t.r = r, t.b = r + i) : n < 240 ? (t.b = e, t.r = r, t.g = e - i) : n < 300 ? (t.b = e, t.g = r, t.r = r + i) : n < 360 ? (t.r = e, t.g = r, t.b = e - i) : (t.r = 0, t.g = 0, t.b = 0)
}
return {
r: Math.round(t.r),
g: Math.round(t.g),
b: Math.round(t.b)
}
},
P = function(t) {
var n = [t.r.toString(16), t.g.toString(16), t.b.toString(16)];
e.each(n, function(e, t) {
t.length == 1 && (n[e] = "0" + t)
});
return n.join("")
},
H = function() {
var t = e(this).parent(),
n = t.data("colorpicker").origColor;
t.data("colorpicker").color = n;
r(n, t.get(0));
s(n, t.get(0));
i(n, t.get(0));
o(n, t.get(0));
u(n, t.get(0));
f(n, t.get(0))
};
return {
init: function(t) {
t = e.extend({}, n, t || {});
if (typeof t.color == "string") t.color = _(M(t.color));
else if (t.color.r != void 0 && t.color.g != void 0 && t.color.b != void 0) t.color = _(t.color);
else if (t.color.h != void 0 && t.color.s != void 0 && t.color.b != void 0) t.color = O(t.color);
else return this;
return this.each(function() {
if (!e(this).data("colorpickerId")) {
var n = e.extend({}, t);
n.origColor = t.color;
var m = "collorpicker_" + parseInt(Math.random() * 1e3);
e(this).data("colorpickerId", m);
m = e('<div class="sceditor-dropdown colorpicker ' + n.skin + '"><div class="colorpicker_color"><div><div></div></div></div><div class="colorpicker_hue"><div></div></div><div class="colorpicker_new_color"></div><div class="colorpicker_current_color"></div><div class="colorpicker_hex"><input type="text" maxlength="6" size="6" /></div><div class="colorpicker_rgb_r colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_g colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_rgb_b colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_h colorpicker_field"><input type="text" maxlength="3" size="3" /><span></span></div><div class="colorpicker_hsb_s colorpicker_field"><input type="text" size="3" /><span></span></div><div class="colorpicker_hsb_b colorpicker_field"><input type="text" size="3" /><span></span></div><div class="colorpicker_submit"></div></div>').attr("id", m);
n.flat ? m.appendTo(this).show("fast") : m.appendTo(document.body);
n.fields = m.find("input").bind("keyup", l).bind("change", h).bind("blur", p).bind("focus", d);
m.find("span").bind("mousedown", v).end().find(">div.colorpicker_current_color").bind("click", H);
n.selector = m.find("div.colorpicker_color").bind("mousedown", E);
n.selectorIndic = n.selector.find("div div");
n.el = this;
n.hue = m.find("div.colorpicker_hue div");
m.find("div.colorpicker_hue").bind("mousedown", y);
n.newColor = m.find("div.colorpicker_new_color");
n.currentColor = m.find("div.colorpicker_current_color");
m.data("colorpicker", n);
m.find("div.colorpicker_submit").bind("mouseenter", T).bind("mouseleave", N).bind("click", C);
r(n.color, m.get(0));
i(n.color, m.get(0));
s(n.color, m.get(0));
u(n.color, m.get(0));
o(n.color, m.get(0));
a(n.color, m.get(0));
f(n.color, m.get(0));
n.flat ? m.css({
position: "relative",
display: "block"
}) : e(this).bind(n.eventName, k)
}
})
},
showPicker: function() {
return this.each(function() {
e(this).data("colorpickerId") && k.apply(this)
})
},
hidePicker: function() {
return this.each(function() {
e(this).data("colorpickerId") && e("#" + e(this).data("colorpickerId")).hide()
})
},
setColor: function(t) {
if (typeof t == "string") t = _(M(t));
else if (t.r != void 0 && t.g != void 0 && t.b != void 0) t = _(t);
else if (t.h != void 0 && t.s != void 0 && t.b != void 0) t = O(t);
else return this;
return this.each(function() {
if (e(this).data("colorpickerId")) {
var n = e("#" + e(this).data("colorpickerId"));
n.data("colorpicker").color = t;
n.data("colorpicker").origColor = t;
r(t, n.get(0));
i(t, n.get(0));
s(t, n.get(0));
u(t, n.get(0));
o(t, n.get(0));
a(t, n.get(0));
f(t, n.get(0))
}
})
}
}
}();
e.fn.extend({
ColorPicker: t.init,
ColorPickerHide: t.hidePicker,
ColorPickerShow: t.showPicker,
ColorPickerSetColor: t.setColor
})
}(jQuery), $('<a class="sceditor-button sceditor-button-paletaavanzada" unselectable="on" title="لون خط الكتابة"><div unselectable="on" style="cursor: pointer !important; opacity: 1 !important; background-image:url(http://i83.servimg.com/u/f83/17/45/19/77/color_10.png)"></div></a>').insertAfter(".sceditor-button-color").ColorPicker({
color: my_getcookie("defColCP") ? my_getcookie("defColCP") : "#000000",
flat: false,
skin: skin_color_picker,
onSubmit: function(e, t, n, r) {
my_setcookie("defColCP", t, 1, 0);
var i = $("#message").sceditor("instance");
i.inSourceMode() ? i.insertText("[color=#" + t + "]", "[/color]") : i.execCommand("forecolor", "#" + t);
return !1
}
}))
})
});
var editormaxi = false;
$(function() {
$(function() {
$('<a class="sceditor-button sceditor-button-maxi" unselectable="on" title="تكبير الصندوق"><div unselectable="on" style="cursor:pointer!important;opacity:1!important;background-image:url(http://i37.servimg.com/u/f37/17/45/19/77/full_s10.png)">Maximizar</div></a>').insertBefore('.sceditor-button-source').click(function() {
$("#message").sceditor("instance").maximize(editormaxi = !editormaxi).focus();
if (editormaxi) {
$(".sceditor-button-maxi").addClass("hover");
$("div.sceditor-container").append('<div align="center" id="sceditor-maximized" class="sceditor-toolbar" style="width:100%;border-top:1px solid silver;position:absolute;bottom:0;"><input type="submit" value="معاينة" name="preview"> <input type="submit" value="ارسال" name="post"></div>');
$(".sceditor-maximize").prop("style", $(".sceditor-maximize").attr("style") + ";text-align:center;");
$("#fa_toolbar").hide()
} else {
$(".sceditor-button-maxi").removeClass("hover");
$("#sceditor-maximized").remove();
$("#fa_toolbar").show()
}
})
})
})
@BlackScorpion no problem, I hope you have fun with it !
@Michael_vx It looks like your website / forum doesn't have the custom function for getting and setting cookies that forumotion has. Try adding these into a JavaScript section on your forum :
For the message editor id, you should try using the devtools in your browser to inspect the HTML of the document. Which browser are you using ?
@Michael_vx It looks like your website / forum doesn't have the custom function for getting and setting cookies that forumotion has. Try adding these into a JavaScript section on your forum :
- Code:
function my_getcookie(name) {
cname = name + '=';
cpos = document.cookie.indexOf(cname);
if (cpos != -1) {
cstart = cpos + cname.length;
cend = document.cookie.indexOf(";", cstart);
if (cend == -1) {
cend = document.cookie.length
}
return unescape(document.cookie.substring(cstart, cend))
}
return null
}
function my_setcookie(name, value, sticky, path) {
expires = "";
domain = "";
if (sticky) {
expires = "; expires=Wed, 1 Jan 2020 00:00:00 GMT"
}
if (!path) {
path = "/"
}
document.cookie = name + "=" + value + "; path=" + path + expires + domain + ';'
}
For the message editor id, you should try using the devtools in your browser to inspect the HTML of the document. Which browser are you using ?
@Ange Tuteur
there is no such a thing called Java Sction
i can add JavaScripts in any template as the way as i want the Script to appear within about 400 templates in total
should i add the Script above to running in all pages or Just the new thread/reply pages
im using FireFox
i have also UC broswer installed - CometBird - Safari - Google Chrome
there is no such a thing called Java Sction
i can add JavaScripts in any template as the way as i want the Script to appear within about 400 templates in total
should i add the Script above to running in all pages or Just the new thread/reply pages
im using FireFox
i have also UC broswer installed - CometBird - Safari - Google Chrome
@Michael_vx oh, that sucks. Even on my website I had a section for my JavaScripts. xD I'd add it inside the <head> section if you can.
@Michael_vx I forgot to ask ; is this for the Giphy button or something else ? If it's for something else I wont be able to help here further, because this topic is meant for the Giphy plugin.
Ah okay, does anything show up in your console when you add this code ?
- Code:
$(function() {
var msg = $('#message')[0];
console.log(msg ? msg : 'NO');
});
@SLGray yep, they have a rating limit for the API. By default I have it set to pg-13. The ratings available are :
- y
- g
- pg
- pg-13
- r
You can replace pg-13 in the script with any of the ratings above.
- y
- g
- pg
- pg-13
- r
You can replace pg-13 in the script with any of the ratings above.
Thanks for the information.Ange Tuteur wrote:@SLGray yep, they have a rating limit for the API. By default I have it set to pg-13. The ratings available are :
- y
- g
- pg
- pg-13
- r
You can replace pg-13 in the script with any of the ratings above.
Ange Tuteur wrote:Ah okay, does anything show up in your console when you add this code ?It's to check if the textarea's id is message or not. If yes it'll display the element, if not it'll display "NO".
- Code:
$(function() {
var msg = $('#message')[0];
console.log(msg ? msg : 'NO');
});
i got this on the console
- Code:
<textarea style="width: 100%; height: 297.667px; display: none;" tabindex="1" id="message" name="message" cols="80" rows="8" class="w3-input w3-border w3-round">
looks like using #message was wrong or there something that im stupid at it
one more thing
what does the rates
- y
- g
- pg
- pg-13
- r
what does it control
i mean is it something like
age control ??? +12 +16 or +18
That's correct, the id for the editor shows id="message" so, #message should suffice for the selector. So for forumotion scripts you need to replace text_editor_textarea with message.
Yep, the ratings are for age restrictions It's similar to movie ratings :
https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system#From_M_to_GP_to_PG
Yep, the ratings are for age restrictions It's similar to movie ratings :
https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system#From_M_to_GP_to_PG
Yep, you got it right !
Alright, sorry to hear that. If you want, you can check out this section. I'll be posting tutorials there related to teaching web development, specifically on the forums, but these methods can be applied anywhere on the web.
Alright, sorry to hear that. If you want, you can check out this section. I'll be posting tutorials there related to teaching web development, specifically on the forums, but these methods can be applied anywhere on the web.
- Sponsored content
Page 2 of 3 • 1, 2, 3
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 2 of 3
Permissions in this forum:
You cannot reply to topics in this forum