Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

first commit

  • Loading branch information...
commit 9097de2a7cc86df42565f8d2b8a68eccae232f57 0 parents
@NoahY authored
60 README.rst
@@ -0,0 +1,60 @@
+===========================
+Question2Answer Embed 1.0b2
+===========================
+-----------
+Description
+-----------
+This is a plugin for **Question2Answer** that provides media embedding functionality.
+
+--------
+Features
+--------
+- currently supports the following sites:
+ - YouTube
+ - Vimeo
+ - Metacafe
+ - Dailymotion
+- also supports basic image and mp3 embedding from urls
+- option to add Thickbox_ effect for images
+- switch on and off via admin/plugins
+- set width and height via admin/plugins
+
+.. _Thickbox: http://jquery.com/demo/thickbox/
+
+------------
+Installation
+------------
+#. Install Question2Answer_
+#. Get the source code for this plugin from github_, either using git_, or downloading directly:
+
+ - To download using git, install git and then type
+ ``git clone git://github.com/NoahY/q2a-embed.git embed``
+ at the command prompt (on Linux, Windows is a bit different)
+ - To download directly, go to the `project page`_ and click **Download**
+
+#. navigate to your site, go to **Admin -> Plugins** on your q2a install and select the '**Enable Video Embedding**' option, then '**Save**'.
+
+.. _Question2Answer: http://www.question2answer.org/install.php
+.. _git: http://git-scm.com/
+.. _github:
+.. _project page: https://github.com/NoahY/q2a-embed
+
+----------
+Disclaimer
+----------
+This is **beta** code. It is probably okay for production environments, but may not work exactly as expected. Refunds will not be given. If it breaks, you get to keep both parts.
+
+-------
+Release
+-------
+All code herein is Copylefted_.
+
+.. _Copylefted: http://en.wikipedia.org/wiki/Copyleft
+
+---------
+About q2A
+---------
+Question2Answer is a free and open source platform for Q&A sites. For more information, visit:
+
+http://www.question2answer.org/
+
57 qa-confirm-admin.php
@@ -0,0 +1,57 @@
+<?php
+ class qa_confirm_admin {
+
+ function option_default($option) {
+
+ switch($option) {
+ default:
+ return null;
+ }
+
+ }
+
+ function allow_template($template)
+ {
+ return ($template!='admin');
+ }
+
+ function admin_form(&$qa_content)
+ {
+
+ // Process form input
+
+ $ok = null;
+
+ if (qa_clicked('confirm_plugin_save')) {
+ qa_opt('confirm_close_plugin',(bool)qa_post_text('confirm_close_plugin'));
+ $ok = qa_lang('admin/options_saved');
+ }
+
+ // Create the form for display
+
+
+ $fields = array();
+
+ $fields[] = array(
+ 'label' => 'Enable confirmation',
+ 'tags' => 'NAME="confirm_close_plugin"',
+ 'value' => qa_opt('confirm_close_plugin'),
+ 'type' => 'checkbox',
+ );
+
+
+ return array(
+ 'ok' => ($ok && !isset($error)) ? $ok : null,
+
+ 'fields' => $fields,
+
+ 'buttons' => array(
+ array(
+ 'label' => 'Save',
+ 'tags' => 'NAME="confirm_plugin_save"',
+ )
+ ),
+ );
+ }
+ }
+
44 qa-confirm-layer.php
@@ -0,0 +1,44 @@
+<?php
+
+ class qa_html_theme_layer extends qa_html_theme_base {
+
+ // theme replacement functions
+
+ function head_custom()
+ {
+ qa_html_theme_base::head_custom();
+ if(in_array($this->template, array('question','ask','not-found')) && qa_opt('confirm_close_plugin')) {
+ $this->output('<script type="text/javascript">
+jQuery("document").ready(function() {
+ jQuery("textarea").each( function(i) {
+ if(this.value) {
+ window.onbeforeunload = function(event) {
+ return "You have entered text; are you sure you wish to leave this page?";
+ }
+ return;
+ }
+ else
+ window.onbeforeunload = null;
+ });
+ jQuery("textarea").keyup(function(){checkForContent()});
+ jQuery("form").submit(function(event) {
+ window.onbeforeunload = null;
+ });
+});
+function checkForContent() {
+ jQuery("textarea").each( function(i) {
+ if(this.value) {
+ window.onbeforeunload = function(event) {
+ return "You have entered text; are you sure you wish to leave this page?";
+ }
+ return;
+ }
+ else
+ window.onbeforeunload = null;
+ });
+}
+</script>');
+ }
+ }
+ }
+
30 qa-plugin.php
@@ -0,0 +1,30 @@
+<?php
+
+/*
+ Plugin Name: Confirm
+ Plugin URI: https://github.com/NoahY/q2a-confirm
+ Plugin Description: Confirm close when text is entered
+ Plugin Version: 1.0b1
+ Plugin Date: 2011-11-24
+ Plugin Author: NoahY
+ Plugin Author URI:
+ Plugin License: GPLv2
+ Plugin Minimum Question2Answer Version: 1.3
+*/
+
+
+ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
+ header('Location: ../../');
+ exit;
+ }
+
+ qa_register_plugin_module('module', 'qa-confirm-admin.php', 'qa_confirm_admin', 'Confirm Admin');
+
+ qa_register_plugin_layer('qa-confirm-layer.php', 'Confirm Replacement Layer');
+
+
+/*
+ Omit PHP closing tag to help avoid accidental output
+*/
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.