Merge branch 'seeddms-5.0.x' into develop
|
@ -26,6 +26,7 @@
|
||||||
- take out file deletion because it was (and probabbly never has been) useful
|
- take out file deletion because it was (and probabbly never has been) useful
|
||||||
- send notification if folder is deleted by ajax call
|
- send notification if folder is deleted by ajax call
|
||||||
- add page ImportFS for mass importing files from drop folder
|
- add page ImportFS for mass importing files from drop folder
|
||||||
|
- add initial version for editing text files online
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
Changes in version 4.3.24
|
Changes in version 4.3.24
|
||||||
|
|
|
@ -53,6 +53,27 @@ class SeedDMS_AccessOperation {
|
||||||
$this->settings = $settings;
|
$this->settings = $settings;
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if editing of version is allowed
|
||||||
|
*
|
||||||
|
* This check can only be done for documents. Removal of versions is
|
||||||
|
* only allowed if this is turned on in the settings and there are
|
||||||
|
* at least 2 versions avaiable. Everybody with write access on the
|
||||||
|
* document may delete versions. The admin may even delete a version
|
||||||
|
* even if is disallowed in the settings.
|
||||||
|
*/
|
||||||
|
function mayEditVersion() { /* {{{ */
|
||||||
|
if(get_class($this->obj) == 'SeedDMS_Core_Document') {
|
||||||
|
$version = $this->obj->getLatestContent();
|
||||||
|
if (!isset($this->settings->_editOnlineFileTypes) || !is_array($this->settings->_editOnlineFileTypes) || !in_array(strtolower($version->getFileType()), $this->settings->_editOnlineFileTypes))
|
||||||
|
return false;
|
||||||
|
if ($this->obj->getAccessMode($this->user) == M_ALL || $this->user->isAdmin()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if removal of version is allowed
|
* Check if removal of version is allowed
|
||||||
*
|
*
|
||||||
|
|
|
@ -113,6 +113,8 @@ class Settings { /* {{{ */
|
||||||
var $_updateNotifyTime = 86400;
|
var $_updateNotifyTime = 86400;
|
||||||
// files with one of the following endings can be viewed online
|
// files with one of the following endings can be viewed online
|
||||||
var $_viewOnlineFileTypes = array();
|
var $_viewOnlineFileTypes = array();
|
||||||
|
// files with one of the following endings can be edited online
|
||||||
|
var $_editOnlineFileTypes = array();
|
||||||
// enable/disable converting of files
|
// enable/disable converting of files
|
||||||
var $_enableConverting = false;
|
var $_enableConverting = false;
|
||||||
// default style
|
// default style
|
||||||
|
@ -335,6 +337,26 @@ class Settings { /* {{{ */
|
||||||
return implode(";", $this->_viewOnlineFileTypes);
|
return implode(";", $this->_viewOnlineFileTypes);
|
||||||
} /* }}} */
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* set $_editOnlineFileTypes
|
||||||
|
*
|
||||||
|
* @param string $stringValue string value
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function setEditOnlineFileTypesFromString($stringValue) { /* {{{ */
|
||||||
|
$this->_editOnlineFileTypes = explode(";", $stringValue);
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get $_editOnlineFileTypes in a string value
|
||||||
|
*
|
||||||
|
* @return string value
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function getEditOnlineFileTypesToString() { /* {{{ */
|
||||||
|
return implode(";", $this->_editOnlineFileTypes);
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load config file
|
* Load config file
|
||||||
*
|
*
|
||||||
|
@ -370,6 +392,7 @@ class Settings { /* {{{ */
|
||||||
$tab = $node[0]->attributes();
|
$tab = $node[0]->attributes();
|
||||||
$this->_strictFormCheck = Settings::boolVal($tab["strictFormCheck"]);
|
$this->_strictFormCheck = Settings::boolVal($tab["strictFormCheck"]);
|
||||||
$this->setViewOnlineFileTypesFromString(strval($tab["viewOnlineFileTypes"]));
|
$this->setViewOnlineFileTypesFromString(strval($tab["viewOnlineFileTypes"]));
|
||||||
|
$this->setEditOnlineFileTypesFromString(strval($tab["editOnlineFileTypes"]));
|
||||||
$this->_enableConverting = Settings::boolVal($tab["enableConverting"]);
|
$this->_enableConverting = Settings::boolVal($tab["enableConverting"]);
|
||||||
$this->_enableEmail = Settings::boolVal($tab["enableEmail"]);
|
$this->_enableEmail = Settings::boolVal($tab["enableEmail"]);
|
||||||
$this->_enableUsersView = Settings::boolVal($tab["enableUsersView"]);
|
$this->_enableUsersView = Settings::boolVal($tab["enableUsersView"]);
|
||||||
|
@ -688,6 +711,7 @@ class Settings { /* {{{ */
|
||||||
$node = $this->getXMLNode($xml, '/configuration/site', 'edition');
|
$node = $this->getXMLNode($xml, '/configuration/site', 'edition');
|
||||||
$this->setXMLAttributValue($node, "strictFormCheck", $this->_strictFormCheck);
|
$this->setXMLAttributValue($node, "strictFormCheck", $this->_strictFormCheck);
|
||||||
$this->setXMLAttributValue($node, "viewOnlineFileTypes", $this->getViewOnlineFileTypesToString());
|
$this->setXMLAttributValue($node, "viewOnlineFileTypes", $this->getViewOnlineFileTypesToString());
|
||||||
|
$this->setXMLAttributValue($node, "editOnlineFileTypes", $this->getEditOnlineFileTypesToString());
|
||||||
$this->setXMLAttributValue($node, "enableConverting", $this->_enableConverting);
|
$this->setXMLAttributValue($node, "enableConverting", $this->_enableConverting);
|
||||||
$this->setXMLAttributValue($node, "enableEmail", $this->_enableEmail);
|
$this->setXMLAttributValue($node, "enableEmail", $this->_enableEmail);
|
||||||
$this->setXMLAttributValue($node, "enableUsersView", $this->_enableUsersView);
|
$this->setXMLAttributValue($node, "enableUsersView", $this->_enableUsersView);
|
||||||
|
|
|
@ -118,7 +118,7 @@ function fileExistsInIncludePath($file) { /* {{{ */
|
||||||
* Load default settings + set
|
* Load default settings + set
|
||||||
*/
|
*/
|
||||||
define("SEEDDMS_INSTALL", "on");
|
define("SEEDDMS_INSTALL", "on");
|
||||||
define("SEEDDMS_VERSION", "5.0.1");
|
define("SEEDDMS_VERSION", "5.0.2");
|
||||||
|
|
||||||
require_once('../inc/inc.ClassSettings.php');
|
require_once('../inc/inc.ClassSettings.php');
|
||||||
|
|
||||||
|
|
67
op/op.EditOnline.php
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
<?php
|
||||||
|
// MyDMS. Document Management System
|
||||||
|
// Copyright (C) 2002-2005 Markus Westphal
|
||||||
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
include("../inc/inc.Settings.php");
|
||||||
|
include("../inc/inc.LogInit.php");
|
||||||
|
include("../inc/inc.Utils.php");
|
||||||
|
include("../inc/inc.DBInit.php");
|
||||||
|
include("../inc/inc.Language.php");
|
||||||
|
include("../inc/inc.ClassUI.php");
|
||||||
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
|
if (!isset($_POST["documentid"]) || !is_numeric($_POST["documentid"]) || intval($_POST["documentid"])<1) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$documentid = $_POST["documentid"];
|
||||||
|
$document = $dms->getDocument($documentid);
|
||||||
|
|
||||||
|
if (!is_object($document)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$folder = $document->getFolder();
|
||||||
|
$docPathHTML = getFolderPathHTML($folder, true). " / <a href=\"../out/out.ViewDocument.php?documentid=".$documentid."\">".$document->getName()."</a>";
|
||||||
|
|
||||||
|
if ($document->getAccessMode($user) < M_READWRITE) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if($document->isLocked()) {
|
||||||
|
$lockingUser = $document->getLockingUser();
|
||||||
|
if (($lockingUser->getID() != $user->getID()) && ($document->getAccessMode($user) != M_ALL)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => htmlspecialchars($document->getName()))),getMLText("lock_message", array("email" => $lockingUser->getEmail(), "username" => htmlspecialchars($lockingUser->getFullName()))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$tmpfname = tempnam(sys_get_temp_dir(), 'FOO');
|
||||||
|
file_put_contents($tmpfname, $_POST['data']);
|
||||||
|
|
||||||
|
/* Check if the uploaded file is identical to last version */
|
||||||
|
$lc = $document->getLatestContent();
|
||||||
|
if($lc->getChecksum() == SeedDMS_Core_File::checksum($tmpfname)) {
|
||||||
|
echo json_encode(array('success'=>false, 'message'=>getMLText('identical_version')));
|
||||||
|
} else {
|
||||||
|
if($document->replaceContent(0, $user, $tmpfname, $lc->getOriginalFileName(), $lc->getFileType(), $lc->getMimeType())) {
|
||||||
|
echo json_encode(array('success'=>true, 'message'=>getMLText('splash_saved_file')));
|
||||||
|
} else {
|
||||||
|
echo json_encode(array('success'=>false, 'message'=>getMLText('splash_error_saving_file')));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
unlink($tmpfname);
|
|
@ -65,6 +65,7 @@ if ($action == "saveSettings")
|
||||||
// SETTINGS - SITE - EDITION
|
// SETTINGS - SITE - EDITION
|
||||||
$settings->_strictFormCheck = getBoolValue("strictFormCheck");
|
$settings->_strictFormCheck = getBoolValue("strictFormCheck");
|
||||||
$settings->setViewOnlineFileTypesFromString($_POST["viewOnlineFileTypes"]);
|
$settings->setViewOnlineFileTypesFromString($_POST["viewOnlineFileTypes"]);
|
||||||
|
$settings->setEditOnlineFileTypesFromString($_POST["editOnlineFileTypes"]);
|
||||||
$settings->_enableConverting = getBoolValue("enableConverting");
|
$settings->_enableConverting = getBoolValue("enableConverting");
|
||||||
$settings->_enableEmail =getBoolValue("enableEmail");
|
$settings->_enableEmail =getBoolValue("enableEmail");
|
||||||
$settings->_enableUsersView = getBoolValue("enableUsersView");
|
$settings->_enableUsersView = getBoolValue("enableUsersView");
|
||||||
|
|
94
out/out.EditOnline.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?php
|
||||||
|
// MyDMS. Document Management System
|
||||||
|
// Copyright (C) 2002-2005 Markus Westphal
|
||||||
|
// Copyright (C) 2006-2008 Malcolm Cowe
|
||||||
|
// Copyright (C) 2011 Uwe Steinmann
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation; either version 2 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program; if not, write to the Free Software
|
||||||
|
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
|
||||||
|
include("../inc/inc.Settings.php");
|
||||||
|
include("../inc/inc.LogInit.php");
|
||||||
|
include("../inc/inc.DBInit.php");
|
||||||
|
include("../inc/inc.Language.php");
|
||||||
|
include("../inc/inc.ClassUI.php");
|
||||||
|
include("../inc/inc.ClassAccessOperation.php");
|
||||||
|
include("../inc/inc.Authentication.php");
|
||||||
|
|
||||||
|
$documentid = $_GET["documentid"];
|
||||||
|
|
||||||
|
if (!isset($documentid) || !is_numeric($documentid) || intval($documentid)<1) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$document = $dms->getDocument($documentid);
|
||||||
|
|
||||||
|
if (!is_object($document)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => getMLText("invalid_doc_id"))),getMLText("invalid_doc_id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($document->getAccessMode($user) < M_READWRITE) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("access_denied"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_GET["version"])) {
|
||||||
|
$version = $_GET["version"];
|
||||||
|
|
||||||
|
if (!is_numeric($version)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
|
}
|
||||||
|
|
||||||
|
$content = $document->getContentByVersion($version);
|
||||||
|
$lc = $document->getLatestContent();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
$content = $document->getLatestContent();
|
||||||
|
$lc = $document->getLatestContent();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_object($content)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Only the latest version may be edited */
|
||||||
|
if($content->getVersion() != $lc->getVersion()) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
if (!isset($settings->_editOnlineFileTypes) || !is_array($settings->_editOnlineFileTypes) || !in_array(strtolower($content->getFileType()), $settings->_editOnlineFileTypes)) {
|
||||||
|
UI::exitError(getMLText("document_title", array("documentname" => $document->getName())),getMLText("invalid_version"));
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Create object for checking access to certain operations */
|
||||||
|
$accessop = new SeedDMS_AccessOperation($dms, $user, $settings);
|
||||||
|
|
||||||
|
$folder = $document->getFolder();
|
||||||
|
|
||||||
|
$tmp = explode('.', basename($_SERVER['SCRIPT_FILENAME']));
|
||||||
|
$view = UI::factory($theme, $tmp[1], array('dms'=>$dms, 'user'=>$user));
|
||||||
|
if($view) {
|
||||||
|
$view->setParam('document', $document);
|
||||||
|
$view->setParam('version', $content);
|
||||||
|
$view->setParam('folder', $folder);
|
||||||
|
$view->setParam('accessobject', $accessop);
|
||||||
|
$view->setParam('cachedir', $settings->_cacheDir);
|
||||||
|
$view->setParam('previewWidthList', $settings->_previewWidthList);
|
||||||
|
$view->setParam('previewWidthDetail', $settings->_previewWidthDetail);
|
||||||
|
$view->setParam('timeout', $settings->_cmdTimeout);
|
||||||
|
$view($_GET);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
665
styles/bootstrap/markitup/jquery.markitup.js
Normal file
|
@ -0,0 +1,665 @@
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// markItUp! Universal MarkUp Engine, JQuery plugin
|
||||||
|
// v 1.1.x
|
||||||
|
// Dual licensed under the MIT and GPL licenses.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2007-2012 Jay Salvat
|
||||||
|
// http://markitup.jaysalvat.com/
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
(function($) {
|
||||||
|
$.fn.markItUp = function(settings, extraSettings) {
|
||||||
|
var method, params, options, ctrlKey, shiftKey, altKey; ctrlKey = shiftKey = altKey = false;
|
||||||
|
|
||||||
|
if (typeof settings == 'string') {
|
||||||
|
method = settings;
|
||||||
|
params = extraSettings;
|
||||||
|
}
|
||||||
|
|
||||||
|
options = { id: '',
|
||||||
|
nameSpace: '',
|
||||||
|
root: '',
|
||||||
|
previewHandler: false,
|
||||||
|
previewInWindow: '', // 'width=800, height=600, resizable=yes, scrollbars=yes'
|
||||||
|
previewInElement: '',
|
||||||
|
previewAutoRefresh: true,
|
||||||
|
previewPosition: 'after',
|
||||||
|
previewTemplatePath: '~/templates/preview.html',
|
||||||
|
previewParser: false,
|
||||||
|
previewParserPath: '',
|
||||||
|
previewParserVar: 'data',
|
||||||
|
resizeHandle: true,
|
||||||
|
beforeInsert: '',
|
||||||
|
afterInsert: '',
|
||||||
|
onEnter: {},
|
||||||
|
onShiftEnter: {},
|
||||||
|
onCtrlEnter: {},
|
||||||
|
onTab: {},
|
||||||
|
markupSet: [ { /* set */ } ]
|
||||||
|
};
|
||||||
|
$.extend(options, settings, extraSettings);
|
||||||
|
|
||||||
|
// compute markItUp! path
|
||||||
|
if (!options.root) {
|
||||||
|
$('script').each(function(a, tag) {
|
||||||
|
miuScript = $(tag).get(0).src.match(/(.*)jquery\.markitup(\.pack)?\.js$/);
|
||||||
|
if (miuScript !== null) {
|
||||||
|
options.root = miuScript[1];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quick patch to keep compatibility with jQuery 1.9
|
||||||
|
var uaMatch = function(ua) {
|
||||||
|
ua = ua.toLowerCase();
|
||||||
|
|
||||||
|
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) ||
|
||||||
|
/(webkit)[ \/]([\w.]+)/.exec(ua) ||
|
||||||
|
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) ||
|
||||||
|
/(msie) ([\w.]+)/.exec(ua) ||
|
||||||
|
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) ||
|
||||||
|
[];
|
||||||
|
|
||||||
|
return {
|
||||||
|
browser: match[ 1 ] || "",
|
||||||
|
version: match[ 2 ] || "0"
|
||||||
|
};
|
||||||
|
};
|
||||||
|
var matched = uaMatch( navigator.userAgent );
|
||||||
|
var browser = {};
|
||||||
|
|
||||||
|
if (matched.browser) {
|
||||||
|
browser[matched.browser] = true;
|
||||||
|
browser.version = matched.version;
|
||||||
|
}
|
||||||
|
if (browser.chrome) {
|
||||||
|
browser.webkit = true;
|
||||||
|
} else if (browser.webkit) {
|
||||||
|
browser.safari = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.each(function() {
|
||||||
|
var $$, textarea, levels, scrollPosition, caretPosition, caretOffset,
|
||||||
|
clicked, hash, header, footer, previewWindow, template, iFrame, abort;
|
||||||
|
$$ = $(this);
|
||||||
|
textarea = this;
|
||||||
|
levels = [];
|
||||||
|
abort = false;
|
||||||
|
scrollPosition = caretPosition = 0;
|
||||||
|
caretOffset = -1;
|
||||||
|
|
||||||
|
options.previewParserPath = localize(options.previewParserPath);
|
||||||
|
options.previewTemplatePath = localize(options.previewTemplatePath);
|
||||||
|
|
||||||
|
if (method) {
|
||||||
|
switch(method) {
|
||||||
|
case 'remove':
|
||||||
|
remove();
|
||||||
|
break;
|
||||||
|
case 'insert':
|
||||||
|
markup(params);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
$.error('Method ' + method + ' does not exist on jQuery.markItUp');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// apply the computed path to ~/
|
||||||
|
function localize(data, inText) {
|
||||||
|
if (inText) {
|
||||||
|
return data.replace(/("|')~\//g, "$1"+options.root);
|
||||||
|
}
|
||||||
|
return data.replace(/^~\//, options.root);
|
||||||
|
}
|
||||||
|
|
||||||
|
// init and build editor
|
||||||
|
function init() {
|
||||||
|
id = ''; nameSpace = '';
|
||||||
|
if (options.id) {
|
||||||
|
id = 'id="'+options.id+'"';
|
||||||
|
} else if ($$.attr("id")) {
|
||||||
|
id = 'id="markItUp'+($$.attr("id").substr(0, 1).toUpperCase())+($$.attr("id").substr(1))+'"';
|
||||||
|
|
||||||
|
}
|
||||||
|
if (options.nameSpace) {
|
||||||
|
nameSpace = 'class="'+options.nameSpace+'"';
|
||||||
|
}
|
||||||
|
$$.wrap('<div '+nameSpace+'></div>');
|
||||||
|
$$.wrap('<div '+id+' class="markItUp"></div>');
|
||||||
|
$$.wrap('<div class="markItUpContainer"></div>');
|
||||||
|
$$.addClass("markItUpEditor");
|
||||||
|
|
||||||
|
// add the header before the textarea
|
||||||
|
header = $('<div class="markItUpHeader"></div>').insertBefore($$);
|
||||||
|
$(dropMenus(options.markupSet)).appendTo(header);
|
||||||
|
|
||||||
|
// add the footer after the textarea
|
||||||
|
footer = $('<div class="markItUpFooter"></div>').insertAfter($$);
|
||||||
|
|
||||||
|
// add the resize handle after textarea
|
||||||
|
if (options.resizeHandle === true && browser.safari !== true) {
|
||||||
|
resizeHandle = $('<div class="markItUpResizeHandle"></div>')
|
||||||
|
.insertAfter($$)
|
||||||
|
.bind("mousedown.markItUp", function(e) {
|
||||||
|
var h = $$.height(), y = e.clientY, mouseMove, mouseUp;
|
||||||
|
mouseMove = function(e) {
|
||||||
|
$$.css("height", Math.max(20, e.clientY+h-y)+"px");
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
mouseUp = function(e) {
|
||||||
|
$("html").unbind("mousemove.markItUp", mouseMove).unbind("mouseup.markItUp", mouseUp);
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
$("html").bind("mousemove.markItUp", mouseMove).bind("mouseup.markItUp", mouseUp);
|
||||||
|
});
|
||||||
|
footer.append(resizeHandle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// listen key events
|
||||||
|
$$.bind('keydown.markItUp', keyPressed).bind('keyup', keyPressed);
|
||||||
|
|
||||||
|
// bind an event to catch external calls
|
||||||
|
$$.bind("insertion.markItUp", function(e, settings) {
|
||||||
|
if (settings.target !== false) {
|
||||||
|
get();
|
||||||
|
}
|
||||||
|
if (textarea === $.markItUp.focused) {
|
||||||
|
markup(settings);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// remember the last focus
|
||||||
|
$$.bind('focus.markItUp', function() {
|
||||||
|
$.markItUp.focused = this;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (options.previewInElement) {
|
||||||
|
refreshPreview();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// recursively build header with dropMenus from markupset
|
||||||
|
function dropMenus(markupSet) {
|
||||||
|
var ul = $('<ul></ul>'), i = 0;
|
||||||
|
$('li:hover > ul', ul).css('display', 'block');
|
||||||
|
$.each(markupSet, function() {
|
||||||
|
var button = this, t = '', title, li, j;
|
||||||
|
title = (button.key) ? (button.name||'')+' [Ctrl+'+button.key+']' : (button.name||'');
|
||||||
|
key = (button.key) ? 'accesskey="'+button.key+'"' : '';
|
||||||
|
if (button.separator) {
|
||||||
|
li = $('<li class="markItUpSeparator">'+(button.separator||'')+'</li>').appendTo(ul);
|
||||||
|
} else {
|
||||||
|
i++;
|
||||||
|
for (j = levels.length -1; j >= 0; j--) {
|
||||||
|
t += levels[j]+"-";
|
||||||
|
}
|
||||||
|
li = $('<li class="markItUpButton markItUpButton'+t+(i)+' '+(button.className||'')+'"><a href="" '+key+' title="'+title+'">'+(button.name||'')+'</a></li>')
|
||||||
|
.bind("contextmenu.markItUp", function() { // prevent contextmenu on mac and allow ctrl+click
|
||||||
|
return false;
|
||||||
|
}).bind('click.markItUp', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
}).bind("focusin.markItUp", function(){
|
||||||
|
$$.focus();
|
||||||
|
}).bind('mouseup', function() {
|
||||||
|
if (button.call) {
|
||||||
|
eval(button.call)();
|
||||||
|
}
|
||||||
|
setTimeout(function() { markup(button) },1);
|
||||||
|
return false;
|
||||||
|
}).bind('mouseenter.markItUp', function() {
|
||||||
|
$('> ul', this).show();
|
||||||
|
$(document).one('click', function() { // close dropmenu if click outside
|
||||||
|
$('ul ul', header).hide();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}).bind('mouseleave.markItUp', function() {
|
||||||
|
$('> ul', this).hide();
|
||||||
|
}).appendTo(ul);
|
||||||
|
if (button.dropMenu) {
|
||||||
|
levels.push(i);
|
||||||
|
$(li).addClass('markItUpDropMenu').append(dropMenus(button.dropMenu));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
levels.pop();
|
||||||
|
return ul;
|
||||||
|
}
|
||||||
|
|
||||||
|
// markItUp! markups
|
||||||
|
function magicMarkups(string) {
|
||||||
|
if (string) {
|
||||||
|
string = string.toString();
|
||||||
|
string = string.replace(/\(\!\(([\s\S]*?)\)\!\)/g,
|
||||||
|
function(x, a) {
|
||||||
|
var b = a.split('|!|');
|
||||||
|
if (altKey === true) {
|
||||||
|
return (b[1] !== undefined) ? b[1] : b[0];
|
||||||
|
} else {
|
||||||
|
return (b[1] === undefined) ? "" : b[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// [![prompt]!], [![prompt:!:value]!]
|
||||||
|
string = string.replace(/\[\!\[([\s\S]*?)\]\!\]/g,
|
||||||
|
function(x, a) {
|
||||||
|
var b = a.split(':!:');
|
||||||
|
if (abort === true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
value = prompt(b[0], (b[1]) ? b[1] : '');
|
||||||
|
if (value === null) {
|
||||||
|
abort = true;
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare action
|
||||||
|
function prepare(action) {
|
||||||
|
if ($.isFunction(action)) {
|
||||||
|
action = action(hash);
|
||||||
|
}
|
||||||
|
return magicMarkups(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
// build block to insert
|
||||||
|
function build(string) {
|
||||||
|
var openWith = prepare(clicked.openWith);
|
||||||
|
var placeHolder = prepare(clicked.placeHolder);
|
||||||
|
var replaceWith = prepare(clicked.replaceWith);
|
||||||
|
var closeWith = prepare(clicked.closeWith);
|
||||||
|
var openBlockWith = prepare(clicked.openBlockWith);
|
||||||
|
var closeBlockWith = prepare(clicked.closeBlockWith);
|
||||||
|
var multiline = clicked.multiline;
|
||||||
|
|
||||||
|
if (replaceWith !== "") {
|
||||||
|
block = openWith + replaceWith + closeWith;
|
||||||
|
} else if (selection === '' && placeHolder !== '') {
|
||||||
|
block = openWith + placeHolder + closeWith;
|
||||||
|
} else {
|
||||||
|
string = string || selection;
|
||||||
|
|
||||||
|
var lines = [string], blocks = [];
|
||||||
|
|
||||||
|
if (multiline === true) {
|
||||||
|
lines = string.split(/\r?\n/);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (var l = 0; l < lines.length; l++) {
|
||||||
|
line = lines[l];
|
||||||
|
var trailingSpaces;
|
||||||
|
if (trailingSpaces = line.match(/ *$/)) {
|
||||||
|
blocks.push(openWith + line.replace(/ *$/g, '') + closeWith + trailingSpaces);
|
||||||
|
} else {
|
||||||
|
blocks.push(openWith + line + closeWith);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
block = blocks.join("\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
block = openBlockWith + block + closeBlockWith;
|
||||||
|
|
||||||
|
return { block:block,
|
||||||
|
openBlockWith:openBlockWith,
|
||||||
|
openWith:openWith,
|
||||||
|
replaceWith:replaceWith,
|
||||||
|
placeHolder:placeHolder,
|
||||||
|
closeWith:closeWith,
|
||||||
|
closeBlockWith:closeBlockWith
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// define markup to insert
|
||||||
|
function markup(button) {
|
||||||
|
var len, j, n, i;
|
||||||
|
hash = clicked = button;
|
||||||
|
get();
|
||||||
|
$.extend(hash, { line:"",
|
||||||
|
root:options.root,
|
||||||
|
textarea:textarea,
|
||||||
|
selection:(selection||''),
|
||||||
|
caretPosition:caretPosition,
|
||||||
|
ctrlKey:ctrlKey,
|
||||||
|
shiftKey:shiftKey,
|
||||||
|
altKey:altKey
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// callbacks before insertion
|
||||||
|
prepare(options.beforeInsert);
|
||||||
|
prepare(clicked.beforeInsert);
|
||||||
|
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
|
||||||
|
prepare(clicked.beforeMultiInsert);
|
||||||
|
}
|
||||||
|
$.extend(hash, { line:1 });
|
||||||
|
|
||||||
|
if ((ctrlKey === true && shiftKey === true)) {
|
||||||
|
lines = selection.split(/\r?\n/);
|
||||||
|
for (j = 0, n = lines.length, i = 0; i < n; i++) {
|
||||||
|
if ($.trim(lines[i]) !== '') {
|
||||||
|
$.extend(hash, { line:++j, selection:lines[i] } );
|
||||||
|
lines[i] = build(lines[i]).block;
|
||||||
|
} else {
|
||||||
|
lines[i] = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
string = { block:lines.join('\n')};
|
||||||
|
start = caretPosition;
|
||||||
|
len = string.block.length + ((browser.opera) ? n-1 : 0);
|
||||||
|
} else if (ctrlKey === true) {
|
||||||
|
string = build(selection);
|
||||||
|
start = caretPosition + string.openWith.length;
|
||||||
|
len = string.block.length - string.openWith.length - string.closeWith.length;
|
||||||
|
len = len - (string.block.match(/ $/) ? 1 : 0);
|
||||||
|
len -= fixIeBug(string.block);
|
||||||
|
} else if (shiftKey === true) {
|
||||||
|
string = build(selection);
|
||||||
|
start = caretPosition;
|
||||||
|
len = string.block.length;
|
||||||
|
len -= fixIeBug(string.block);
|
||||||
|
} else {
|
||||||
|
string = build(selection);
|
||||||
|
start = caretPosition + string.block.length ;
|
||||||
|
len = 0;
|
||||||
|
start -= fixIeBug(string.block);
|
||||||
|
}
|
||||||
|
if ((selection === '' && string.replaceWith === '')) {
|
||||||
|
caretOffset += fixOperaBug(string.block);
|
||||||
|
|
||||||
|
start = caretPosition + string.openBlockWith.length + string.openWith.length;
|
||||||
|
len = string.block.length - string.openBlockWith.length - string.openWith.length - string.closeWith.length - string.closeBlockWith.length;
|
||||||
|
|
||||||
|
caretOffset = $$.val().substring(caretPosition, $$.val().length).length;
|
||||||
|
caretOffset -= fixOperaBug($$.val().substring(0, caretPosition));
|
||||||
|
}
|
||||||
|
$.extend(hash, { caretPosition:caretPosition, scrollPosition:scrollPosition } );
|
||||||
|
|
||||||
|
if (string.block !== selection && abort === false) {
|
||||||
|
insert(string.block);
|
||||||
|
set(start, len);
|
||||||
|
} else {
|
||||||
|
caretOffset = -1;
|
||||||
|
}
|
||||||
|
get();
|
||||||
|
|
||||||
|
$.extend(hash, { line:'', selection:selection });
|
||||||
|
|
||||||
|
// callbacks after insertion
|
||||||
|
if ((ctrlKey === true && shiftKey === true) || button.multiline === true) {
|
||||||
|
prepare(clicked.afterMultiInsert);
|
||||||
|
}
|
||||||
|
prepare(clicked.afterInsert);
|
||||||
|
prepare(options.afterInsert);
|
||||||
|
|
||||||
|
// refresh preview if opened
|
||||||
|
if (previewWindow && options.previewAutoRefresh) {
|
||||||
|
refreshPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
// reinit keyevent
|
||||||
|
shiftKey = altKey = ctrlKey = abort = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Substract linefeed in Opera
|
||||||
|
function fixOperaBug(string) {
|
||||||
|
if (browser.opera) {
|
||||||
|
return string.length - string.replace(/\n*/g, '').length;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
// Substract linefeed in IE
|
||||||
|
function fixIeBug(string) {
|
||||||
|
if (browser.msie) {
|
||||||
|
return string.length - string.replace(/\r*/g, '').length;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// add markup
|
||||||
|
function insert(block) {
|
||||||
|
if (document.selection) {
|
||||||
|
var newSelection = document.selection.createRange();
|
||||||
|
newSelection.text = block;
|
||||||
|
} else {
|
||||||
|
textarea.value = textarea.value.substring(0, caretPosition) + block + textarea.value.substring(caretPosition + selection.length, textarea.value.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set a selection
|
||||||
|
function set(start, len) {
|
||||||
|
if (textarea.createTextRange){
|
||||||
|
// quick fix to make it work on Opera 9.5
|
||||||
|
if (browser.opera && browser.version >= 9.5 && len == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
range = textarea.createTextRange();
|
||||||
|
range.collapse(true);
|
||||||
|
range.moveStart('character', start);
|
||||||
|
range.moveEnd('character', len);
|
||||||
|
range.select();
|
||||||
|
} else if (textarea.setSelectionRange ){
|
||||||
|
textarea.setSelectionRange(start, start + len);
|
||||||
|
}
|
||||||
|
textarea.scrollTop = scrollPosition;
|
||||||
|
textarea.focus();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get the selection
|
||||||
|
function get() {
|
||||||
|
textarea.focus();
|
||||||
|
|
||||||
|
scrollPosition = textarea.scrollTop;
|
||||||
|
if (document.selection) {
|
||||||
|
selection = document.selection.createRange().text;
|
||||||
|
if (browser.msie) { // ie
|
||||||
|
var range = document.selection.createRange(), rangeCopy = range.duplicate();
|
||||||
|
rangeCopy.moveToElementText(textarea);
|
||||||
|
caretPosition = -1;
|
||||||
|
while(rangeCopy.inRange(range)) {
|
||||||
|
rangeCopy.moveStart('character');
|
||||||
|
caretPosition ++;
|
||||||
|
}
|
||||||
|
} else { // opera
|
||||||
|
caretPosition = textarea.selectionStart;
|
||||||
|
}
|
||||||
|
} else { // gecko & webkit
|
||||||
|
caretPosition = textarea.selectionStart;
|
||||||
|
|
||||||
|
selection = textarea.value.substring(caretPosition, textarea.selectionEnd);
|
||||||
|
}
|
||||||
|
return selection;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open preview window
|
||||||
|
function preview() {
|
||||||
|
if (typeof options.previewHandler === 'function') {
|
||||||
|
previewWindow = true;
|
||||||
|
} else if (options.previewInElement) {
|
||||||
|
previewWindow = $(options.previewInElement);
|
||||||
|
} else if (!previewWindow || previewWindow.closed) {
|
||||||
|
if (options.previewInWindow) {
|
||||||
|
previewWindow = window.open('', 'preview', options.previewInWindow);
|
||||||
|
$(window).unload(function() {
|
||||||
|
previewWindow.close();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
iFrame = $('<iframe class="markItUpPreviewFrame"></iframe>');
|
||||||
|
if (options.previewPosition == 'after') {
|
||||||
|
iFrame.insertAfter(footer);
|
||||||
|
} else {
|
||||||
|
iFrame.insertBefore(header);
|
||||||
|
}
|
||||||
|
previewWindow = iFrame[iFrame.length - 1].contentWindow || frame[iFrame.length - 1];
|
||||||
|
}
|
||||||
|
} else if (altKey === true) {
|
||||||
|
if (iFrame) {
|
||||||
|
iFrame.remove();
|
||||||
|
} else {
|
||||||
|
previewWindow.close();
|
||||||
|
}
|
||||||
|
previewWindow = iFrame = false;
|
||||||
|
}
|
||||||
|
if (!options.previewAutoRefresh) {
|
||||||
|
refreshPreview();
|
||||||
|
}
|
||||||
|
if (options.previewInWindow) {
|
||||||
|
previewWindow.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// refresh Preview window
|
||||||
|
function refreshPreview() {
|
||||||
|
renderPreview();
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderPreview() {
|
||||||
|
var phtml;
|
||||||
|
if (options.previewHandler && typeof options.previewHandler === 'function') {
|
||||||
|
options.previewHandler( $$.val() );
|
||||||
|
} else if (options.previewParser && typeof options.previewParser === 'function') {
|
||||||
|
var data = options.previewParser( $$.val() );
|
||||||
|
writeInPreview(localize(data, 1) );
|
||||||
|
} else if (options.previewParserPath !== '') {
|
||||||
|
$.ajax({
|
||||||
|
type: 'POST',
|
||||||
|
dataType: 'text',
|
||||||
|
global: false,
|
||||||
|
url: options.previewParserPath,
|
||||||
|
data: options.previewParserVar+'='+encodeURIComponent($$.val()),
|
||||||
|
success: function(data) {
|
||||||
|
writeInPreview( localize(data, 1) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
if (!template) {
|
||||||
|
$.ajax({
|
||||||
|
url: options.previewTemplatePath,
|
||||||
|
dataType: 'text',
|
||||||
|
global: false,
|
||||||
|
success: function(data) {
|
||||||
|
writeInPreview( localize(data, 1).replace(/<!-- content -->/g, $$.val()) );
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeInPreview(data) {
|
||||||
|
if (options.previewInElement) {
|
||||||
|
$(options.previewInElement).html(data);
|
||||||
|
} else if (previewWindow && previewWindow.document) {
|
||||||
|
try {
|
||||||
|
sp = previewWindow.document.documentElement.scrollTop
|
||||||
|
} catch(e) {
|
||||||
|
sp = 0;
|
||||||
|
}
|
||||||
|
previewWindow.document.open();
|
||||||
|
previewWindow.document.write(data);
|
||||||
|
previewWindow.document.close();
|
||||||
|
previewWindow.document.documentElement.scrollTop = sp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set keys pressed
|
||||||
|
function keyPressed(e) {
|
||||||
|
shiftKey = e.shiftKey;
|
||||||
|
altKey = e.altKey;
|
||||||
|
ctrlKey = (!(e.altKey && e.ctrlKey)) ? (e.ctrlKey || e.metaKey) : false;
|
||||||
|
|
||||||
|
if (e.type === 'keydown') {
|
||||||
|
if (ctrlKey === true) {
|
||||||
|
li = $('a[accesskey="'+((e.keyCode == 13) ? '\\n' : String.fromCharCode(e.keyCode))+'"]', header).parent('li');
|
||||||
|
if (li.length !== 0) {
|
||||||
|
ctrlKey = false;
|
||||||
|
setTimeout(function() {
|
||||||
|
li.triggerHandler('mouseup');
|
||||||
|
},1);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.keyCode === 13 || e.keyCode === 10) { // Enter key
|
||||||
|
if (ctrlKey === true) { // Enter + Ctrl
|
||||||
|
ctrlKey = false;
|
||||||
|
markup(options.onCtrlEnter);
|
||||||
|
return options.onCtrlEnter.keepDefault;
|
||||||
|
} else if (shiftKey === true) { // Enter + Shift
|
||||||
|
shiftKey = false;
|
||||||
|
markup(options.onShiftEnter);
|
||||||
|
return options.onShiftEnter.keepDefault;
|
||||||
|
} else { // only Enter
|
||||||
|
markup(options.onEnter);
|
||||||
|
return options.onEnter.keepDefault;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (e.keyCode === 9) { // Tab key
|
||||||
|
if (shiftKey == true || ctrlKey == true || altKey == true) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (caretOffset !== -1) {
|
||||||
|
get();
|
||||||
|
caretOffset = $$.val().length - caretOffset;
|
||||||
|
set(caretOffset, 0);
|
||||||
|
caretOffset = -1;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
markup(options.onTab);
|
||||||
|
return options.onTab.keepDefault;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function remove() {
|
||||||
|
$$.unbind(".markItUp").removeClass('markItUpEditor');
|
||||||
|
$$.parent('div').parent('div.markItUp').parent('div').replaceWith($$);
|
||||||
|
$$.data('markItUp', null);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
$.fn.markItUpRemove = function() {
|
||||||
|
return this.each(function() {
|
||||||
|
$(this).markItUp('remove');
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
$.markItUp = function(settings) {
|
||||||
|
var options = { target:false };
|
||||||
|
$.extend(options, settings);
|
||||||
|
if (options.target) {
|
||||||
|
return $(options.target).each(function() {
|
||||||
|
$(this).focus();
|
||||||
|
$(this).trigger('insertion', [options]);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$('textarea').trigger('insertion', [options]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
})(jQuery);
|
BIN
styles/bootstrap/markitup/sets/default/images/bold.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
styles/bootstrap/markitup/sets/default/images/clean.png
Normal file
After Width: | Height: | Size: 667 B |
BIN
styles/bootstrap/markitup/sets/default/images/image.png
Normal file
After Width: | Height: | Size: 516 B |
BIN
styles/bootstrap/markitup/sets/default/images/italic.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
styles/bootstrap/markitup/sets/default/images/link.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
styles/bootstrap/markitup/sets/default/images/list-bullet.png
Normal file
After Width: | Height: | Size: 344 B |
BIN
styles/bootstrap/markitup/sets/default/images/list-numeric.png
Normal file
After Width: | Height: | Size: 357 B |
BIN
styles/bootstrap/markitup/sets/default/images/picture.png
Normal file
After Width: | Height: | Size: 606 B |
BIN
styles/bootstrap/markitup/sets/default/images/preview.png
Normal file
After Width: | Height: | Size: 537 B |
BIN
styles/bootstrap/markitup/sets/default/images/stroke.png
Normal file
After Width: | Height: | Size: 269 B |
30
styles/bootstrap/markitup/sets/default/set.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// markItUp!
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2011 Jay Salvat
|
||||||
|
// http://markitup.jaysalvat.com/
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Html tags
|
||||||
|
// http://en.wikipedia.org/wiki/html
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// Basic set. Feel free to add more tags
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
var mySettings = {
|
||||||
|
onShiftEnter: {keepDefault:false, replaceWith:'<br />\n'},
|
||||||
|
onCtrlEnter: {keepDefault:false, openWith:'\n<p>', closeWith:'</p>'},
|
||||||
|
onTab: {keepDefault:false, replaceWith:' '},
|
||||||
|
markupSet: [
|
||||||
|
{name:'Bold', key:'B', openWith:'(!(<strong>|!|<b>)!)', closeWith:'(!(</strong>|!|</b>)!)' },
|
||||||
|
{name:'Italic', key:'I', openWith:'(!(<em>|!|<i>)!)', closeWith:'(!(</em>|!|</i>)!)' },
|
||||||
|
{name:'Stroke through', key:'S', openWith:'<del>', closeWith:'</del>' },
|
||||||
|
{separator:'---------------' },
|
||||||
|
{name:'Bulleted List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ul>\n', closeBlockWith:'\n</ul>'},
|
||||||
|
{name:'Numeric List', openWith:' <li>', closeWith:'</li>', multiline:true, openBlockWith:'<ol>\n', closeBlockWith:'\n</ol>'},
|
||||||
|
{separator:'---------------' },
|
||||||
|
{name:'Picture', key:'P', replaceWith:'<img src="[![Source:!:http://]!]" alt="[![Alternative text]!]" />' },
|
||||||
|
{name:'Link', key:'L', openWith:'<a href="[![Link:!:http://]!]"(!( title="[![Title]!]")!)>', closeWith:'</a>', placeHolder:'Your text to link...' },
|
||||||
|
{separator:'---------------' },
|
||||||
|
{name:'Clean', className:'clean', replaceWith:function(markitup) { return markitup.selection.replace(/<(.*?)>/g, "") } }/*,
|
||||||
|
{name:'Preview', className:'preview', call:'preview'}*/
|
||||||
|
]
|
||||||
|
}
|
34
styles/bootstrap/markitup/sets/default/style.css
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
// markItUp!
|
||||||
|
// By Jay Salvat - http://markitup.jaysalvat.com/
|
||||||
|
// ------------------------------------------------------------------*/
|
||||||
|
.markItUp .markItUpButton1 a {
|
||||||
|
background-image:url(images/bold.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton2 a {
|
||||||
|
background-image:url(images/italic.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton3 a {
|
||||||
|
background-image:url(images/stroke.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton4 a {
|
||||||
|
background-image:url(images/list-bullet.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton5 a {
|
||||||
|
background-image:url(images/list-numeric.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton6 a {
|
||||||
|
background-image:url(images/picture.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton7 a {
|
||||||
|
background-image:url(images/link.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton8 a {
|
||||||
|
background-image:url(images/clean.png);
|
||||||
|
}
|
||||||
|
.markItUp .preview a {
|
||||||
|
background-image:url(images/preview.png);
|
||||||
|
}
|
BIN
styles/bootstrap/markitup/sets/markdown/images/bold.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/clean.png
Normal file
After Width: | Height: | Size: 667 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/code.png
Normal file
After Width: | Height: | Size: 859 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/disk.png
Normal file
After Width: | Height: | Size: 620 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/h1.png
Normal file
After Width: | Height: | Size: 276 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/h2.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/h3.png
Normal file
After Width: | Height: | Size: 306 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/h4.png
Normal file
After Width: | Height: | Size: 293 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/h5.png
Normal file
After Width: | Height: | Size: 304 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/h6.png
Normal file
After Width: | Height: | Size: 310 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/image.png
Normal file
After Width: | Height: | Size: 516 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/italic.png
Normal file
After Width: | Height: | Size: 223 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/link.png
Normal file
After Width: | Height: | Size: 343 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/list-bullet.png
Normal file
After Width: | Height: | Size: 344 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/list-numeric.png
Normal file
After Width: | Height: | Size: 357 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/picture.png
Normal file
After Width: | Height: | Size: 606 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/preview.png
Normal file
After Width: | Height: | Size: 537 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/quotes.png
Normal file
After Width: | Height: | Size: 743 B |
BIN
styles/bootstrap/markitup/sets/markdown/images/stroke.png
Normal file
After Width: | Height: | Size: 269 B |
11
styles/bootstrap/markitup/sets/markdown/readme.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
Markup language:
|
||||||
|
Markdown
|
||||||
|
|
||||||
|
Description:
|
||||||
|
A basic Markdown markup set with Headings, Bold, Italic, Picture, Link, List, Quotes, Code, Preview button.
|
||||||
|
|
||||||
|
Install:
|
||||||
|
- Download the zip file
|
||||||
|
- Unzip it in your markItUp! sets folder
|
||||||
|
- Modify your JS link to point at this set.js
|
||||||
|
- Modify your CSS link to point at this style.css
|
65
styles/bootstrap/markitup/sets/markdown/set.js
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// markItUp!
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Copyright (C) 2008 Jay Salvat
|
||||||
|
// http://markitup.jaysalvat.com/
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// MarkDown tags example
|
||||||
|
// http://en.wikipedia.org/wiki/Markdown
|
||||||
|
// http://daringfireball.net/projects/markdown/
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
// Feel free to add more tags
|
||||||
|
// -------------------------------------------------------------------
|
||||||
|
mySettings = {
|
||||||
|
previewParserPath: '',
|
||||||
|
onShiftEnter: {keepDefault:false, openWith:'\n\n'},
|
||||||
|
markupSet: [
|
||||||
|
{name:'First Level Heading', key:'1', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '=') } },
|
||||||
|
{name:'Second Level Heading', key:'2', placeHolder:'Your title here...', closeWith:function(markItUp) { return miu.markdownTitle(markItUp, '-') } },
|
||||||
|
{name:'Heading 3', key:'3', openWith:'### ', placeHolder:'Your title here...' },
|
||||||
|
{name:'Heading 4', key:'4', openWith:'#### ', placeHolder:'Your title here...' },
|
||||||
|
{name:'Heading 5', key:'5', openWith:'##### ', placeHolder:'Your title here...' },
|
||||||
|
{name:'Heading 6', key:'6', openWith:'###### ', placeHolder:'Your title here...' },
|
||||||
|
{separator:'---------------' },
|
||||||
|
{name:'Bold', key:'B', openWith:'**', closeWith:'**'},
|
||||||
|
{name:'Italic', key:'I', openWith:'_', closeWith:'_'},
|
||||||
|
{separator:'---------------' },
|
||||||
|
{name:'Bulleted List', openWith:'- ' },
|
||||||
|
{name:'Numeric List', openWith:function(markItUp) {
|
||||||
|
return markItUp.line+'. ';
|
||||||
|
}},
|
||||||
|
{separator:'---------------' },
|
||||||
|
{name:'Picture', key:'P', replaceWith:'![[![Alternative text]!]]([![Url:!:http://]!] "[![Title]!]")'},
|
||||||
|
{name:'Link', key:'L', openWith:'[', closeWith:']([![Url:!:http://]!] "[![Title]!]")', placeHolder:'Your text to link here...' },
|
||||||
|
{separator:'---------------'},
|
||||||
|
{name:'Quotes', openWith:'> '},
|
||||||
|
{name:'Code Block / Code', openWith:'(!(\t|!|`)!)', closeWith:'(!(`)!)'}/*,
|
||||||
|
{separator:'---------------'},
|
||||||
|
{name:'Save', className:'save', beforeInsert:function(markItUp) { miu.save(markItUp) } },
|
||||||
|
{name:'Preview', call:'preview', className:"preview"} */
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
// mIu nameSpace to avoid conflict.
|
||||||
|
miu = {
|
||||||
|
markdownTitle: function(markItUp, char) {
|
||||||
|
heading = '';
|
||||||
|
n = $.trim(markItUp.selection||markItUp.placeHolder).length;
|
||||||
|
for(i = 0; i < n; i++) {
|
||||||
|
heading += char;
|
||||||
|
}
|
||||||
|
return '\n'+heading;
|
||||||
|
},
|
||||||
|
save: function(markItUp) {
|
||||||
|
$.post("../op/op.EditOnline.php", $('#form1').serialize(), function(response) {
|
||||||
|
noty({
|
||||||
|
text: response.message,
|
||||||
|
type: response.success === true ? 'success' : 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
}, "json");
|
||||||
|
}
|
||||||
|
}
|
58
styles/bootstrap/markitup/sets/markdown/style.css
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
// markItUp!
|
||||||
|
// By Jay Salvat - http://markitup.jaysalvat.com/
|
||||||
|
// ------------------------------------------------------------------*/
|
||||||
|
.markItUp .markItUpButton1 a {
|
||||||
|
background-image:url(images/h1.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton2 a {
|
||||||
|
background-image:url(images/h2.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton3 a {
|
||||||
|
background-image:url(images/h3.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton4 a {
|
||||||
|
background-image:url(images/h4.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton5 a {
|
||||||
|
background-image:url(images/h5.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton6 a {
|
||||||
|
background-image:url(images/h6.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton7 a {
|
||||||
|
background-image:url(images/bold.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton8 a {
|
||||||
|
background-image:url(images/italic.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton9 a {
|
||||||
|
background-image:url(images/list-bullet.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton10 a {
|
||||||
|
background-image:url(images/list-numeric.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton11 a {
|
||||||
|
background-image:url(images/picture.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton12 a {
|
||||||
|
background-image:url(images/link.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .markItUpButton13 a {
|
||||||
|
background-image:url(images/quotes.png);
|
||||||
|
}
|
||||||
|
.markItUp .markItUpButton14 a {
|
||||||
|
background-image:url(images/code.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .preview a {
|
||||||
|
background-image:url(images/preview.png);
|
||||||
|
}
|
||||||
|
|
||||||
|
.markItUp .save a {
|
||||||
|
background-image:url(images/disk.png);
|
||||||
|
}
|
BIN
styles/bootstrap/markitup/skins/markitup/images/bg-container.png
Normal file
After Width: | Height: | Size: 322 B |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.7 KiB |
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 1.5 KiB |
BIN
styles/bootstrap/markitup/skins/markitup/images/bg-editor.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
styles/bootstrap/markitup/skins/markitup/images/handle.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
styles/bootstrap/markitup/skins/markitup/images/menu.png
Normal file
After Width: | Height: | Size: 254 B |
BIN
styles/bootstrap/markitup/skins/markitup/images/submenu.png
Normal file
After Width: | Height: | Size: 240 B |
147
styles/bootstrap/markitup/skins/markitup/style.css
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
// markItUp! Universal MarkUp Engine, JQuery plugin
|
||||||
|
// By Jay Salvat - http://markitup.jaysalvat.com/
|
||||||
|
// ------------------------------------------------------------------*/
|
||||||
|
.markItUp * {
|
||||||
|
margin:0px; padding:0px;
|
||||||
|
outline:none;
|
||||||
|
}
|
||||||
|
.markItUp a:link,
|
||||||
|
.markItUp a:visited {
|
||||||
|
color:#000;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
.markItUp {
|
||||||
|
width:700px;
|
||||||
|
margin:5px 0 5px 0;
|
||||||
|
border:5px solid #F5F5F5;
|
||||||
|
}
|
||||||
|
.markItUpContainer {
|
||||||
|
border:1px solid #3C769D;
|
||||||
|
background:#FFF url(images/bg-container.png) repeat-x top left;
|
||||||
|
padding:5px 5px 2px 5px;
|
||||||
|
font:11px Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
.markItUpEditor {
|
||||||
|
font:12px 'Courier New', Courier, monospace;
|
||||||
|
padding:5px 5px 5px 35px;
|
||||||
|
border:3px solid #3C769D;
|
||||||
|
width:643px;
|
||||||
|
height:320px;
|
||||||
|
background:#FFF url(images/bg-editor.png) no-repeat;
|
||||||
|
clear:both;
|
||||||
|
line-height:18px;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
.markItUpPreviewFrame {
|
||||||
|
overflow:auto;
|
||||||
|
background-color:#FFFFFF;
|
||||||
|
border:1px solid #3C769D;
|
||||||
|
width:99.9%;
|
||||||
|
height:300px;
|
||||||
|
margin:5px 0;
|
||||||
|
}
|
||||||
|
.markItUpFooter {
|
||||||
|
width:100%;
|
||||||
|
cursor:n-resize;
|
||||||
|
}
|
||||||
|
.markItUpResizeHandle {
|
||||||
|
overflow:hidden;
|
||||||
|
width:22px; height:5px;
|
||||||
|
margin-left:auto;
|
||||||
|
margin-right:auto;
|
||||||
|
background-image:url(images/handle.png);
|
||||||
|
cursor:n-resize;
|
||||||
|
}
|
||||||
|
/***************************************************************************************/
|
||||||
|
/* first row of buttons */
|
||||||
|
.markItUpHeader ul li {
|
||||||
|
list-style:none;
|
||||||
|
float:left;
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul li ul{
|
||||||
|
display:none;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul li:hover > ul{
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul .markItUpDropMenu {
|
||||||
|
background:transparent url(images/menu.png) no-repeat 115% 50%;
|
||||||
|
margin-right:5px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul .markItUpDropMenu li {
|
||||||
|
margin-right:0px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul .markItUpSeparator {
|
||||||
|
margin:0 10px;
|
||||||
|
width:1px;
|
||||||
|
height:16px;
|
||||||
|
overflow:hidden;
|
||||||
|
background-color:#CCC;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul .markItUpSeparator {
|
||||||
|
width:auto; height:1px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
/* next rows of buttons */
|
||||||
|
.markItUpHeader ul ul {
|
||||||
|
display:none;
|
||||||
|
position:absolute;
|
||||||
|
top:18px; left:0px;
|
||||||
|
background:#F5F5F5;
|
||||||
|
border:1px solid #3C769D;
|
||||||
|
height:inherit;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul li {
|
||||||
|
float:none;
|
||||||
|
border-bottom:1px solid #3C769D;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul .markItUpDropMenu {
|
||||||
|
background:#F5F5F5 url(images/submenu.png) no-repeat 100% 50%;
|
||||||
|
}
|
||||||
|
/* next rows of buttons */
|
||||||
|
.markItUpHeader ul ul ul {
|
||||||
|
position:absolute;
|
||||||
|
top:-1px; left:150px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul ul li {
|
||||||
|
float:none;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul a {
|
||||||
|
display:block;
|
||||||
|
width:16px; height:16px;
|
||||||
|
text-indent:-10000px;
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
padding:3px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul a {
|
||||||
|
display:block;
|
||||||
|
padding-left:0px;
|
||||||
|
text-indent:0;
|
||||||
|
width:120px;
|
||||||
|
padding:5px 5px 5px 25px;
|
||||||
|
background-position:2px 50%;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul a:hover {
|
||||||
|
color:#FFF;
|
||||||
|
background-color:#3C769D;
|
||||||
|
}
|
||||||
|
/***************************************************************************************/
|
||||||
|
.html .markItUpEditor {
|
||||||
|
background-image:url(images/bg-editor-html.png);
|
||||||
|
}
|
||||||
|
.markdown .markItUpEditor {
|
||||||
|
background-image:url(images/bg-editor-markdown.png);
|
||||||
|
}
|
||||||
|
.textile .markItUpEditor {
|
||||||
|
background-image:url(images/bg-editor-textile.png);
|
||||||
|
}
|
||||||
|
.bbcode .markItUpEditor {
|
||||||
|
background-image:url(images/bg-editor-bbcode.png);
|
||||||
|
}
|
||||||
|
.wiki .markItUpEditor,
|
||||||
|
.dotclear .markItUpEditor {
|
||||||
|
background-image:url(images/bg-editor-wiki.png);
|
||||||
|
}
|
BIN
styles/bootstrap/markitup/skins/simple/images/handle.png
Normal file
After Width: | Height: | Size: 258 B |
BIN
styles/bootstrap/markitup/skins/simple/images/menu.png
Normal file
After Width: | Height: | Size: 26 KiB |
BIN
styles/bootstrap/markitup/skins/simple/images/submenu.png
Normal file
After Width: | Height: | Size: 240 B |
118
styles/bootstrap/markitup/skins/simple/style.css
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
/* -------------------------------------------------------------------
|
||||||
|
// markItUp! Universal MarkUp Engine, JQuery plugin
|
||||||
|
// By Jay Salvat - http://markitup.jaysalvat.com/
|
||||||
|
// ------------------------------------------------------------------*/
|
||||||
|
.markItUp * {
|
||||||
|
margin:0px; padding:0px;
|
||||||
|
outline:none;
|
||||||
|
}
|
||||||
|
.markItUp a:link,
|
||||||
|
.markItUp a:visited {
|
||||||
|
color:#000;
|
||||||
|
text-decoration:none;
|
||||||
|
}
|
||||||
|
.markItUp {
|
||||||
|
width:100%;
|
||||||
|
margin:5px 0 5px 0;
|
||||||
|
}
|
||||||
|
.markItUpContainer {
|
||||||
|
font:11px Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
}
|
||||||
|
.markItUpEditor {
|
||||||
|
font:12px 'Courier New', Courier, monospace;
|
||||||
|
padding:0px;
|
||||||
|
width:100%;
|
||||||
|
_height:320px;
|
||||||
|
clear:both;
|
||||||
|
line-height:18px;
|
||||||
|
overflow:auto;
|
||||||
|
}
|
||||||
|
.markItUpPreviewFrame {
|
||||||
|
overflow:auto;
|
||||||
|
background-color:#FFF;
|
||||||
|
width:99.9%;
|
||||||
|
height:300px;
|
||||||
|
margin:5px 0;
|
||||||
|
}
|
||||||
|
.markItUpFooter {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
.markItUpResizeHandle {
|
||||||
|
overflow:hidden;
|
||||||
|
width:22px; height:5px;
|
||||||
|
margin-left:auto;
|
||||||
|
margin-right:auto;
|
||||||
|
background-image:url(images/handle.png);
|
||||||
|
cursor:n-resize;
|
||||||
|
}
|
||||||
|
/***************************************************************************************/
|
||||||
|
/* first row of buttons */
|
||||||
|
.markItUpHeader ul li {
|
||||||
|
list-style:none;
|
||||||
|
float:left;
|
||||||
|
position:relative;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul li:hover > ul{
|
||||||
|
display:block;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul .markItUpDropMenu {
|
||||||
|
background:transparent url(images/menu.png) no-repeat 115% 50%;
|
||||||
|
margin-right:5px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul .markItUpDropMenu li {
|
||||||
|
margin-right:0px;
|
||||||
|
}
|
||||||
|
/* next rows of buttons */
|
||||||
|
.markItUpHeader ul ul {
|
||||||
|
display:none;
|
||||||
|
position:absolute;
|
||||||
|
top:18px; left:0px;
|
||||||
|
background:#FFF;
|
||||||
|
border:1px solid #000;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul li {
|
||||||
|
float:none;
|
||||||
|
border-bottom:1px solid #000;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul .markItUpDropMenu {
|
||||||
|
background:#FFF url(images/submenu.png) no-repeat 100% 50%;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul .markItUpSeparator {
|
||||||
|
margin:0 10px;
|
||||||
|
width:1px;
|
||||||
|
height:16px;
|
||||||
|
overflow:hidden;
|
||||||
|
background-color:#CCC;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul .markItUpSeparator {
|
||||||
|
width:auto; height:1px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
/* next rows of buttons */
|
||||||
|
.markItUpHeader ul ul ul {
|
||||||
|
position:absolute;
|
||||||
|
top:-1px; left:150px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul ul li {
|
||||||
|
float:none;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul a {
|
||||||
|
display:block;
|
||||||
|
width:16px; height:16px;
|
||||||
|
text-indent:-10000px;
|
||||||
|
background-repeat:no-repeat;
|
||||||
|
padding:3px;
|
||||||
|
margin:0px;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul a {
|
||||||
|
display:block;
|
||||||
|
padding-left:0px;
|
||||||
|
text-indent:0;
|
||||||
|
width:120px;
|
||||||
|
padding:5px 5px 5px 25px;
|
||||||
|
background-position:2px 50%;
|
||||||
|
}
|
||||||
|
.markItUpHeader ul ul a:hover {
|
||||||
|
color:#FFF;
|
||||||
|
background-color:#000;
|
||||||
|
}
|
5
styles/bootstrap/markitup/templates/preview.css
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
/* preview style examples */
|
||||||
|
body {
|
||||||
|
background-color:#EFEFEF;
|
||||||
|
font:70% Verdana, Arial, Helvetica, sans-serif;
|
||||||
|
}
|
11
styles/bootstrap/markitup/templates/preview.html
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||||
|
<title>markItUp! preview template</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="~/templates/preview.css" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- content -->
|
||||||
|
</body>
|
||||||
|
</html>
|
138
views/bootstrap/class.EditOnline.php
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Implementation of EditOnline view
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @license GPL 2
|
||||||
|
* @version @version@
|
||||||
|
* @author Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
||||||
|
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
||||||
|
* 2010-2012 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Include parent class
|
||||||
|
*/
|
||||||
|
require_once("class.Bootstrap.php");
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class which outputs the html page for EditOnline view
|
||||||
|
*
|
||||||
|
* @category DMS
|
||||||
|
* @package SeedDMS
|
||||||
|
* @author Markus Westphal, Malcolm Cowe, Uwe Steinmann <uwe@steinmann.cx>
|
||||||
|
* @copyright Copyright (C) 2002-2005 Markus Westphal,
|
||||||
|
* 2006-2008 Malcolm Cowe, 2010 Matteo Lucarelli,
|
||||||
|
* 2010-2012 Uwe Steinmann
|
||||||
|
* @version Release: @package_version@
|
||||||
|
*/
|
||||||
|
class SeedDMS_View_EditOnline extends SeedDMS_Bootstrap_Style {
|
||||||
|
var $dms;
|
||||||
|
var $folder_count;
|
||||||
|
var $document_count;
|
||||||
|
var $file_count;
|
||||||
|
var $storage_size;
|
||||||
|
|
||||||
|
function preview() { /* {{{ */
|
||||||
|
$dms = $this->params['dms'];
|
||||||
|
$document = $this->params['document'];
|
||||||
|
$version = $this->params['version'];
|
||||||
|
?>
|
||||||
|
<ul class="nav nav-tabs" id="preview-tab">
|
||||||
|
<li class="active"><a data-target="#preview_markdown" data-toggle="tab"><?php printMLText('preview_markdown'); ?></a></li>
|
||||||
|
<li><a data-target="#preview_plain" data-toggle="tab"><?php printMLText('preview_plain'); ?></a></li>
|
||||||
|
</ul>
|
||||||
|
<div class="tab-content">
|
||||||
|
<div class="tab-pane active" id="preview_markdown">
|
||||||
|
<?php
|
||||||
|
require_once('parsedown/Parsedown.php');
|
||||||
|
$Parsedown = new Parsedown();
|
||||||
|
echo $Parsedown->text(file_get_contents($dms->contentDir . $version->getPath()));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<div class="tab-pane" id="preview_plain">
|
||||||
|
<?php
|
||||||
|
echo "<pre>".htmlspecialchars(file_get_contents($dms->contentDir . $version->getPath()))."</pre>";
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php
|
||||||
|
} /* }}} */
|
||||||
|
|
||||||
|
function show() { /* {{{ */
|
||||||
|
$dms = $this->params['dms'];
|
||||||
|
$user = $this->params['user'];
|
||||||
|
$document = $this->params['document'];
|
||||||
|
$version = $this->params['version'];
|
||||||
|
$cachedir = $this->params['cachedir'];
|
||||||
|
$previewwidthlist = $this->params['previewWidthList'];
|
||||||
|
$previewwidthdetail = $this->params['previewWidthDetail'];
|
||||||
|
|
||||||
|
$set = 'markdown'; //default or markdown
|
||||||
|
$skin = 'simple'; // simple or markitup
|
||||||
|
$this->htmlAddHeader('<link href="../styles/'.$this->theme.'/markitup/skins/'.$skin.'/style.css" rel="stylesheet">'."\n", 'css');
|
||||||
|
$this->htmlAddHeader('<link href="../styles/'.$this->theme.'/markitup/sets/'.$set.'/style.css" rel="stylesheet">'."\n", 'css');
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/markitup/jquery.markitup.js"></script>'."\n", 'js');
|
||||||
|
$this->htmlAddHeader('<script type="text/javascript" src="../styles/'.$this->theme.'/markitup/sets/'.$set.'/set.js"></script>'."\n", 'js');
|
||||||
|
|
||||||
|
$this->htmlStartPage(getMLText("edit_online"));
|
||||||
|
$this->globalNavigation();
|
||||||
|
$this->contentStart();
|
||||||
|
$folder = $document->getFolder();
|
||||||
|
$this->pageNavigation($this->getFolderPathHTML($folder, true, $document), "view_document", $document);
|
||||||
|
?>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
echo "<div class=\"row-fluid\">\n";
|
||||||
|
|
||||||
|
echo "<div class=\"span6\">\n";
|
||||||
|
$this->contentHeading(getMLText("content"));
|
||||||
|
?>
|
||||||
|
<script language="javascript">
|
||||||
|
$(document).ready(function() {
|
||||||
|
$('#markdown').markItUp(mySettings);
|
||||||
|
|
||||||
|
$('#update').click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
$.post("../op/op.EditOnline.php", $('#form1').serialize(), function(response) {
|
||||||
|
noty({
|
||||||
|
text: response.message,
|
||||||
|
type: response.success === true ? 'success' : 'error',
|
||||||
|
dismissQueue: true,
|
||||||
|
layout: 'topRight',
|
||||||
|
theme: 'defaultTheme',
|
||||||
|
timeout: 1500,
|
||||||
|
});
|
||||||
|
$('div.ajax').trigger('update', {documentid: <?= $document->getId() ?>});
|
||||||
|
}, "json");
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<form action="../op/op.EditOnline.php" id="form1" method="post">
|
||||||
|
<input type="hidden" name="documentid" value="<?= $document->getId() ?>" />
|
||||||
|
<textarea id="markdown" name="data" width="100%" rows="20">
|
||||||
|
<?php
|
||||||
|
echo htmlspecialchars(file_get_contents($dms->contentDir . $version->getPath()));
|
||||||
|
?>
|
||||||
|
</textarea>
|
||||||
|
<button id="update" type="submit" class="btn btn-primary"><i class="icon-save"></i> <?php printMLText("save"); ?></button>
|
||||||
|
</form>
|
||||||
|
<?php
|
||||||
|
echo "</div>\n";
|
||||||
|
|
||||||
|
echo "<div class=\"span6\">\n";
|
||||||
|
$this->contentHeading(getMLText("preview"));
|
||||||
|
echo "<div class=\"ajax\" data-view=\"EditOnline\" data-action=\"preview\" data-query=\"documentid=".$document->getId()."\"></div>";
|
||||||
|
echo "</div>\n";
|
||||||
|
|
||||||
|
echo "</div>\n";
|
||||||
|
|
||||||
|
$this->contentContainerEnd();
|
||||||
|
$this->htmlEndPage();
|
||||||
|
} /* }}} */
|
||||||
|
}
|
||||||
|
?>
|
|
@ -188,6 +188,10 @@ if(!is_writeable($settings->_configFilePath)) {
|
||||||
<td><?php printMLText("settings_viewOnlineFileTypes");?>:</td>
|
<td><?php printMLText("settings_viewOnlineFileTypes");?>:</td>
|
||||||
<td><?php $this->showTextField("viewOnlineFileTypes", $settings->getViewOnlineFileTypesToString()); ?></td>
|
<td><?php $this->showTextField("viewOnlineFileTypes", $settings->getViewOnlineFileTypesToString()); ?></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr title="<?php printMLText("settings_editOnlineFileTypes_desc");?>">
|
||||||
|
<td><?php printMLText("settings_editOnlineFileTypes");?>:</td>
|
||||||
|
<td><?php $this->showTextField("editOnlineFileTypes", $settings->getEditOnlineFileTypesToString()); ?></td>
|
||||||
|
</tr>
|
||||||
<tr title="<?php printMLText("settings_enableConverting_desc");?>">
|
<tr title="<?php printMLText("settings_enableConverting_desc");?>">
|
||||||
<td><?php printMLText("settings_enableConverting");?>:</td>
|
<td><?php printMLText("settings_enableConverting");?>:</td>
|
||||||
<td><input name="enableConverting" type="checkbox" <?php if ($settings->_enableConverting) echo "checked" ?> /></td>
|
<td><input name="enableConverting" type="checkbox" <?php if ($settings->_enableConverting) echo "checked" ?> /></td>
|
||||||
|
|
|
@ -518,6 +518,9 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style {
|
||||||
}
|
}
|
||||||
print "</ul>";
|
print "</ul>";
|
||||||
print "<ul class=\"unstyled actions\">";
|
print "<ul class=\"unstyled actions\">";
|
||||||
|
if($accessop->mayEditVersion()) {
|
||||||
|
print "<li><a href=\"out.EditOnline.php?documentid=".$documentid."&version=".$latestContent->getVersion()."\"><i class=\"icon-edit\"></i>".getMLText("edit_version")."</a></li>";
|
||||||
|
}
|
||||||
/* Only admin has the right to remove version in any case or a regular
|
/* Only admin has the right to remove version in any case or a regular
|
||||||
* user if enableVersionDeletion is on
|
* user if enableVersionDeletion is on
|
||||||
*/
|
*/
|
||||||
|
|